#header-mark#
Button 按钮
常用的操作按钮。
按钮组件可以在被点击时触发事件。除了在处理点击事件期间会从False
切换到True
的value
参数外,还有一个额外的clicks
参数,可以被监听以订阅点击事件。
底层实现为panel.widgets.Button
,参数基本一致,参考文档:https://panel.holoviz.org/reference/widgets/Button.html
基本用法
基本的按钮使用,点击时触发事件:
按钮样式
按钮的颜色可以通过设置button_type
来改变,而button_style
可以是'solid'
或'outline'
:
图标按钮
Button 组件可以添加图标,支持 Unicode、Emoji 字符,以及 tabler-icons.io 的命名图标或自定义 SVG:
加载状态按钮
通过设置 loading 属性为 true 来显示加载中状态。
自定义 css style
通过style
设置组件外层DOM节点(意味着无法设置某些组件内的样式,如background-color,font-size等)的CSS样式:
width
、height
设置组件的高和宽border
设置组件的边框- ...
API
属性
属性名 | 说明 | 类型 | 默认值 |
---|---|---|---|
button_style | 按钮样式 | str | 'solid' |
button_type | 按钮主题 | str | 'default' |
clicks | 点击次数 | int | 0 |
disabled | 是否禁用 | bool | False |
icon | 按钮图标(SVG字符串或tabler-icons.io图标名称) | str | None |
icon_size | 图标大小(如"12px"或"1em") | str | None |
name | 按钮标题/文本 | str | "" |
value | 按钮值,处理点击事件时切换 | bool | False |
description | 鼠标悬停时显示的描述 | str | "" |
Events
事件名 | 说明 | 类型 |
---|---|---|
click | 当按钮被点击时触发的事件 | Callable |
Slots
插槽名 | 说明 |
---|---|
default | 按钮文字 |
icon | svg 图标 |
Controls
src/examples/panel_vuepy/widgets/Button