2017-05-18 04:28:45 +00:00
< style >
.demo-box.demo-button {
.el-row {
margin-bottom: 10px;
}
.el-button + .el-button {
margin-left: 10px;
}
.el-button-group {
margin-bottom: 20px;
.el-button + .el-button {
margin-left: 0;
}
& + .el-button-group {
margin-left: 10px;
}
}
}
< / style >
2016-11-10 13:46:55 +00:00
## Button
Commonly used button.
### Basic usage
2017-08-23 12:38:14 +00:00
::: demo Use `type` , `plain` and `round` to define Button's style.
2016-11-10 13:46:55 +00:00
```html
2017-08-23 10:07:14 +00:00
< div >
< el-button > Default< / el-button >
< el-button type = "primary" > Primary< / el-button >
< el-button type = "success" > Success< / el-button >
< el-button type = "info" > Info< / el-button >
< el-button type = "warning" > Warning< / el-button >
< el-button type = "danger" > Danger< / el-button >
< / div >
< div style = "margin: 20px 0" >
< el-button plain > Plain< / el-button >
< el-button type = "primary" plain > Primary< / el-button >
< el-button type = "success" plain > Success< / el-button >
< el-button type = "info" plain > Info< / el-button >
< el-button type = "warning" plain > Warning< / el-button >
< el-button type = "danger" plain > Danger< / el-button >
< / div >
< div >
< el-button round > Round< / el-button >
< el-button type = "primary" round > Primary< / el-button >
< el-button type = "success" round > Success< / el-button >
< el-button type = "info" round > Info< / el-button >
< el-button type = "warning" round > Warning< / el-button >
< el-button type = "danger" round > Danger< / el-button >
< / div >
2016-11-10 13:46:55 +00:00
```
:::
### Disabled Button
2017-08-23 10:07:14 +00:00
The `disabled` attribute determines if the button is disabled.
2016-11-10 13:46:55 +00:00
:::demo Use `disabled` attribute to determine whether a button is disabled. It accepts a `Boolean` value.
```html
2017-08-23 10:07:14 +00:00
< div >
< el-button disabled > Default< / el-button >
< el-button type = "primary" disabled > Primary< / el-button >
< el-button type = "success" disabled > Success< / el-button >
< el-button type = "info" disabled > Info< / el-button >
< el-button type = "warning" disabled > Warning< / el-button >
< el-button type = "danger" disabled > Danger< / el-button >
< / div >
< div style = "margin-top: 20px" >
< el-button plain disabled > Plain< / el-button >
< el-button type = "primary" plain disabled > Primary< / el-button >
< el-button type = "success" plain disabled > Success< / el-button >
< el-button type = "info" plain disabled > Info< / el-button >
< el-button type = "warning" plain disabled > Warning< / el-button >
< el-button type = "danger" plain disabled > Danger< / el-button >
< / div >
2016-11-10 13:46:55 +00:00
```
:::
2017-08-23 10:07:14 +00:00
### Text Button
2016-11-10 13:46:55 +00:00
2017-08-23 10:07:14 +00:00
Buttons without border and background.
2016-11-10 13:46:55 +00:00
2017-08-23 10:07:14 +00:00
:::demo
2016-11-10 13:46:55 +00:00
```html
2017-08-23 10:07:14 +00:00
< el-button type = "text" > Text Button< / el-button >
< el-button type = "text" disabled > Text Button< / el-button >
2016-11-10 13:46:55 +00:00
```
:::
2016-12-26 03:41:15 +00:00
### Icon Button
2016-11-10 13:46:55 +00:00
2017-08-23 10:07:14 +00:00
Use icons to add more meaning to Button. You can use icon alone to save some space, or use it with text.
2016-11-10 13:46:55 +00:00
:::demo Use the `icon` attribute to add icon. You can find the icon list in Element icon component. Adding icons to the right side of the text is achievable with an `<i>` tag. Custom icons can be used as well.
```html
< el-button type = "primary" icon = "edit" > < / el-button >
< el-button type = "primary" icon = "share" > < / el-button >
< el-button type = "primary" icon = "delete" > < / el-button >
< el-button type = "primary" icon = "search" > Search< / el-button >
< el-button type = "primary" > Upload< i class = "el-icon-upload el-icon-right" > < / i > < / el-button >
```
:::
### Button Group
Displayed as a button group, can be used to group a series of similar operations.
:::demo Use tag `<el-button-group>` to group your buttons.
```html
< el-button-group >
< el-button type = "primary" icon = "arrow-left" > Previous Page< / el-button >
< el-button type = "primary" > Next Page< i class = "el-icon-arrow-right el-icon-right" > < / i > < / el-button >
< / el-button-group >
< el-button-group >
< el-button type = "primary" icon = "edit" > < / el-button >
< el-button type = "primary" icon = "share" > < / el-button >
< el-button type = "primary" icon = "delete" > < / el-button >
< / el-button-group >
```
:::
### Loading Button
Click the button to load data, then the button displays a loading state.
:::demo Set `loading` attribute to `true` to display loading state.
```html
< el-button type = "primary" :loading = "true" > Loading< / el-button >
```
:::
### Sizes
Besides default size, Button component provides three additional sizes for you to choose among different scenarios.
2017-08-23 10:07:14 +00:00
:::demo Use attribute `size` to set additional sizes with `medium` , `small` or `mini` .
2016-11-10 13:46:55 +00:00
```html
2017-08-23 10:07:14 +00:00
< div >
< el-button > Default< / el-button >
< el-button size = "medium" > Medium< / el-button >
< el-button size = "small" > Small< / el-button >
< el-button size = "mini" > Mini< / el-button >
< / div >
< div style = "margin-top: 20px" >
< el-button round > Default< / el-button >
< el-button size = "medium" round > Medium< / el-button >
< el-button size = "small" round > Small< / el-button >
< el-button size = "mini" round > Mini< / el-button >
< / div >
2016-11-10 13:46:55 +00:00
```
:::
### Attributes
| Attribute | Description | Type | Accepted values | Default |
|---------- |-------- |---------- |------------- |-------- |
2017-08-23 10:07:14 +00:00
| size | button size | string | large / small / mini | — |
| type | button type | string | primary / success / warning / danger / info / text | — |
| plain | determine whether it's a plain button | boolean | — | false |
| round | determine whether it's a round button | boolean | — | false |
| loading | determine whether it's loading | boolean | — | false |
2016-12-13 15:10:41 +00:00
| disabled | disable the button | boolean | — | false |
2016-11-10 13:46:55 +00:00
| icon | button icon, accepts an icon name of Element icon component | string | — | — |
| autofocus | same as native button's `autofocus` | boolean | — | false |
2017-08-23 10:07:14 +00:00
| native-type | same as native button's `type` | string | button / submit / reset | button |