Radio
A control for choosing one option from a mutually exclusive set.
Usage
Button Group
The default style; the indicator can also be dragged to choose.
Loading demo...
Standard
Set type="standard"; direction switches between a row and a column.
Loading demo...
Cards
Set type="card" and put the title and description in the default slot.
Loading demo...
Indicator
indicatorVariant sets how the indicator is drawn; elastic toggles its stretch motion.
Loading demo...
Disabled
Loading demo...
Playground
Loading demo...
Best Practices
- Keep every
valueunique within a group. - Use
buttonfor short segmented choices, a column ofstandardradios for long lists, andcardwhen options need a description. - Disable an unavailable option on its own so it stays visible; disable the whole group only when read-only or loading.
- Keep the
updateOnSettleddefault forglass/blurindicators unless validation must run immediately.
API Reference
TxRadioGroup
Props
| Prop | Type | Default | Description |
|---|---|---|---|
modelValue / v-model | string | number | - | Value of the selected radio. |
disabled | boolean | false | Disables the whole group, including keyboard selection. |
type | 'button' | 'standard' | 'card' | 'button' | Style shared by the child radios. |
direction | 'row' | 'column' | - | Layout direction; button is always row, standard defaults to row, card to column. |
indicatorVariant | 'solid' | 'outline' | 'glass' | 'blur' | - | Button-group indicator style; when omitted, derived from glass / blur, otherwise solid. |
glass | boolean | false | Shorthand for the glass indicator. |
blur | boolean | false | Shorthand for the blur indicator. |
updateOnSettled | boolean | - | Button groups emit only after the indicator settles; on by default for glass and blur. |
stiffness | number | 110 | Indicator spring stiffness; higher settles faster. |
damping | number | 12 | Indicator spring damping; lower is bouncier. |
blurAmount | number | 1 | Backdrop blur strength of the blur indicator. |
elastic | boolean | true | Enables the indicator's stretch and impact motion. |
Events
| Event | Params | Description |
|---|---|---|
update:modelValue | (value: string | number) | Fires when a new value is selected. |
change | (value: string | number) | Fires together with update:modelValue. |
Slots
| Slot | Props | Description |
|---|---|---|
default | - | TxRadio children. |
Keyboard
| Key | Behavior |
|---|---|
ArrowRight / ArrowDown | Selects the next enabled radio, wrapping to the first. |
ArrowLeft / ArrowUp | Selects the previous enabled radio, wrapping to the last. |
Home / End | Selects the first / last enabled radio. |
TxRadio
Props
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | number | - | Value written to the group when selected. |
label | string | '' | Text shown when the default slot is empty. |
disabled | boolean | false | Disables this radio; keyboard navigation skips it. |
type | 'button' | 'standard' | 'card' | 'button' | Style when used standalone; inside a group, the group's type wins. |
modelValue / v-model | boolean | - | Checked state when used standalone; uncontrolled when omitted, ignored inside a group. |
Events
| Event | Params | Description |
|---|---|---|
click | (value: string | number) | Fires when an enabled, unchecked radio selects itself through the group. |
update:modelValue | (value: boolean) | Standalone only: fires with true when an unchecked radio is clicked. |
Slots
| Slot | Props | Description |
|---|---|---|
default | - | Label or card content; falls back to label. |
Overview
TxRadioGroupowns the selected value, injects style and disabled state into its radios, and handles keyboard navigation.- In a group, clicking the checked radio emits nothing.
- In button groups, the indicator can be dragged horizontally; on release it snaps to and selects the nearest enabled radio. Disabled groups ignore the drag.
Technologies
- With
updateOnSettledactive, the new value applies inside the group first;update:modelValueandchangefire once the indicator settles. - Source:
packages/tuffex/packages/components/src/radio/.
查看源码
packages/tuffex/packages/components/src/radio/index.ts