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.
#
ExpandThis 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. |
#
FillThis 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. |
#
SizeThis 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
#
Properties#
buttonTypeDescription | The type of button. |
Attribute | button-type |
Type | string |
Default | 'button' |
#
colorDescription | 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 |
#
disabledDescription | If true , the user cannot interact with the button. |
Attribute | disabled |
Type | boolean |
Default | false |
#
downloadDescription | 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 |
#
expandDescription | Set to "block" for a full-width button or to "full" for a full-width buttonwithout left and right borders. |
Attribute | expand |
Type | "block" \| "full" \| undefined |
Default | undefined |
#
fillDescription | Set to "clear" for a transparent button, to "outline" for a transparentbutton with a border, or to "solid" . The default style is "solid" except inside ofa toolbar, where the default is "clear" . |
Attribute | fill |
Type | "clear" \| "default" \| "outline" \| "solid" \| undefined |
Default | undefined |
#
hrefDescription | 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 |
#
modeDescription | The mode determines which platform styles to use. |
Attribute | mode |
Type | "ios" \| "md" |
Default | undefined |
#
relDescription | 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 |
#
routerAnimationDescription | 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 |
#
routerDirectionDescription | 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' |
#
shapeDescription | The button shape. |
Attribute | shape |
Type | "round" \| undefined |
Default | undefined |
#
sizeDescription | The button size. |
Attribute | size |
Type | "default" \| "large" \| "small" \| undefined |
Default | undefined |
#
strongDescription | If true , activates a button with a heavier font weight. |
Attribute | strong |
Type | boolean |
Default | false |
#
targetDescription | 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 |
#
typeDescription | The type of the button. |
Attribute | type |
Type | "button" \| "reset" \| "submit" |
Default | 'button' |
#
EventsName | Description |
---|---|
ionBlur | Emitted when the button loses focus. |
ionFocus | Emitted when the button has focus. |
#
CSS Shadow PartsName | Description |
---|---|
native | The native HTML button or anchor element that wraps all child elements. |
#
CSS Custom PropertiesName | 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 |
#
SlotsName | 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. |