2017-11-06 11:22:02 +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;
2017-12-03 10:03:06 +00:00
2017-11-06 11:22:02 +00:00
.el-button + .el-button {
margin-left: 0;
}
2017-12-03 10:03:06 +00:00
2017-11-06 11:22:02 +00:00
& + .el-button-group {
margin-left: 10px;
}
}
}
< / style >
## Button
2017-11-08 06:22:06 +00:00
Botones comúnmente usados.
2017-11-06 11:22:02 +00:00
2017-11-08 06:22:06 +00:00
### Uso básico
2017-11-06 11:22:02 +00:00
2017-12-12 04:45:09 +00:00
:::demo Use `type` , `plain` y `round` para definir estilos a los botones.
2017-11-06 11:22:02 +00:00
```html
< 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 >
```
:::
2017-11-08 06:22:06 +00:00
### Botón deshabilitado
2017-11-06 11:22:02 +00:00
2017-11-08 06:22:06 +00:00
El atributo `disabled` determina su un botón esta deshabilitado.
2017-11-06 11:22:02 +00:00
2017-11-08 06:22:06 +00:00
:::demo Use el atributo `disabled` para determinar si un botón esta deshabilitado. Acepta un valor `Boolean` .
2017-11-06 11:22:02 +00:00
```html
< 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 >
```
:::
2017-11-08 06:22:06 +00:00
### Botón de texto
2017-11-06 11:22:02 +00:00
2017-11-08 06:22:06 +00:00
Botones sin borde ni fondo.
2017-11-06 11:22:02 +00:00
:::demo
```html
< el-button type = "text" > Text Button< / el-button >
< el-button type = "text" disabled > Text Button< / el-button >
```
:::
2017-11-08 06:22:06 +00:00
### Botón icono
2017-11-06 11:22:02 +00:00
2017-11-08 06:22:06 +00:00
Use iconos para darle mayor significado a Button. Se puede usar simplemente un icono o un icono con texto.
2017-11-06 11:22:02 +00:00
2017-11-08 06:22:06 +00:00
:::demo Use el atributo `icon` para agregar un icono. Puede encontrar el listado de iconos en el componente de iconos. Agregar iconos a la derecha del texto se puede conseguir con un tag `<i>` . También se pueden usar iconos custom.
2017-11-06 11:22:02 +00:00
```html
< el-button type = "primary" icon = "el-icon-edit" > < / el-button >
< el-button type = "primary" icon = "el-icon-share" > < / el-button >
< el-button type = "primary" icon = "el-icon-delete" > < / el-button >
< el-button type = "primary" icon = "el-icon-search" > Search< / el-button >
< el-button type = "primary" > Upload< i class = "el-icon-upload el-icon-right" > < / i > < / el-button >
```
:::
2017-11-08 06:22:06 +00:00
### Grupo de botones
2017-11-06 11:22:02 +00:00
2017-11-08 06:22:06 +00:00
Mostrar un grupo de botones puede ser usado para mostrar un grupo de operaciones similares.
2017-11-06 11:22:02 +00:00
2017-11-08 06:22:06 +00:00
:::demo Use el tag `<el-button-group>` para agrupar sus botones.
2017-11-06 11:22:02 +00:00
```html
< el-button-group >
< el-button type = "primary" icon = "el-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 = "el-icon-edit" > < / el-button >
< el-button type = "primary" icon = "el-icon-share" > < / el-button >
< el-button type = "primary" icon = "el-icon-delete" > < / el-button >
< / el-button-group >
```
:::
2017-11-08 06:22:06 +00:00
### Botón de descarga
2017-11-06 11:22:02 +00:00
2017-11-08 06:22:06 +00:00
Cuando se hace clic en un botón para descargar datos, el botón muestra un estado de descarga.
2017-11-06 11:22:02 +00:00
2017-12-03 10:03:06 +00:00
:::demo Ajuste el atributo `loading` a `true` para mostrar el estado de descarga.
2017-11-06 11:22:02 +00:00
```html
< el-button type = "primary" :loading = "true" > Loading< / el-button >
```
:::
2017-11-08 06:22:06 +00:00
### Tamaños
2017-11-06 11:22:02 +00:00
2017-11-08 06:22:06 +00:00
Además del tamaño por defecto, el componente Button provee tres tamaños adicionales para utilizar en diferentes escenarios.
2017-11-06 11:22:02 +00:00
2017-11-08 06:22:06 +00:00
:::demo Use el atributo `size` para setear tamaños adicionales con `medium` , `small` or `mini` .
2017-11-06 11:22:02 +00:00
```html
< 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 >
```
:::
2017-11-08 06:22:06 +00:00
### Atributos
2017-12-03 10:03:06 +00:00
| Atributo | Descripción | Tipo | Valores aceptados | Por defecto |
| ----------- | ---------------------------------------- | ------- | ---------------------------------------- | ----------- |
| size | tamaño del botón | string | medium / small / mini | — |
| type | tipo de botón | string | primary / success / warning / danger / info / text | — |
| plain | determinar si es o no un botón plano | boolean | — | false |
| round | determinar si es o no un botón redondo | boolean | — | false |
| loading | determinar si es o no un botón de descarga | boolean | — | false |
| disabled | deshabilitar el botón | boolean | — | false |
| icon | nombre de la clase del icono | string | — | — |
| autofocus | misma funcionalidad que la nativa `autofocus` | boolean | — | false |
| native-type | misma funcionalidad que la nativa `type` | string | button / submit / reset | button |