Radio

A control for choosing one option from a mutually exclusive set.

VerifiedSince 0.3.4

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 value unique within a group.
  • Use button for short segmented choices, a column of standard radios for long lists, and card when 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 updateOnSettled default for glass / blur indicators unless validation must run immediately.

API Reference

TxRadioGroup

Props

PropTypeDefaultDescription
modelValue / v-modelstring | number-Value of the selected radio.
disabledbooleanfalseDisables 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.
glassbooleanfalseShorthand for the glass indicator.
blurbooleanfalseShorthand for the blur indicator.
updateOnSettledboolean-Button groups emit only after the indicator settles; on by default for glass and blur.
stiffnessnumber110Indicator spring stiffness; higher settles faster.
dampingnumber12Indicator spring damping; lower is bouncier.
blurAmountnumber1Backdrop blur strength of the blur indicator.
elasticbooleantrueEnables the indicator's stretch and impact motion.

Events

EventParamsDescription
update:modelValue(value: string | number)Fires when a new value is selected.
change(value: string | number)Fires together with update:modelValue.

Slots

SlotPropsDescription
default-TxRadio children.

Keyboard

KeyBehavior
ArrowRight / ArrowDownSelects the next enabled radio, wrapping to the first.
ArrowLeft / ArrowUpSelects the previous enabled radio, wrapping to the last.
Home / EndSelects the first / last enabled radio.

TxRadio

Props

PropTypeDefaultDescription
valuestring | number-Value written to the group when selected.
labelstring''Text shown when the default slot is empty.
disabledbooleanfalseDisables 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-modelboolean-Checked state when used standalone; uncontrolled when omitted, ignored inside a group.

Events

EventParamsDescription
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

SlotPropsDescription
default-Label or card content; falls back to label.

Overview

  • TxRadioGroup owns 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 updateOnSettled active, the new value applies inside the group first; update:modelValue and change fire once the indicator settles.
  • Source: packages/tuffex/packages/components/src/radio/.
查看源码
packages/tuffex/packages/components/src/radio/index.ts