メインコンテンツまでスキップ
Version: v6

ion-button

shadow

コンテンツ

Buttonはクリック可能な要素を提供し、Form内や、標準の単機能なButton機能を必要とする任意の場所で使用できます。text、icon、またはその両方を表示できます。Buttonは、いくつかの属性を利用して特定の外観になるようにスタイル設定できます。

Expand

この属性では、Buttonの横幅を指定します。デフォルトでは、ボタンはinline-blockですが、Expandを設定すると、Buttonは横幅100%のblock要素になります。

ValueDetails
blockFull-width button with rounded corners.
fullFull-width button with square corners and no border on the left or right.

Fill

この属性は、Buttonのbackgroundとborder-colorを設定します。デフォルトでは、Buttonはtoolbar内にない限り、backgroundは塗りつぶされます。toolbar内にある場合は、backgroundは透明になります。

ValueDetails
clearButton with a transparent background that resembles a flat button.
outlineButton with a transparent background and a visible border.
solidButton with a filled background. Useful for buttons in a toolbar.

Size

この属性は、Buttonのサイズを指定します。この属性を設定すると、Buttonの高さとpaddingが変更されます。

ValueDetails
smallButton with less height and padding. Default for buttons in an item.
defaultButton with the default height and padding. Useful for buttons in an item.
largeButton with more height and padding.

使い方

<!-- 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>

プロパティ

buttonType

DescriptionThe type of button.
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 & Record<never, never> | undefined
Defaultundefined

disabled

DescriptionIf true, the user cannot interact with the button.
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

DescriptionThe HTML form element or form element id. Used to submit a form when the button is not a child of the form.
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

DescriptionThe mode determines which platform styles to use.
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

DescriptionSet to "round" for a button with more rounded corners.
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

DescriptionIf true, activates a button with a heavier 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

DescriptionThe type of the button.
Attributetype
Type"button" | "reset" | "submit"
Default'button'

イベント

NameDescription
ionBlurEmitted when the button loses focus.
ionFocusEmitted when the button has focus.

メソッド

No public methods available for this component.

CSS Shadow Parts

NameDescription
nativeThe native HTML button or anchor element that wraps all child elements.

CSSカスタムプロパティ

NameDescription
--backgroundBackground of the button
--background-activatedBackground of the button when pressed. Note: setting this will interfere with the Material Design ripple.
--background-activated-opacityOpacity of the button when pressed
--background-focusedBackground of the button when focused with the tab key
--background-focused-opacityOpacity of the button when focused with the tab key
--background-hoverBackground of the button on hover
--background-hover-opacityOpacity of the background on hover
--border-colorBorder color of the button
--border-radiusBorder radius of the button
--border-styleBorder style of the button
--border-widthBorder width of the button
--box-shadowBox shadow of the button
--colorText color of the button
--color-activatedText color of the button when pressed
--color-focusedText color of the button when focused with the tab key
--color-hoverText color of the button when hover
--opacityOpacity of the button
--padding-bottomBottom padding of the button
--padding-endRight padding if direction is left-to-right, and left padding if direction is right-to-left of the button
--padding-startLeft padding if direction is left-to-right, and right padding if direction is right-to-left of the button
--padding-topTop padding of the button
--ripple-colorColor of the button ripple effect
--transitionTransition of the button

Slots

NameDescription
``Content is placed between the named slots if provided without a slot.
endContent is placed to the right of the button text in LTR, and to the left in RTL.
icon-onlyShould be used on an icon in a button that has no text.
startContent is placed to the left of the button text in LTR, and to the right in RTL.
View Source