For AI agents: the complete documentation index is available at https://rickyshin93.github.io/tao-ui/zh/llms.txt, the full documentation bundle is available at https://rickyshin93.github.io/tao-ui/zh/llms-full.txt, and this page is available as Markdown at https://rickyshin93.github.io/tao-ui/zh/components/button.md.
v0.0.57
  • 简体中文
  • Button 按钮

    通用@rockshin/tao-ui

    触发提交、保存、打开界面等即时操作。

    代码演示

    变体

    每个视图或决策区域只保留一个主操作。Secondary、ghost 与 destructive 变体用于降低或明确操作层级。Bare 保留按钮行为,同时把视觉样式交给消费方的 class 或 style。

    TSX

    尺寸

    密集工具栏使用 small,常规操作使用 medium,需要突出时使用 large。

    TSX

    加载与禁用

    加载按钮会设置 aria-busy 并阻止重复操作。图标插槽始终挂载,因此状态切换不会造成内容位移。

    TSX

    图标与自定义加载

    通过 icon 传入装饰性前置图标。SVG 的显式宽高会被保留;未指定的宽高默认为按钮字号。只有内置 spinner 不符合周围视觉语言时才使用 loadingIcon。

    TSX

    Provider 默认值

    Button 会从 TaoProvider 继承 size 与 disabled,局部属性可以覆盖继承的尺寸。

    TSX

    语义化定制

    通过稳定的 root 部件定制样式,无需依赖私有选择器。

    TSX

    原生表单按钮

    提交与重置遵循原生表单语义,演示不发送网络请求。

    Edit and save
    TSX

    纯图标按钮

    使用 aria-label 提供名称;图标自身从辅助技术中隐藏。

    0 items
    TSX

    局部配置与覆盖

    局部配置统一尺寸和禁用状态,单个按钮可以明确覆盖。

    TSX

    API

    Button

    属性说明类型默认值
    disabledPrevents interaction. Inherits from TaoProvider.boolean | undefined-
    childrenButton label or inline content.ReactNode-
    variantVisual emphasis for the action."primary" | "secondary" | "ghost" | "destructive" | "bare" | undefinedprimary
    sizeControl height and horizontal spacing. Inherits from TaoProvider.TaoSize | undefined-
    loadingShows the loading icon, sets aria-busy, and prevents interaction.boolean | undefined-
    iconLeft-leading decorative icon (non-loading state).ReactNode-
    loadingIconIcon shown while loading. Defaults to a built-in spinner.ReactNode-
    classNamesSemantic class overrides keyed by ButtonSemanticPart.Partial<Record<"root", string>> | undefined-
    stylesSemantic style overrides keyed by ButtonSemanticPart.Partial<Record<"root", CSSProperties>> | undefined-