Component

Radio

安装 Installation

npx timkit add radio-group --yes --framework react

用法 Usage

import { RadioGroup } from "@/components/ui/radio-group"

className 与 variant、size 可以一起用。字段以 timkit agent inspect radio-group --json 的 props 为准。

示例

Examples

一次看一个示例。左侧按名称筛选,预览里可切换源码和框架。

20 / 20

Radio · With label · 01

Loading preview...

结构化 API

Structured API

与 UCS schema 对齐的 props、逻辑机与多框架运行时。

Component

radio-group

Logic

zag / radioGroup

Runtime Frameworks

Not declared

Supported Platforms

WebWeChat Mini Program

Configuration

PropTypeDefaultDescription
logic.provider*
enum (zag | native | none)
zagState and interaction provider used by this component.
logic.machine
string
radioGroupUnderlying state machine identifier when provider is zag.
platforms*
array
Web, WeChat Mini ProgramPlatforms officially supported by this schema.
frameworks*
array
-Framework demos/code currently available in registry files.
dependencies
array
-Runtime package dependencies required by this registry item.
optionalPeerDependencies
array
-Optional peer dependencies used by this registry item.
registryDependencies
array
-Dependent Timkit registry components/hook entries.

Props

PropTypeDefaultDescription
value
string
-The controlled value.
disabled
boolean
falseWhether the radio group is disabled.
readOnly
boolean
falseWhen true, selection changes are ignored.
required
boolean
falseWhen true, the group is announced as required.
name
string
-The name of the radio group.
orientation
enum (horizontal | vertical)
verticalVertical groups are vertical. Horizontal groups are horizontal.

Events

PropTypeDefaultDescription
onValueChange
event
-Callback called when value changes.

TypeScript

来自 TypeScript 导出。

PropTypeDefaultDescription
id
string
-Input behavior configuration for id.
defaultValue
string
-The default value of the component when uncontrolled.
modelValue
string
-The controlled value bound via `v-model` (Vue specific).

Slots

PropTypeDefaultDescription
default
slot
-The radio items

Parts

PropTypeDefaultDescription
root*
root
-The radio group container
item
part
-The radio item
indicator
part
-The visual indicator of the checked state
This API reference is generated from `/packages/core` component schemas to keep React/Vue/Weapp docs consistent.

该组件尚无扩展说明文档。

键盘与焦点

Keyboard

跨 React、Vue 与小程序共享的交互与可读名称约定。

  • ArrowDown and ArrowUp move the selection when the group is vertical.
  • ArrowRight and ArrowLeft move it when the group is horizontal.
  • A letter selects the next enabled item whose label starts with that letter.
  • On the mini program, that label is the item value.
  • Space or Enter selects the focused item.
  • A disabled item is skipped.
  • A disabled or read-only group ignores those keys.
  • The checked item is in the tab order unless it is disabled.
  • When nothing is checked, or the checked item is disabled, the first enabled item is.
  • The other items are not.
  • A disabled group leaves every item out of the tab order.
  • The checked option is visible as Option N of the option count.
  • An empty value has no option status.
  • An omitted name is Radio group.
  • A passed aria-label names the group.
  • On the mini program, a radio is named by its content.
  • The checked mark is not part of that name.
  • In static HTML, on React, and in Vue, the checked mark is hidden from the name.
  • In static HTML, only the checked item stays in the tab order.
  • The checked option is visible as Option 1 of 2.
  • On the mini program, a read-only group sets aria-readonly.
  • On the mini program, a disabled group sets aria-disabled.

行为契约

Contract

props、默认值和运行时状态。

  • When read-only, selection changes are ignored.
  • The group is vertical unless orientation is horizontal.
  • A required group is announced as required.