For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt, and this page is available as Markdown at /next/zh/ui/components/radio-group.md.
lynx-ui logo
lynx-ui
  • 简体中文
  • RadioGroup

    一个适用于 ReactLynx 的无样式单选组组件,用于管理一组单选按钮的单选状态。

    基础用法

    禁用

    RadioGroup 支持整组禁用,也支持为单个选项设置禁用状态。

    结构

    <RadioGroupRoot>
      <Radio>
        <RadioIndicator />
      </Radio>
    </RadioGroupRoot>

    API

    RadioGroupRoot

    The root component of the RadioGroup, containing all of its child components.

    defaultValue
    iOS
    Android
    Harmony
    类型string
    RadioGroup 被选中的初始值。使用此属性意味着 RadioGroup 是非受控的。如果值不匹配任何一个 Radio 的值,RadioGroup 将不会被选中。
    disabled
    iOS
    Android
    Harmony
    类型boolean·默认值false
    如果设置为 true,RadioGroup 将不能接受交互。
    onValueChange
    iOS
    Android
    Harmony
    类型(value: string) => void
    选中状态改变时触发
    value
    iOS
    Android
    Harmony
    类型string
    RadioGroup 被选中的值。使用此属性意味着 RadioGroup 是受控的。如果值不匹配任何一个 Radio 的值,RadioGroup 将不会被选中。
    children
    iOS
    Android
    Harmony
    类型ReactNode | ((state: { value: string | null; disabled: boolean }) => ReactNode)
    子节点

    基于状态的样式与渲染

    该组件将每一项内部状态通过两条等价通道同时对外暴露,下表逐行给出两者的对应关系:

    • CSS className:根节点上会动态加上 ui-<state> 形式的类名,可直接用 .ui-<state> { ... } 选择器定制样式;
    • Render-prop 字段:当 children 传入函数时,同一个状态会以 children({ <state>: boolean, ... }) 的形式作为参数传入,便于在运行时做条件渲染。
    ui-value
    Render Propvalue·类型string | null
    RadioGroup 当前被选中的值。
    ui-disabled
    Render Propdisabled·类型boolean
    RadioGroup 是否整体被禁用。

    Radio

    The item inside RadioGroup.

    children
    iOS
    Android
    Harmony
    类型ReactNode
    子组件
    className
    iOS
    Android
    Harmony
    类型string
    类名
    disabled
    iOS
    Android
    Harmony
    类型boolean
    Radio 是否被禁用。如果设置为 true,则该 Radio 无法接受交互。
    radioProps
    iOS
    Android
    类型ViewProps
    Radio 支持将原始视图属性直接展开到这个属性中。
    style
    iOS
    Android
    Harmony
    类型CSSProperties
    样式
    value
    iOS
    Android
    Harmony
    类型string
    Radio 的标识

    RadioIndicator

    The check slot indicating this Radio is now selected. Normally a circle. It's children will only be rendered when selected so it can be a custom inner selected indicator. Can be a ReactNode or a render function returns a ReactNode.

    children
    iOS
    Android
    Harmony
    类型ReactNode
    子节点
    className
    iOS
    Android
    Harmony
    类型string
    类名
    forceMount
    iOS
    Android
    类型boolean·默认值false
    强制挂载子节点。如果设置为 true,即使 checked 为 false,子节点也会被挂载。
    style
    iOS
    Android
    Harmony
    类型CSSProperties
    样式
    除非另有说明,本项目采用知识共享署名 4.0 国际许可协议进行许可,代码示例采用 Apache License 2.0 许可协议进行许可。