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カスタムプロパティ
アクセシビリティ
ボタンはアクセスしやすいように作られていますが、その内容によっては調整が必要な場合があります。ボタンコンポーネントは、ネイティブのbutton elementをレンダリングし、ネイティブのボタンが提供する機能を利用できるようにします。
Overflowing Text Content
ボタンのテキスト・コンテンツがコンテナからはみ出す場合が多々あります。このような場合、すべてのテキストがまだ読めるように、ボタンの内側にテキストを折り返すことをお勧めします。ボタンコンポーネントは、テキストの余分な行を収容するために、その高さを自動的に調整します。
テキストが長すぎて収まらない場合、ボタンテキストは自動的に次の行に折り返されません。テキストを折り返すには、ion-text-wrap
クラスを追加して、white-space
プロパティを"normal"
に設定します。これは将来のメジャーリリースでデフォルトになる予定である。
max-width`スタイルは、デモのためだけに下のボタンに設定されています。テキストラッピングは動的なボタン幅で動作します。
プロパティ
buttonType
Description | ボタンの種類です。 |
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 | undefined |
Default | undefined |
disabled
Description | true の場合、ユーザはボタンと対話することができません。 |
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 | HTML のフォーム要素またはフォーム要素 ID。ボタンがフォームの子でない場合に、フォームを送信するために使用します。 |
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 | modeは、どのプラットフォームのスタイルを使用するかを決定します。 |
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 | router-animation |
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 | round"` に設定すると、より角が丸いボタンになります。 |
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 | true の場合、より重い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 | ボタンの種類です。 |
Attribute | type |
Type | "button" | "reset" | "submit" |
Default | 'button' |
イベント
Name | Description | Bubbles |
---|---|---|
ionBlur | ボタンのフォーカスが外れたときに発行されます。 | true |
ionFocus | ボタンにフォーカスが当たっているときに発行されます。 | true |
メソッド
No public methods available for this component.
CSS Shadow Parts
Name | Description |
---|---|
native | すべての子要素をラップするネイティブHTMLのボタンまたはアンカー要素です。 |
CSSカスタムプロパティ
- iOS
- MD
Name | Description |
---|---|
--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 | ボタンの遷移 |
Name | Description |
---|---|
--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
Name | Description |
---|---|
`` | slotがない状態で提供される場合、コンテンツは名前付きslotの間に配置されます。 |
end | コンテンツは、LTRの場合はボタンテキストの右側に、RTLの場合は左側に配置されます。 |
icon-only | テキストを持たないボタン内のアイコンに対して使用されるべきです。 |
start | コンテンツは、LTRではボタンテキストの左側に、RTLでは右側に配置されます。 |