ion-button
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.
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 | ボタンの種類です。 |
| Attribute | button-type |
| Type | string |
| Default | 'button' |
color
| Description | アプリケーションのカラーパレットから使用する色を指定します。デフォルトのオプションは以下の通りです。 "primary", "secondary", "tertiary", "success", "warning", "danger", "light", "medium", と "dark" です.色に関する詳しい情報は 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 | この属性は、ブラウザが URL に移動する代わりに URL をダウンロードするように指示し、ユーザはローカルファイルとして保存するように促されます。この属性に値がある場合、保存のプロンプトであらかじめ入力されたファイル名として使用されます(ユーザーはファイル名を変更することができます)。 |
| Attribute | download |
| Type | string | undefined |
| Default | undefined |
expand
| Description | 全角のボタンなら"block"、角が四角く左右のボーダーがない全角のボタンなら"full"に設定します。 |
| Attribute | expand |
| Type | "block" | "full" | undefined |
| Default | undefined |
fill
| Description | フラットなボタンに似た透明なボタンには "clear" を、ボーダーのある透明なボタンには "outline" を、背景を塗りつぶしたボタンには "solid" を設定します。デフォルトの塗りつぶしは "solid" です。ただし、ツールバーの内側では "clear" となります。 |
| Attribute | fill |
| Type | "clear" | "default" | "outline" | "solid" | undefined |
| Default | undefined |
form
| Description | HTML のフォーム要素またはフォーム要素 ID。ボタンがフォームの子でない場合に、フォームを送信するために使用します。 This is a virtual property that is set once during initialization and will not update if you change its value after the initial render. |
| Attribute | form |
| Type | HTMLFormElement | string | undefined |
| Default | undefined |
href
| Description | ハイパーリンクが指し示す URL または URL フラグメントを格納します。このプロパティが設定されている場合、アンカータグがレンダリングされます。 |
| Attribute | href |
| Type | string | undefined |
| Default | undefined |
mode
| Description | modeは、どのプラットフォームのスタイルを使用するかを決定します。 This is a virtual property that is set once during initialization and will not update if you change its value after the initial render. |
| Attribute | mode |
| Type | "ios" | "md" |
| Default | undefined |
rel
| Description | ターゲットオブジェクトとリンクオブジェクトの関係を指定します。値は、スペースで区切られたリンクタイプのリストです。 |
| Attribute | rel |
| Type | string | undefined |
| Default | undefined |
routerAnimation
| Description | ルータを使用する場合、hrefを使用して別のページに移動する際の遷移アニメーションを指定します。 |
| Attribute | router-animation |
| Type | ((baseEl: any, opts?: any) => Animation) | undefined |
| Default | undefined |