Skip to main content
Version: v7

ion-button

shadow

Buttons provide a clickable element, which can be used in forms, or anywhere that needs simple, standard button functionality. They may display text, icons, or both. Buttons can be styled with several attributes to look a specific way.

Basic Usage

Expand

This property lets you specify how wide the button should be. By default, buttons have display: inline-block, but setting this property will change the button to a full-width element with display: block.

Shape

This property lets you specify the shape of the button. By default, buttons are rectangular with a small border radius, but setting this to "round" will change the button to a rounded element.

Fill

This property determines the background and border color of the button. By default, buttons have a solid background unless the button is inside of a toolbar, in which case it has a transparent background.

Size

This property specifies the size of the button. Setting this property will change the height and padding of a button.

Icons

Theming

Colors

CSS Custom Properties

Accessibility

Buttons are built to be accessible, but may need some adjustments depending on their content. The button component renders a native button element which allows it to take advantage of the functionality that a native button provides.

Overflowing Text Content

There are many cases where a button's text content may overflow the container. It is recommended to wrap the text inside of the button when this happens so that all of the text can still be read. The button component will automatically adjust its height to accommodate the extra lines of text.

The button text does not automatically wrap to the next line when the text is too long to fit. In order to make the text wrap, the ion-text-wrap class can be added, which will set the white-space property to "normal". This will become the default in a future major release.

info

The max-width style is set on the button below for demo purposes only. Text wrapping will work with a dynamic button width.

Properties

buttonType

Descriptionボタンの種類です。
Attributebutton-type
Typestring
Default'button'

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

disabled

Descriptiontrueの場合、ユーザはボタンと対話することができません。
Attributedisabled
Typeboolean
Defaultfalse

download

DescriptionThis attribute instructs browsers to download a URL instead of navigating to it, so the user will be prompted to save it as a local file. If the attribute has a value, it is used as the pre-filled file name in the Save prompt (the user can still change the file name if they want).
Attributedownload
Typestring | undefined
Defaultundefined

expand

DescriptionSet to "block" for a full-width button or to "full" for a full-width button with square corners and no left or right borders.
Attributeexpand
Type"block" | "full" | undefined
Defaultundefined

fill

DescriptionSet to "clear" for a transparent button that resembles a flat button, to "outline" for a transparent button with a border, or to "solid" for a button with a filled background. The default fill is "solid" except inside of a toolbar, where the default is "clear".
Attributefill
Type"clear" | "default" | "outline" | "solid" | undefined
Defaultundefined

form

DescriptionHTML のフォーム要素またはフォーム要素 ID。ボタンがフォームの子でない場合に、フォームを送信するために使用します。
Attributeform
TypeHTMLFormElement | string | undefined
Defaultundefined

href

DescriptionContains a URL or a URL fragment that the hyperlink points to. If this property is set, an anchor tag will be rendered.
Attributehref
Typestring | undefined
Defaultundefined

mode

Descriptionmodeは、どのプラットフォームのスタイルを使用するかを決定します。
Attributemode
Type"ios" | "md"
Defaultundefined

rel

DescriptionSpecifies the relationship of the target object to the link object. The value is a space-separated list of link types.
Attributerel
Typestring | undefined
Defaultundefined

routerAnimation

DescriptionWhen using a router, it specifies the transition animation when navigating to another page using href.
Attributeundefined
Type((baseEl: any, opts?: any) => Animation) | undefined
Defaultundefined

routerDirection

DescriptionWhen using a router, it specifies the transition direction when navigating to another page using href.
Attributerouter-direction
Type"back" | "forward" | "root"
Default'forward'

shape

Descriptionround"` に設定すると、より角が丸いボタンになります。
Attributeshape
Type"round" | undefined
Defaultundefined

size

DescriptionSet to "small" for a button with less height and padding, to "default" for a button with the default height and padding, or to "large" for a button with more height and padding. By default the size is unset, unless the button is inside of an item, where the size is "small" by default. Set the size to "default" inside of an item to make it a standard size button.
Attributesize
Type"default" | "large" | "small" | undefined
Defaultundefined

strong

Descriptiontrueの場合、より重いFont Weightを持つボタンをアクティブにします。
Attributestrong
Typeboolean
Defaultfalse

target

DescriptionSpecifies where to display the linked URL. Only applies when an href is provided. Special keywords: "_blank", "_self", "_parent", "_top".
Attributetarget
Typestring | undefined
Defaultundefined

type

Descriptionボタンの種類です。
Attributetype
Type"button" | "reset" | "submit"
Default'button'

Events

NameDescriptionBubbles
ionBlurボタンのフォーカスが外れたときに発行されます。true
ionFocusボタンにフォーカスが当たっているときに発行されます。true

Methods

No public methods available for this component.

CSS Shadow Parts

NameDescription
nativeすべての子要素をラップするネイティブHTMLのボタンまたはアンカー要素です。

CSS Custom Properties

NameDescription
--backgroundボタンの背景
--background-activatedボタンが押されたときの背景。注意:これを設定すると、Material Designの波紋に干渉します。
--background-activated-opacityボタンが押されたときの不透明度
--background-focusedタブキーでフォーカスしたときのボタンの背景
--background-focused-opacityタブキーでフォーカスしたときのボタンの不透明度
--background-hoverホバー時のボタンの背景
--background-hover-opacityホバー時の背景の不透明度
--border-colorボタンのボーダーカラー
--border-radiusボタンの境界半径
--border-styleボタンのボーダースタイル
--border-widthボタンのボーダー幅
--box-shadowボタンのボックスシャドウ
--colorボタンの文字色
--color-activatedボタンが押されたときの文字色
--color-focusedタブキーでフォーカスしたときのボタンの文字色
--color-hoverホバー時のボタンの文字色
--opacityボタンの不透明度
--padding-bottomボタンのBottom Padding
--padding-endボタンの向きが左から右の場合はRight Padding、右から左の場合はLeft Paddingとなります。
--padding-startボタンの向きが左から右の場合はLeft Padding、右から左の場合はRight Paddingとなります。
--padding-topボタンのTop Padding
--ripple-colorボタンリプルエフェクトの色
--transitionボタンの遷移

Slots

NameDescription
``slotがない状態で提供される場合、コンテンツは名前付きslotの間に配置されます。
endコンテンツは、LTRの場合はボタンテキストの右側に、RTLの場合は左側に配置されます。
icon-onlyテキストを持たないボタン内のアイコンに対して使用されるべきです。
startコンテンツは、LTRではボタンテキストの左側に、RTLでは右側に配置されます。