Button
Commonly used button.
Basic usage
Use type
, plain
, round
and circle
to define Button's style.
<!-- @format -->
<template>
<div class="mb-4">
<el-button-pro>Default</el-button-pro>
<el-button-pro type="primary" class="el-button-pro--3d" size="large"
>Primary</el-button-pro
>
<el-button-pro type="primary" class="el-button-pro--3d"
>Primary</el-button-pro
>
<el-button-pro type="primary" class="el-button-pro--3d" size="small"
>Primary</el-button-pro
>
<el-button-pro type="success">Success</el-button-pro>
<el-button-pro type="info">Info</el-button-pro>
<el-button-pro type="warning">Warning</el-button-pro>
<el-button-pro type="danger">Danger</el-button-pro>
</div>
<div class="mb-4">
<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 class="mb-4">
<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>
<div>
<el-button :icon="Search" circle />
<el-button type="primary" :icon="Edit" circle />
<el-button type="success" :icon="Check" circle />
<el-button type="info" :icon="Message" circle />
<el-button type="warning" :icon="Star" circle />
<el-button type="danger" :icon="Delete" circle />
</div>
</template>
<script lang="ts" setup>
import {
Check,
Delete,
Edit,
Message,
Search,
Star,
} from '@element-plus/icons-vue'
</script>
style-3d-neonDisabled Button
The disabled
attribute determines if the button is disabled.
Use disabled
attribute to determine whether a button is disabled. It accepts a Boolean
value.
<!-- @format -->
<template>
<div class="demo-button-pro">
<div class="section-title">3D按钮 - 具有立体感的按钮</div>
<div class="button-row">
<el-button-pro type="primary" class="el-button-pro--3d"
>3D按钮</el-button-pro
>
<el-button-pro type="success" class="el-button-pro--3d"
>3D按钮</el-button-pro
>
<el-button-pro type="warning" class="el-button-pro--3d"
>3D按钮</el-button-pro
>
<el-button-pro type="danger" class="el-button-pro--3d"
>3D按钮</el-button-pro
>
<el-button-pro type="info" class="el-button-pro--3d"
>3D按钮</el-button-pro
>
</div>
<div class="section-title">霓虹灯按钮 - 发光边框效果</div>
<div class="button-row dark-bg">
<el-button-pro type="primary" class="el-button-pro--neon"
>霓虹灯按钮</el-button-pro
>
<el-button-pro type="success" class="el-button-pro--neon"
>霓虹灯按钮</el-button-pro
>
<el-button-pro type="warning" class="el-button-pro--neon"
>霓虹灯按钮</el-button-pro
>
<el-button-pro type="danger" class="el-button-pro--neon"
>霓虹灯按钮</el-button-pro
>
<el-button-pro type="info" class="el-button-pro--neon"
>霓虹灯按钮</el-button-pro
>
</div>
</div>
</template>
<style scoped>
.demo-button-pro {
padding: 20px;
}
.section-title {
margin: 20px 0 10px;
font-weight: bold;
font-size: 16px;
color: #333;
}
.button-row {
margin-bottom: 20px;
display: flex;
flex-wrap: wrap;
gap: 15px;
}
.dark-bg {
background-color: #222;
padding: 20px;
border-radius: 8px;
}
</style>
style-3d-neonDisabled Button
The disabled
attribute determines if the button is disabled.
Use disabled
attribute to determine whether a button is disabled. It accepts a Boolean
value.
<!-- @format -->
<template>
<div class="demo-button-pro">
<div class="section-title">所有按钮样式综合展示</div>
<div class="style-section">
<div class="style-title">3D 按钮</div>
<div class="button-row">
<el-button-pro type="primary" class="el-button-pro--3d"
>3D按钮</el-button-pro
>
<el-button-pro type="success" class="el-button-pro--3d"
>3D按钮</el-button-pro
>
<el-button-pro type="warning" class="el-button-pro--3d"
>3D按钮</el-button-pro
>
<el-button-pro type="danger" class="el-button-pro--3d"
>3D按钮</el-button-pro
>
<el-button-pro type="info" class="el-button-pro--3d"
>3D按钮</el-button-pro
>
</div>
</div>
<div class="style-section">
<div class="style-title">霓虹灯按钮</div>
<div class="button-row">
<el-button-pro type="primary" class="el-button-pro--neon"
>霓虹灯</el-button-pro
>
<el-button-pro type="success" class="el-button-pro--neon"
>霓虹灯</el-button-pro
>
<el-button-pro type="warning" class="el-button-pro--neon"
>霓虹灯</el-button-pro
>
<el-button-pro type="danger" class="el-button-pro--neon"
>霓虹灯</el-button-pro
>
<el-button-pro type="info" class="el-button-pro--neon"
>霓虹灯</el-button-pro
>
</div>
</div>
<div class="style-section">
<div class="style-title">渐变按钮</div>
<div class="button-row">
<el-button-pro type="primary" class="el-button-pro--gradient"
>渐变按钮</el-button-pro
>
<el-button-pro type="success" class="el-button-pro--gradient"
>渐变按钮</el-button-pro
>
<el-button-pro type="warning" class="el-button-pro--gradient"
>渐变按钮</el-button-pro
>
<el-button-pro type="danger" class="el-button-pro--gradient"
>渐变按钮</el-button-pro
>
<el-button-pro type="info" class="el-button-pro--gradient"
>渐变按钮</el-button-pro
>
</div>
</div>
<div class="style-section">
<div class="style-title">涟漪按钮</div>
<div class="button-row">
<el-button-pro type="primary" class="el-button-pro--ripple"
>涟漪按钮</el-button-pro
>
<el-button-pro type="success" class="el-button-pro--ripple"
>涟漪按钮</el-button-pro
>
<el-button-pro type="warning" class="el-button-pro--ripple"
>涟漪按钮</el-button-pro
>
<el-button-pro type="danger" class="el-button-pro--ripple"
>涟漪按钮</el-button-pro
>
<el-button-pro type="info" class="el-button-pro--ripple"
>涟漪按钮</el-button-pro
>
</div>
</div>
<div class="style-section">
<div class="style-title">边框动画按钮</div>
<div class="button-row">
<el-button-pro type="primary" class="el-button-pro--border-animation"
>边框动画</el-button-pro
>
<el-button-pro type="success" class="el-button-pro--border-animation"
>边框动画</el-button-pro
>
<el-button-pro type="warning" class="el-button-pro--border-animation"
>边框动画</el-button-pro
>
<el-button-pro type="danger" class="el-button-pro--border-animation"
>边框动画</el-button-pro
>
<el-button-pro type="info" class="el-button-pro--border-animation"
>边框动画</el-button-pro
>
</div>
</div>
<div class="style-section">
<div class="style-title">脉冲按钮</div>
<div class="button-row">
<el-button-pro type="primary" class="el-button-pro--pulse"
>脉冲按钮</el-button-pro
>
<el-button-pro type="success" class="el-button-pro--pulse"
>脉冲按钮</el-button-pro
>
<el-button-pro type="warning" class="el-button-pro--pulse"
>脉冲按钮</el-button-pro
>
<el-button-pro type="danger" class="el-button-pro--pulse"
>脉冲按钮</el-button-pro
>
<el-button-pro type="info" class="el-button-pro--pulse"
>脉冲按钮</el-button-pro
>
</div>
</div>
<div class="style-section">
<div class="style-title">悬浮按钮</div>
<div class="button-row">
<el-button-pro type="primary" class="el-button-pro--float"
>悬浮按钮</el-button-pro
>
<el-button-pro type="success" class="el-button-pro--float"
>悬浮按钮</el-button-pro
>
<el-button-pro type="warning" class="el-button-pro--float"
>悬浮按钮</el-button-pro
>
<el-button-pro type="danger" class="el-button-pro--float"
>悬浮按钮</el-button-pro
>
<el-button-pro type="info" class="el-button-pro--float"
>悬浮按钮</el-button-pro
>
</div>
</div>
<div class="style-section">
<div class="style-title">光泽按钮</div>
<div class="button-row">
<el-button-pro type="primary" class="el-button-pro--shine"
>光泽按钮</el-button-pro
>
<el-button-pro type="success" class="el-button-pro--shine"
>光泽按钮</el-button-pro
>
<el-button-pro type="warning" class="el-button-pro--shine"
>光泽按钮</el-button-pro
>
<el-button-pro type="danger" class="el-button-pro--shine"
>光泽按钮</el-button-pro
>
<el-button-pro type="info" class="el-button-pro--shine"
>光泽按钮</el-button-pro
>
</div>
</div>
<div class="style-section">
<div class="style-title">轮廓按钮</div>
<div class="button-row">
<el-button-pro type="primary" class="el-button-pro--outline"
>轮廓按钮</el-button-pro
>
<el-button-pro type="success" class="el-button-pro--outline"
>轮廓按钮</el-button-pro
>
<el-button-pro type="warning" class="el-button-pro--outline"
>轮廓按钮</el-button-pro
>
<el-button-pro type="danger" class="el-button-pro--outline"
>轮廓按钮</el-button-pro
>
<el-button-pro type="info" class="el-button-pro--outline"
>轮廓按钮</el-button-pro
>
</div>
</div>
<div class="style-section">
<div class="style-title">展开按钮</div>
<div class="button-row">
<el-button-pro type="primary" class="el-button-pro--expand"
>展开按钮</el-button-pro
>
<el-button-pro type="success" class="el-button-pro--expand"
>展开按钮</el-button-pro
>
<el-button-pro type="warning" class="el-button-pro--expand"
>展开按钮</el-button-pro
>
<el-button-pro type="danger" class="el-button-pro--expand"
>展开按钮</el-button-pro
>
<el-button-pro type="info" class="el-button-pro--expand"
>展开按钮</el-button-pro
>
</div>
</div>
<div class="style-section">
<div class="style-title">抖动按钮</div>
<div class="button-row">
<el-button-pro type="primary" class="el-button-pro--shake"
>抖动按钮</el-button-pro
>
<el-button-pro type="success" class="el-button-pro--shake"
>抖动按钮</el-button-pro
>
<el-button-pro type="warning" class="el-button-pro--shake"
>抖动按钮</el-button-pro
>
<el-button-pro type="danger" class="el-button-pro--shake"
>抖动按钮</el-button-pro
>
<el-button-pro type="info" class="el-button-pro--shake"
>抖动按钮</el-button-pro
>
</div>
</div>
<div class="style-section">
<div class="style-title">旋转图标按钮</div>
<div class="button-row">
<el-button-pro
type="primary"
class="el-button-pro--rotate-icon"
:icon="Refresh"
>旋转图标</el-button-pro
>
<el-button-pro
type="success"
class="el-button-pro--rotate-icon"
:icon="Refresh"
>旋转图标</el-button-pro
>
<el-button-pro
type="warning"
class="el-button-pro--rotate-icon"
:icon="Refresh"
>旋转图标</el-button-pro
>
<el-button-pro
type="danger"
class="el-button-pro--rotate-icon"
:icon="Refresh"
>旋转图标</el-button-pro
>
<el-button-pro
type="info"
class="el-button-pro--rotate-icon"
:icon="Refresh"
>旋转图标</el-button-pro
>
</div>
</div>
<div class="style-section">
<div class="style-title">弹跳按钮</div>
<div class="button-row">
<el-button-pro type="primary" class="el-button-pro--bounce"
>弹跳按钮</el-button-pro
>
<el-button-pro type="success" class="el-button-pro--bounce"
>弹跳按钮</el-button-pro
>
<el-button-pro type="warning" class="el-button-pro--bounce"
>弹跳按钮</el-button-pro
>
<el-button-pro type="danger" class="el-button-pro--bounce"
>弹跳按钮</el-button-pro
>
<el-button-pro type="info" class="el-button-pro--bounce"
>弹跳按钮</el-button-pro
>
</div>
</div>
<div class="style-section">
<div class="style-title">折叠按钮</div>
<div class="button-row">
<el-button-pro type="primary" class="el-button-pro--fold"
>折叠按钮</el-button-pro
>
<el-button-pro type="success" class="el-button-pro--fold"
>折叠按钮</el-button-pro
>
<el-button-pro type="warning" class="el-button-pro--fold"
>折叠按钮</el-button-pro
>
<el-button-pro type="danger" class="el-button-pro--fold"
>折叠按钮</el-button-pro
>
<el-button-pro type="info" class="el-button-pro--fold"
>折叠按钮</el-button-pro
>
</div>
</div>
<div class="style-section">
<div class="style-title">滑动按钮</div>
<div class="button-row">
<el-button-pro type="primary" class="el-button-pro--slide"
>滑动按钮</el-button-pro
>
<el-button-pro type="success" class="el-button-pro--slide"
>滑动按钮</el-button-pro
>
<el-button-pro type="warning" class="el-button-pro--slide"
>滑动按钮</el-button-pro
>
<el-button-pro type="danger" class="el-button-pro--slide"
>滑动按钮</el-button-pro
>
<el-button-pro type="info" class="el-button-pro--slide"
>滑动按钮</el-button-pro
>
</div>
</div>
<div class="style-section">
<div class="style-title">气泡按钮</div>
<div class="button-row">
<el-button-pro type="primary" class="el-button-pro--bubble"
>气泡按钮</el-button-pro
>
<el-button-pro type="success" class="el-button-pro--bubble"
>气泡按钮</el-button-pro
>
<el-button-pro type="warning" class="el-button-pro--bubble"
>气泡按钮</el-button-pro
>
<el-button-pro type="danger" class="el-button-pro--bubble"
>气泡按钮</el-button-pro
>
<el-button-pro type="info" class="el-button-pro--bubble"
>气泡按钮</el-button-pro
>
</div>
</div>
<div class="style-section">
<div class="style-title">闪烁按钮</div>
<div class="button-row">
<el-button-pro type="primary" class="el-button-pro--blink"
>闪烁按钮</el-button-pro
>
<el-button-pro type="success" class="el-button-pro--blink"
>闪烁按钮</el-button-pro
>
<el-button-pro type="warning" class="el-button-pro--blink"
>闪烁按钮</el-button-pro
>
<el-button-pro type="danger" class="el-button-pro--blink"
>闪烁按钮</el-button-pro
>
<el-button-pro type="info" class="el-button-pro--blink"
>闪烁按钮</el-button-pro
>
</div>
</div>
<div class="style-section">
<div class="style-title">翻转按钮</div>
<div class="button-row">
<el-button-pro type="primary" class="el-button-pro--flip"
>翻转按钮</el-button-pro
>
<el-button-pro type="success" class="el-button-pro--flip"
>翻转按钮</el-button-pro
>
<el-button-pro type="warning" class="el-button-pro--flip"
>翻转按钮</el-button-pro
>
<el-button-pro type="danger" class="el-button-pro--flip"
>翻转按钮</el-button-pro
>
<el-button-pro type="info" class="el-button-pro--flip"
>翻转按钮</el-button-pro
>
</div>
</div>
<div class="style-section">
<div class="style-title">阴影按钮</div>
<div class="button-row">
<el-button-pro type="primary" class="el-button-pro--shadow"
>阴影按钮</el-button-pro
>
<el-button-pro type="success" class="el-button-pro--shadow"
>阴影按钮</el-button-pro
>
<el-button-pro type="warning" class="el-button-pro--shadow"
>阴影按钮</el-button-pro
>
<el-button-pro type="danger" class="el-button-pro--shadow"
>阴影按钮</el-button-pro
>
<el-button-pro type="info" class="el-button-pro--shadow"
>阴影按钮</el-button-pro
>
</div>
</div>
<div class="style-section">
<div class="style-title">缩放按钮</div>
<div class="button-row">
<el-button-pro type="primary" class="el-button-pro--scale"
>缩放按钮</el-button-pro
>
<el-button-pro type="success" class="el-button-pro--scale"
>缩放按钮</el-button-pro
>
<el-button-pro type="warning" class="el-button-pro--scale"
>缩放按钮</el-button-pro
>
<el-button-pro type="danger" class="el-button-pro--scale"
>缩放按钮</el-button-pro
>
<el-button-pro type="info" class="el-button-pro--scale"
>缩放按钮</el-button-pro
>
</div>
</div>
<div class="style-section">
<div class="style-title">hover背景透明到颜色</div>
<div class="button-row">
<el-button-pro type="primary" class="el-button-pro--hover-bg-write"
>hover背景透明到颜色</el-button-pro
>
<el-button-pro type="success" class="el-button-pro--hover-bg-write"
>hover背景透明到颜色</el-button-pro
>
<el-button-pro type="warning" class="el-button-pro--hover-bg-write"
>hover背景透明到颜色</el-button-pro
>
<el-button-pro type="danger" class="el-button-pro--hover-bg-write"
>hover背景透明到颜色</el-button-pro
>
<el-button-pro type="info" class="el-button-pro--hover-bg-write"
>hover背景透明到颜色</el-button-pro
>
</div>
</div>
<div class="style-section">
<div class="style-title">
hover背景颜色到透明
<div class="button-row">
<el-button-pro type="primary" class="el-button-pro--hover-bg-color"
>hover背景颜色到透明</el-button-pro
>
<el-button-pro type="success" class="el-button-pro--hover-bg-color"
>hover背景颜色到透明</el-button-pro
>
<el-button-pro type="warning" class="el-button-pro--hover-bg-color"
>hover背景颜色到透明</el-button-pro
>
<el-button-pro type="danger" class="el-button-pro--hover-bg-color"
>hover背景颜色到透明</el-button-pro
>
<el-button-pro type="info" class="el-button-pro--hover-bg-color"
>hover背景颜色到透明</el-button-pro
>
</div>
</div>
</div>
</div>
</template>
<script lang="ts" setup>
import {
Check,
Delete,
Message,
Refresh,
Search,
Star,
} from '@element-plus/icons-vue'
</script>
<style scoped>
.demo-button-pro {
padding: 20px;
}
.section-title {
margin: 20px 0 10px;
font-weight: bold;
font-size: 18px;
color: #333;
text-align: center;
}
.style-section {
margin-bottom: 30px;
padding: 15px;
border: 1px solid #eee;
border-radius: 8px;
}
.style-title {
margin: 0 0 15px;
font-weight: bold;
font-size: 16px;
color: #333;
border-bottom: 1px dashed #ddd;
padding-bottom: 8px;
}
.button-row {
display: flex;
flex-wrap: wrap;
gap: 15px;
}
</style>
Link Button
WARNING
type="text"
has been deprecated, and will be removed in 3.0.0, consider switching to new API.
New API link
has been added in 2.2.1, you can use type
API to set the theme of your link button
<template>
<p>Basic link button</p>
<div class="mb-4">
<el-button
v-for="button in buttons"
:key="button.text"
:type="button.type"
link
>
{{ button.text }}
</el-button>
</div>
<p>Disabled link button</p>
<div>
<el-button
v-for="button in buttons"
:key="button.text"
:type="button.type"
link
disabled
>
{{ button.text }}
</el-button>
</div>
</template>
<script setup lang="ts">
const buttons = [
{ type: '', text: 'plain' },
{ type: 'primary', text: 'primary' },
{ type: 'success', text: 'success' },
{ type: 'info', text: 'info' },
{ type: 'warning', text: 'warning' },
{ type: 'danger', text: 'danger' },
] as const
</script>
Text Button
TIP
Text button has been upgraded with a new design since 2.2.0 , if you want to use the previous version like button, you might want to check Link out.
The API is also updated, because the type
attribute also represents the button's style. So we have to make a new API text: boolean
for text button.
Buttons without border and background.
<template>
<p>Basic text button</p>
<div class="mb-4">
<el-button
v-for="button in buttons"
:key="button.text"
:type="button.type"
text
>
{{ button.text }}
</el-button>
</div>
<p>Background color always on</p>
<div class="mb-4">
<el-button
v-for="button in buttons"
:key="button.text"
:type="button.type"
text
bg
>
{{ button.text }}
</el-button>
</div>
<p>Disabled text button</p>
<div>
<el-button
v-for="button in buttons"
:key="button.text"
:type="button.type"
text
disabled
>
{{ button.text }}
</el-button>
</div>
</template>
<script setup lang="ts">
const buttons = [
{ type: '', text: 'plain' },
{ type: 'primary', text: 'primary' },
{ type: 'success', text: 'success' },
{ type: 'info', text: 'info' },
{ type: 'warning', text: 'warning' },
{ type: 'danger', text: 'danger' },
] as const
</script>
Icon Button
Use icons to add more meaning to Button. You can use icon alone to save some space, or use it with text.
Use the icon
attribute to add icon. You can find the icon list in Element Plus icon component. Adding icons to the right side of the text is achievable with an <i>
tag. Custom icons can be used as well.
<template>
<div>
<el-button type="primary" :icon="Edit" />
<el-button type="primary" :icon="Share" />
<el-button type="primary" :icon="Delete" />
<el-button type="primary" :icon="Search">Search</el-button>
<el-button type="primary">
Upload<el-icon class="el-icon--right"><Upload /></el-icon>
</el-button>
</div>
</template>
<script setup lang="ts">
import { Delete, Edit, Search, Share, Upload } from '@element-plus/icons-vue'
</script>
Button Group
Displayed as a button group, can be used to group a series of similar operations.
Use tag <el-button-group>
to group your buttons.
<template>
<el-button-group>
<el-button type="primary" :icon="ArrowLeft">Previous Page</el-button>
<el-button type="primary">
Next Page<el-icon class="el-icon--right"><ArrowRight /></el-icon>
</el-button>
</el-button-group>
<el-button-group class="ml-4">
<el-button type="primary" :icon="Edit" />
<el-button type="primary" :icon="Share" />
<el-button type="primary" :icon="Delete" />
</el-button-group>
</template>
<script setup lang="ts">
import {
ArrowLeft,
ArrowRight,
Delete,
Edit,
Share,
} from '@element-plus/icons-vue'
</script>
Loading Button
Click the button to load data, then the button displays a loading state.
Set loading
attribute to true
to display loading state.
TIP
You can use the loading
slot or loadingIcon
to customize your loading component
ps: loading
slot has higher priority than loadingIcon
<template>
<el-button type="primary" loading>Loading</el-button>
<el-button type="primary" :loading-icon="Eleme" loading>Loading</el-button>
<el-button type="primary" loading>
<template #loading>
<div class="custom-loading">
<svg class="circular" viewBox="-10, -10, 50, 50">
<path
class="path"
d="
M 30 15
L 28 17
M 25.61 25.61
A 15 15, 0, 0, 1, 15 30
A 15 15, 0, 1, 1, 27.99 7.5
L 15 15
"
style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"
/>
</svg>
</div>
</template>
Loading
</el-button>
</template>
<script lang="ts" setup>
import { Eleme } from '@element-plus/icons-vue'
</script>
<style scoped>
.el-button .custom-loading .circular {
margin-right: 6px;
width: 18px;
height: 18px;
animation: loading-rotate 2s linear infinite;
}
.el-button .custom-loading .circular .path {
animation: loading-dash 1.5s ease-in-out infinite;
stroke-dasharray: 90, 150;
stroke-dashoffset: 0;
stroke-width: 2;
stroke: var(--el-button-text-color);
stroke-linecap: round;
}
</style>
Sizes
Besides default size, Button component provides three additional sizes for you to choose among different scenarios.
Use attribute size
to set additional sizes with large
, small
.
<template>
<div class="flex flex-wrap items-center mb-4">
<el-button size="large">Large</el-button>
<el-button>Default</el-button>
<el-button size="small">Small</el-button>
<el-button size="large" :icon="Search">Search</el-button>
<el-button :icon="Search">Search</el-button>
<el-button size="small" :icon="Search">Search</el-button>
</div>
<div class="flex flex-wrap items-center mb-4">
<el-button size="large" round>Large</el-button>
<el-button round>Default</el-button>
<el-button size="small" round>Small</el-button>
<el-button size="large" :icon="Search" round>Search</el-button>
<el-button :icon="Search" round>Search</el-button>
<el-button size="small" :icon="Search" round>Search</el-button>
</div>
<div class="flex flex-wrap items-center">
<el-button :icon="Search" size="large" circle />
<el-button :icon="Search" circle />
<el-button :icon="Search" size="small" circle />
</div>
</template>
<script setup lang="ts">
import { Search } from '@element-plus/icons-vue'
</script>
Tag 2.3.4
You can custom element tag, For example button, div, a, router-link, nuxt-link.
<template>
<el-button>button</el-button>
<el-button tag="div" role="button" tabindex="0">div</el-button>
<el-button
type="primary"
tag="a"
href="https://github.com/element-plus/element-plus"
target="_blank"
rel="noopener noreferrer"
>
a
</el-button>
</template>
Custom Color beta
You can custom button color.
We will calculate hover color & active color automatically.
<script lang="ts" setup>
import { isDark } from '~/composables/dark'
</script>
<template>
<div>
<el-button color="#626aef" :dark="isDark">Default</el-button>
<el-button color="#626aef" :dark="isDark" plain>Plain</el-button>
<el-button color="#626aef" :dark="isDark" disabled>Disabled</el-button>
<el-button color="#626aef" :dark="isDark" disabled plain>
Disabled Plain
</el-button>
</div>
</template>
Button API
Button Attributes
Name | Description | Type | Default | |||||
---|---|---|---|---|---|---|---|---|
size | button size | enum `'large' | 'default' | 'small'` | — | |||
type | button type | enum `'primary' | 'success' | 'warning' | 'danger' | 'info' | 'text' (deprecated)` | — |
plain | determine whether it's a plain button | boolean | false | |||||
text 2.2.0 | determine whether it's a text button | boolean | false | |||||
bg 2.2.0 | determine whether the text button background color is always on | boolean | false | |||||
link 2.2.1 | determine whether it's a link button | boolean | false | |||||
round | determine whether it's a round button | boolean | false | |||||
circle | determine whether it's a circle button | boolean | false | |||||
loading | determine whether it's loading | boolean | false | |||||
loading-icon | customize loading icon component | string / Component | Loading | |||||
disabled | disable the button | boolean | false | |||||
icon | icon component | string / Component | — | |||||
autofocus | same as native button'sautofocus | boolean | false | |||||
native-type | same as native button'stype | enum `'button' | 'submit' | 'reset'` | button | |||
auto-insert-space | automatically insert a space between two chinese characters | boolean | — | |||||
color | custom button color, automatically calculatehover and active color | string | — | |||||
dark | dark mode, which automatically convertscolor to dark mode colors | boolean | false | |||||
tag 2.3.4 | custom element tag | string / Component | button |
Button Slots
Name | Description |
---|---|
default | customize default content |
loading | customize loading component |
icon | customize icon component |
Button Exposes
Name | Description | Type | |||||||
---|---|---|---|---|---|---|---|---|---|
ref | button html element | object | |||||||
size | button size | object `ComputedRef<'' | 'small' | 'default' | 'large'>` | ||||
type | button type | object `ComputedRef<'' | 'default' | 'primary' | 'success' | 'warning' | 'info' | 'danger' | 'text'>` |
disabled | button disabled | object | |||||||
shouldAddSpace | whether adding space | object |
ButtonGroup API
ButtonGroup Attributes
Name | Description | Type | Default | ||||
---|---|---|---|---|---|---|---|
size | control the size of buttons in this button-group | enum `'large' | 'default' | 'small'` | — | ||
type | control the type of buttons in this button-group | enum `'primary' | 'success' | 'warning' | 'danger' | 'info'` | — |
ButtonGroup Slots
Name | Description | Subtags |
---|---|---|
default | customize button group content | Button |