Skip to main content
Version: v6

ion-content

shadow

The content component provides an easy to use content area with some useful methods to control the scrollable area. There should only be one content in a single view.

Content, along with many other Ionic components, can be customized to modify its padding, margin, and more using the global styles provided in the CSS Utilities or by individually styling it using CSS and the available CSS Custom Properties.

Basic Usage

Content can be the only top-level component in a page, or it can be used alongside a header, footer, or both. When used with a header or footer, it will adjust its size to fill the remaining height.

Fullscreen Content

By default, content fills the space between a header and footer but does not go behind them. In certain cases, it may be desired to have the content scroll behind the header and footer, such as when the translucent property is set on either of them, or opacity is set on the toolbar. This can be achieved by setting the fullscreen property on the content to true.

Fixed Content

To place elements outside of the scrollable area, assign them to the fixed slot. Doing so will absolutely position the element to the top left of the content. In order to change the position of the element, it can be styled using the top, right, bottom, and left CSS properties.

Scroll Methods

Content provides methods that can be called to scroll the content to the bottom, top, or to a specific point. They can be passed a duration in order to smoothly transition instead of instantly changing the position.

Scroll Events

Scroll events are disabled by default for content due to performance. However, they can be enabled by setting scrollEvents to true. This is necessary before listening to any of the scroll events.

Theming

Colors

CSS Shadow Parts

CSS Custom Properties

Interfaces

ScrollBaseDetail

interface ScrollBaseDetail {
isScrolling: boolean;
}

ScrollDetail

interface ScrollDetail extends GestureDetail, ScrollBaseDetail {
scrollTop: number;
scrollLeft: number;
}

ScrollBaseCustomEvent

While not required, this interface can be used in place of the CustomEvent interface for stronger typing on the ionScrollStart and ionScrollEnd events.

interface ScrollBaseCustomEvent extends CustomEvent {
detail: ScrollBaseDetail;
target: HTMLIonContentElement;
}

ScrollCustomEvent

While not required, this interface can be used in place of the CustomEvent interface for stronger typing on the ionScroll event.

interface ScrollCustomEvent extends ScrollBaseCustomEvent {
detail: ScrollDetail;
}

Properties

color

DescriptionThe color to use from your application's color palette. Default options are: "primary", "secondary", "tertiary", "success", "warning", "danger", "light", "medium", and "dark". For more information on colors, see theming.
Attributecolor
Type"danger" | "dark" | "light" | "medium" | "primary" | "secondary" | "success" | "tertiary" | "warning" | string | undefined
Defaultundefined

forceOverscroll

DescriptionIf true and the content does not cause an overflow scroll, the scroll interaction will cause a bounce. If the content exceeds the bounds of ionContent, nothing will change. Note, the does not disable the system bounce on iOS. That is an OS level setting.
Attributeforce-overscroll
Typeboolean | undefined
Defaultundefined

fullscreen

DescriptionIf true, the content will scroll behind the headers and footers. This effect can easily be seen by setting the toolbar to transparent.
Attributefullscreen
Typeboolean
Defaultfalse

scrollEvents

DescriptionBecause of performance reasons, ionScroll events are disabled by default, in order to enable them and start listening from (ionScroll), set this property to true.
Attributescroll-events
Typeboolean
Defaultfalse

scrollX

DescriptionX軸方向のコンテンツスクロールを有効にしたい場合は、このプロパティをtrueに設定します。
Attributescroll-x
Typeboolean
Defaultfalse

scrollY

DescriptionY軸方向のコンテンツスクロールを無効にしたい場合は、このプロパティにfalseを設定します。
Attributescroll-y
Typeboolean
Defaulttrue

Events

NameDescription
ionScrollEmitted while scrolling. This event is disabled by default. Set scrollEvents to true to enable.
ionScrollEndEmitted when the scroll has ended. This event is disabled by default. Set scrollEvents to true to enable.
ionScrollStartEmitted when the scroll has started. This event is disabled by default. Set scrollEvents to true to enable.

Methods

getScrollElement

DescriptionGet the element where the actual scrolling takes place. This element can be used to subscribe to scroll events or manually modify scrollTop. However, it's recommended to use the API provided by ion-content:

i.e. Using ionScroll, ionScrollStart, ionScrollEnd for scrolling events and scrollToPoint() to scroll the content into a certain point.
SignaturegetScrollElement() => Promise<HTMLElement>

scrollByPoint

Descriptionコンポーネントを指定したX/Y距離だけスクロールさせる。
SignaturescrollByPoint(x: number, y: number, duration: number) => Promise<void>

scrollToBottom

Descriptionコンポーネントの一番下までスクロールします。
SignaturescrollToBottom(duration?: number) => Promise<void>

scrollToPoint

Descriptionコンポーネント内の指定したX/Y位置までスクロールします。
SignaturescrollToPoint(x: number | undefined | null, y: number | undefined | null, duration?: number) => Promise<void>

scrollToTop

Descriptionコンポーネントの上部にスクロールします。
SignaturescrollToTop(duration?: number) => Promise<void>

CSS Shadow Parts

NameDescription
backgroundコンテンツの背景です。
scrollコンテンツのスクロール可能なコンテナ。

CSS Custom Properties

NameDescription
--backgroundコンテンツの背景
--colorコンテンツの色
--keyboard-offsetコンテンツのキーボードオフセット
--offset-bottomコンテンツのオフセットボトム
--offset-topコンテンツのオフセットトップ
--padding-bottomコンテンツのBottom Padding
--padding-endコンテンツの方向が左から右の場合はRight Padding、右から左の場合はLeft Paddingとなります。
--padding-startコンテンツの方向が左から右の場合はLeft Padding、右から左の場合はRight Paddingとなります。
--padding-topコンテンツのTop Padding

Slots

NameDescription
``slotなしで提供される場合、コンテンツはスクロール可能な領域に配置されます。
fixedスクロールしてはいけない固定コンテンツに使用する必要があります。