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.
Expand
This attribute lets you specify how wide the button should be. By default, buttons are inline blocks, but setting this attribute will change the button to a full-width block element.
Value | Details |
---|---|
block | Full-width button with rounded corners. |
full | Full-width button with square corners and no border on the left or right. |
Fill
This attributes 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.
Value | Details |
---|---|
clear | Button with a transparent background that resembles a flat button. |
outline | Button with a transparent background and a visible border. |
solid | Button with a filled background. Useful for buttons in a toolbar. |
Size
This attribute specifies the size of the button. Setting this attribute will change the height and padding of a button.
Value | Details |
---|---|
small | Button with less height and padding. Default for buttons in an item. |
default | Button with the default height and padding. Useful for buttons in an item. |
large | Button with more height and padding. |
Usage
- Angular
- Javascript
- React
- Stencil
- Vue
<!-- Default -->
<ion-button>Default</ion-button>
<!-- Anchor -->
<ion-button href="#">Anchor</ion-button>
<!-- Colors -->
<ion-button color="primary">Primary</ion-button>
<ion-button color="secondary">Secondary</ion-button>
<ion-button color="tertiary">Tertiary</ion-button>
<ion-button color="success">Success</ion-button>
<ion-button color="warning">Warning</ion-button>
<ion-button color="danger">Danger</ion-button>
<ion-button color="light">Light</ion-button>
<ion-button color="medium">Medium</ion-button>
<ion-button color="dark">Dark</ion-button>
<!-- Expand -->
<ion-button expand="full">Full Button</ion-button>
<ion-button expand="block">Block Button</ion-button>
<!-- Round -->
<ion-button shape="round">Round Button</ion-button>
<!-- Fill -->
<ion-button expand="full" fill="outline">Outline + Full</ion-button>
<ion-button expand="block" fill="outline">Outline + Block</ion-button>
<ion-button shape="round" fill="outline">Outline + Round</ion-button>
<!-- Icons -->
<ion-button>
<ion-icon slot="start" name="star"></ion-icon>
Left Icon
</ion-button>
<ion-button>
Right Icon
<ion-icon slot="end" name="star"></ion-icon>
</ion-button>
<ion-button>
<ion-icon slot="icon-only" name="star"></ion-icon>
</ion-button>
<!-- Sizes -->
<ion-button size="large">Large</ion-button>
<ion-button>Default</ion-button>
<ion-button size="small">Small</ion-button>
<!-- Default -->
<ion-button>Default</ion-button>
<!-- Anchor -->
<ion-button href="#">Anchor</ion-button>
<!-- Colors -->
<ion-button color="primary">Primary</ion-button>
<ion-button color="secondary">Secondary</ion-button>
<ion-button color="tertiary">Tertiary</ion-button>
<ion-button color="success">Success</ion-button>
<ion-button color="warning">Warning</ion-button>
<ion-button color="danger">Danger</ion-button>
<ion-button color="light">Light</ion-button>
<ion-button color="medium">Medium</ion-button>
<ion-button color="dark">Dark</ion-button>
<!-- Expand -->
<ion-button expand="full">Full Button</ion-button>
<ion-button expand="block">Block Button</ion-button>
<!-- Round -->
<ion-button shape="round">Round Button</ion-button>
<!-- Fill -->
<ion-button expand="full" fill="outline">Outline + Full</ion-button>
<ion-button expand="block" fill="outline">Outline + Block</ion-button>
<ion-button shape="round" fill="outline">Outline + Round</ion-button>
<!-- Icons -->
<ion-button>
<ion-icon slot="start" name="star"></ion-icon>
Left Icon
</ion-button>
<ion-button>
Right Icon
<ion-icon slot="end" name="star"></ion-icon>
</ion-button>
<ion-button>
<ion-icon slot="icon-only" name="star"></ion-icon>
</ion-button>
<!-- Sizes -->
<ion-button size="large">Large</ion-button>
<ion-button>Default</ion-button>
<ion-button size="small">Small</ion-button>
import React from 'react';
import { IonButton, IonIcon, IonContent } from '@ionic/react';
import { star } from 'ionicons/icons';
export const ButtonExample: React.FC = () => (
<IonContent>
{/*-- Default --*/}
<IonButton>Default</IonButton>
{/*-- Anchor --*/}
<IonButton href="#">Anchor</IonButton>
{/*-- Colors --*/}
<IonButton color="primary">Primary</IonButton>
<IonButton color="secondary">Secondary</IonButton>
<IonButton color="tertiary">Tertiary</IonButton>
<IonButton color="success">Success</IonButton>
<IonButton color="warning">Warning</IonButton>
<IonButton color="danger">Danger</IonButton>
<IonButton color="light">Light</IonButton>
<IonButton color="medium">Medium</IonButton>
<IonButton color="dark">Dark</IonButton>
{/*-- Expand --*/}
<IonButton expand="full">Full Button</IonButton>
<IonButton expand="block">Block Button</IonButton>
{/*-- Round --*/}
<IonButton shape="round">Round Button</IonButton>
{/*-- Fill --*/}
<IonButton expand="full" fill="outline">
Outline + Full
</IonButton>
<IonButton expand="block" fill="outline">
Outline + Block
</IonButton>
<IonButton shape="round" fill="outline">
Outline + Round
</IonButton>
{/*-- Icons --*/}
<IonButton>
<IonIcon slot="start" icon={star} />
Left Icon
</IonButton>
<IonButton>
Right Icon
<IonIcon slot="end" icon={star} />
</IonButton>
<IonButton>
<IonIcon slot="icon-only" icon={star} />
</IonButton>
{/*-- Sizes --*/}
<IonButton size="large">Large</IonButton>
<IonButton>Default</IonButton>
<IonButton size="small">Small</IonButton>
</IonContent>
);
import { Component, h } from '@stencil/core';
@Component({
tag: 'button-example',
styleUrl: 'button-example.css',
})
export class ButtonExample {
render() {
return [
// Default
<ion-button>Default</ion-button>,
// Anchor
<ion-button href="#">Anchor</ion-button>,
// Colors
<ion-button color="primary">Primary</ion-button>,
<ion-button color="secondary">Secondary</ion-button>,
<ion-button color="tertiary">Tertiary</ion-button>,
<ion-button color="success">Success</ion-button>,
<ion-button color="warning">Warning</ion-button>,
<ion-button color="danger">Danger</ion-button>,
<ion-button color="light">Light</ion-button>,
<ion-button color="medium">Medium</ion-button>,
<ion-button color="dark">Dark</ion-button>,
// Expand
<ion-button expand="full">Full Button</ion-button>,
<ion-button expand="block">Block Button</ion-button>,
// Round
<ion-button shape="round">Round Button</ion-button>,
// Fill
<ion-button expand="full" fill="outline">
Outline + Full
</ion-button>,
<ion-button expand="block" fill="outline">
Outline + Block
</ion-button>,
<ion-button shape="round" fill="outline">
Outline + Round
</ion-button>,
// Icons
<ion-button>
<ion-icon slot="start" name="star"></ion-icon>
Left Icon
</ion-button>,
<ion-button>
Right Icon
<ion-icon slot="end" name="star"></ion-icon>
</ion-button>,
<ion-button>
<ion-icon slot="icon-only" name="star"></ion-icon>
</ion-button>,
// Sizes
<ion-button size="large">Large</ion-button>,
<ion-button>Default</ion-button>,
<ion-button size="small">Small</ion-button>,
];
}
}
<template>
<!-- Default -->
<ion-button>Default</ion-button>
<!-- Anchor -->
<ion-button href="#">Anchor</ion-button>
<!-- Colors -->
<ion-button color="primary">Primary</ion-button>
<ion-button color="secondary">Secondary</ion-button>
<ion-button color="tertiary">Tertiary</ion-button>
<ion-button color="success">Success</ion-button>
<ion-button color="warning">Warning</ion-button>
<ion-button color="danger">Danger</ion-button>
<ion-button color="light">Light</ion-button>
<ion-button color="medium">Medium</ion-button>
<ion-button color="dark">Dark</ion-button>
<!-- Expand -->
<ion-button expand="full">Full Button</ion-button>
<ion-button expand="block">Block Button</ion-button>
<!-- Round -->
<ion-button shape="round">Round Button</ion-button>
<!-- Fill -->
<ion-button expand="full" fill="outline">Outline + Full</ion-button>
<ion-button expand="block" fill="outline">Outline + Block</ion-button>
<ion-button shape="round" fill="outline">Outline + Round</ion-button>
<!-- Icons -->
<ion-button>
<ion-icon slot="start" name="star"></ion-icon>
Left Icon
</ion-button>
<ion-button>
Right Icon
<ion-icon slot="end" name="star"></ion-icon>
</ion-button>
<ion-button>
<ion-icon slot="icon-only" name="star"></ion-icon>
</ion-button>
<!-- Sizes -->
<ion-button size="large">Large</ion-button>
<ion-button>Default</ion-button>
<ion-button size="small">Small</ion-button>
</template>
<script>
import { IonButton } from '@ionic/vue';
import { defineComponent } from 'vue';
export default defineComponent({
components: { IonButton },
});
</script>
Properties
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 | 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 without left and right borders. |
Attribute | expand |
Type | "block" | "full" | undefined |
Default | undefined |
fill
Description | Set to "clear" for a transparent button, to "outline" for a transparent button with a border, or to "solid" . The default style is "solid" except inside of a toolbar, where the default is "clear" . |
Attribute | fill |
Type | "clear" | "default" | "outline" | "solid" | 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 | 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 | The button shape. |
Attribute | shape |
Type | "round" | undefined |
Default | undefined |
size
Description | The button size. |
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' |
Events
Name | Description |
---|---|
ionBlur | ボタンのフォーカスが外れたときに発行されます。 |
ionFocus | ボタンにフォーカスが当たっているときに発行されます。 |
Methods
No public methods available for this component.
CSS Shadow Parts
Name | Description |
---|---|
native | すべての子要素をラップするネイティブHTMLのボタンまたはアンカー要素です。 |
CSS Custom Properties
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では右側に配置されます。 |