按钮
用途
Add your button HTML
Add class="btn" to a <button> or <a>. Add data-variant and data-size when needed. Add data-icon="inline-start" or data-icon="inline-end" to inline icons when a text button needs icon-aware spacing.
HTML 结构
<button class="btn">- Button root. Use a native
<button>for actions and<a>for navigation. data-variant="primary|secondary|outline|ghost|link|destructive"Optional- Visual variant. Omit it for the primary variant.
data-size="xs|sm|default|lg|icon|icon-xs|icon-sm|icon-lg"Optional- Button size. Omit it for the default size.
变体
尺寸
使用 data-size="icon" 或方形按钮的图标大小变体之一。仅图标按钮需要一个可访问的名称,通常为 aria-label。
当文本按钮需要图标感知间距时,在内联图标上使用 data-icon="inline-start" 或 data-icon="inline-end"。仅对纯图标按钮使用图标大小变体。
要对相关按钮进行分组,请使用Button Group组件。
示例
尺寸
使用data-size更改按钮的大小。
默认
概要
次要
幽灵
破坏性
链接
图标
带图标
在内联图标上使用 data-icon="inline-start" 或 data-icon="inline-end" 以匹配上游图标感知间距。
圆形
使用 rounded-full 类使按钮变圆。
旋转器
按钮组
要对相关按钮进行分组,请使用Button Group组件。
RTL
将 dir="rtl" 添加到按钮或祖先。明确翻转方向图标。