ion-button
Buttonはクリック可能な要素を提供し、Form内や、標準の単機能なButton機能を必要とする任意の場所で使用できます。text、icon、またはその両方を表示できます。Buttonは、いくつかの属性を利用して特定の外観になるようにスタイル設定できます。
基本的な使い方
Expand
このプロパティでは、ボタンの幅を指定することができます。デフォルトでは、ボタンは display: inline-block
を持ちますが、このプロパティを設定すると、ボタンは display: block
を持つ全角要素に変更されます。
Shape
このプロパティは、ボタンの形状を指定することができます。デフォルトでは、ボタンは小さなボーダー半径を持つ長方形ですが、これを "round"
に設定すると、ボタンは丸みを帯びた要素に変更されます。
Fill
この属性は、Buttonのbackgroundとborder-colorを設定します。デフォルトでは、Buttonはtoolbar内にない限り、backgroundは塗りつぶされます。toolbar内にある場合は、backgroundは透明になります。
Size
この属性は、Buttonのサイズを指定します。この属性を設定すると、Buttonの高さとpaddingが変更されます
Icons
テーマ
Colors
CSSカスタムプロパティ
プロパティ
buttonType
Description | The type of button. |
Attribute | button-type |
Type | string |
Default | 'button' |
color
Description | The 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. |
Attribute | color |
Type | "danger" | "dark" | "light" | "medium" | "primary" | "secondary" | "success" | "tertiary" | "warning" | string & Record<never, never> | undefined |
Default | undefined |
disabled
Description | If true , the user cannot interact with the button. |
Attribute | disabled |
Type | boolean |
Default | false |
download
Description | This 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). |
Attribute | download |
Type | string | undefined |
Default | undefined |
expand
Description | Set to "block" for a full-width button or to "full" for a full-width button with square corners and no left or right borders. |
Attribute | expand |
Type | "block" | "full" | undefined |
Default | undefined |
fill
Description | Set 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" . |
Attribute | fill |
Type | "clear" | "default" | "outline" | "solid" | undefined |
Default | undefined |
form
Description | The HTML form element or form element id. Used to submit a form when the button is not a child of the form. |
Attribute | form |
Type | HTMLFormElement | string | undefined |
Default | undefined |
href
Description | Contains a URL or a URL fragment that the hyperlink points to. If this property is set, an anchor tag will be rendered. |
Attribute | href |
Type | string | undefined |
Default | undefined |
mode
Description | The mode determines which platform styles to use. |
Attribute | mode |
Type | "ios" | "md" |
Default | undefined |
rel
Description | Specifies the relationship of the target object to the link object. The value is a space-separated list of link types. |
Attribute | rel |
Type | string | undefined |
Default | undefined |
routerAnimation
Description | When using a router, it specifies the transition animation when navigating to another page using href . |
Attribute | undefined |
Type | ((baseEl: any, opts?: any) => Animation) | undefined |
Default | undefined |
routerDirection
Description | When using a router, it specifies the transition direction when navigating to another page using href . |
Attribute | router-direction |
Type | "back" | "forward" | "root" |
Default | 'forward' |
shape
Description | Set to "round" for a button with more rounded corners. |
Attribute | shape |
Type | "round" | undefined |
Default | undefined |
size
Description | Set 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. |
Attribute | size |
Type | "default" | "large" | "small" | undefined |
Default | undefined |
strong
Description | If true , activates a button with a heavier font weight. |
Attribute | strong |
Type | boolean |
Default | false |
target
Description | Specifies where to display the linked URL. Only applies when an href is provided. Special keywords: "_blank" , "_self" , "_parent" , "_top" . |
Attribute | target |
Type | string | undefined |
Default | undefined |
type
Description | The type of the button. |
Attribute | type |
Type | "button" | "reset" | "submit" |
Default | 'button' |
イベント
Name | Description |
---|---|
ionBlur | Emitted when the button loses focus. |
ionFocus | Emitted when the button has focus. |
メソッド
No public methods available for this component.
CSS Shadow Parts
Name | Description |
---|---|
native | The native HTML button or anchor element that wraps all child elements. |
CSSカスタムプロパティ
Name | Description |
---|---|
--background | Background of the button |
--background-activated | Background of the button when pressed. Note: setting this will interfere with the Material Design ripple. |
--background-activated-opacity | Opacity of the button when pressed |
--background-focused | Background of the button when focused with the tab key |
--background-focused-opacity | Opacity of the button when focused with the tab key |
--background-hover | Background of the button on hover |
--background-hover-opacity | Opacity of the background on hover |
--border-color | Border color of the button |
--border-radius | Border radius of the button |
--border-style | Border style of the button |
--border-width | Border width of the button |
--box-shadow | Box shadow of the button |
--color | Text color of the button |
--color-activated | Text color of the button when pressed |
--color-focused | Text color of the button when focused with the tab key |
--color-hover | Text color of the button when hover |
--opacity | Opacity of the button |
--padding-bottom | Bottom padding of the button |
--padding-end | Right padding if direction is left-to-right, and left padding if direction is right-to-left of the button |
--padding-start | Left padding if direction is left-to-right, and right padding if direction is right-to-left of the button |
--padding-top | Top padding of the button |
--ripple-color | Color of the button ripple effect |
--transition | Transition of the button |
Slots
Name | Description |
---|---|
`` | Content is placed between the named slots if provided without a slot. |
end | Content is placed to the right of the button text in LTR, and to the left in RTL. |
icon-only | Should be used on an icon in a button that has no text. |
start | Content is placed to the left of the button text in LTR, and to the right in RTL. |