Skip to content

Icon Button 图标按钮 ​

承载单个图标的方形按钮,带无障碍标签。pressed 可将其变为工具切换钮。

示例 ​

基础用法 ​

moonbit
@sumi.icon_button(@sumi.icon_download(), aria_label="Download")
@sumi.icon_button(@sumi.icon_crop(), pressed=true, aria_label="Crop (active tool)")
@sumi.icon_button(@sumi.icon_x(), size=@sumi.IconSm, aria_label="Close")
@sumi.icon_button(@sumi.icon_upload(), disabled=true, aria_label="Export")

API ​

icon_button ​

名称类型默认值说明
iconHtml—
variantButtonVariantGhost视觉风格
sizeButtonSizeIconIcon 32×32 或 IconSm 28×28
disabledBoolfalse禁用交互并降低不透明度
pressedBoolfalse选中填充 + aria-pressed
idString—元素 id
classString—附加 class 名
titleString—原生 tooltip 标题
aria_labelString—无障碍标签(纯图标按钮必填)
on_clickCmd—点击时发送的命令
attrsAttrs—附加 HTML 属性
styleArray[String][]附加内联样式

ButtonVariant ​

Primary · Secondary · Ghost

ButtonSize ​

Default · Sm · Icon · IconSm

* 必填(标签)参数——其余均为可选。