Button 按钮
用于触发操作的交互式按钮组件,支持多种样式变体、扁平样式与禁用状态。
基本用法
下面依次展示标准按钮、禁用按钮、扁平(flat)按钮与禁用的扁平按钮:
事件与动态标签
@click 监听点击,:label 动态绑定按钮文字:
Props
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
label | str | "" | 按钮显示文字;也可通过默认 slot 内容设置 |
variant | str | "default" | 样式变体:"default" | "primary" | "success" | "warning" | "error" |
disabled | bool | False | 是否禁用按钮(无需传值,存在即为 True) |
flat | bool | False | 是否使用扁平样式,去掉按钮的立体边框(无需传值,存在即为 True) |
compact | bool | False | 是否使用紧凑样式(无需传值,存在即为 True) |
v-model
v-model 默认绑定属性:label
vue
<Button v-model="btn_label.value" />Slot
Button 支持 default slot,slot 内容会作为按钮的 label:
vue
<Button @click="on_click()">确认提交</Button>事件
| 事件 | 说明 |
|---|---|
click | 按钮被点击时触发(对应 Textual Button.Pressed) |
通用属性
所有 Textual-vuepy 组件均支持以下属性:
| 属性 | 类型 | 说明 |
|---|---|---|
id | str | 组件 CSS ID |
style | str | TCSS 内联样式 |
class | str | TCSS 类名(空格分隔) |
border_title | str | 边框标题 |
border_subtitle | str | 边框副标题 |