直接跳到内容

ButtonIcon 图标按钮

此小部件最初显示一个默认 icon 。点击后,会在指定的 toggle_duration 时间内显示 active_icon

例如,可以有效利用 ButtonIcon 来实现类似于 ChatGPT 的复制到剪贴板按钮的功能。

底层实现为panel.widgets.ButtonIcon,参数基本一致,参考文档:https://panel.holoviz.org/reference/widgets/ButtonIcon.html

基本用法

基本的图标按钮使用:tabler-icons.io 图标

使用SVG图标

可以使用SVG字符串作为图标:

自定义 css style

通过style设置组件外层DOM节点(意味着无法设置某些组件内的样式,如background-color,font-size等)的CSS样式:

  • widthheight 设置组件的高和宽
  • border 设置组件的边框
  • size 设置大小
  • ...

API

属性

属性名说明类型默认值
icon正常显示的图标(tabler-icons.io图标名称或SVG字符串)str None
active_icon切换时显示的图标(tabler-icons.io图标名称或SVG字符串)str None
clicks图标被点击的次数int 0
toggle_durationactive_icon显示的毫秒数及按钮禁用时间int -
value处理事件时从False切换到Truebool False
name小部件的标题str ""
description悬停时显示的描述str ""
disabled是否可编辑bool False
size大小(支持css font-size格式如1em, 20px等)str -

Events

事件名说明类型
click当按钮被点击时触发的事件Callable 

Slots

插槽名说明
default按钮文字
iconsvg 图标

Controls

src/examples/panel_vuepy/widgets/ButtonIcon

ButtonIcon 图标按钮已经加载完毕