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/radio.md.
v0.0.57
  • 简体中文
  • Radio

    数据录入@rockshin/tao-ui

    从一组互斥选项中选择一个值。

    何时使用

    选项数量较少且用户需要同时比较时使用 RadioGroup。

    推荐

    • 默认值应安全且合理。
    • 选项标签描述结果而非动作。

    避免

    • 允许多选时不要使用 Radio,应使用 Checkbox。

    代码演示

    基础用法

    TSX

    独立状态

    TSX

    纵向选项组

    TSX

    受控单选组

    Group 的 onChange 直接返回选项值。

    Frequency: Weekly
    TSX

    垂直与禁用选项

    用纵向排列容纳较长选项,单个选项可禁用。

    TSX

    原生表单提交

    设置组的 name 后,可从 FormData 读取选中的值。

    TSX

    单选组尺寸

    同一组的选项继承尺寸,维持一致的对齐和点击区域。

    TSX

    API

    RadioGroup

    属性说明类型默认值
    disabled是否禁用boolean | undefined-
    nameNative group name; generated when omitted to isolate keyboard navigation.string | undefined-

    Radio

    属性说明类型默认值
    disabled是否禁用boolean | undefined-