Radio Group
Выбор одного варианта. Бесплатно, MIT · Формы и ввод › Флажки и ползунки
Установка
npx valyro-cli@latest add radio-group
npx shadcn@latest add https://valyro.xyz/r/radio-group.json
npm install valyro-ui
import 'valyro-ui/styles.css';
import { RadioGroup } from 'valyro-ui';
Пропсы
| Prop | Type | Default | |
|---|---|---|---|
options | RadioGroupOption[] | Radios in order, each with a label and an optional description. Or compose them as children: RadioGroup.Item. | |
children | ReactNode | The compound form instead of options: RadioGroup.Item elements. | |
value | string | Controlled value; use with onValueChange. | |
defaultValue | string | Initial value when uncontrolled. | |
onValueChange | (value: string) => void | Called with the new value when it changes. | |
name | string | Name of the native radios (generated when omitted). | |
orientation | 'vertical' | 'horizontal' | 'vertical' | Stack options in a column or lay them out in a row. |
variant | 'default' | 'cards' | 'default' | cards renders each option as a selectable bordered card. |
size | 'sm' | 'md' | 'lg' | 'md' | Radio and text size. |
disabled | boolean | false | Disables every option. |
invalid | boolean | false | Error color on the radios and aria-invalid on the group. |
required | boolean | Marks the group aria-required and makes a choice mandatory for native form validation. | |
animation | 'default' | 'spring' | 'default' | spring: the chosen dot pops in with a bounce and the ring pulses. default: the theme's transition. |
label | ReactNode | Visible name above the options, linked to the group. Outside a FormField a group needs a name (this, or an aria-label / aria-labelledby), or a screen reader reads the options with no question. |
Составные части
RadioGroup.Item (RadioGroupItem)
Похожие компоненты
- Checkbox — Флажки
- Checkbox Group — Флажки с общей подписью, подсказкой, ошибкой и обязательностью
- Switch — Переключатель
- Slider — Ползунок
- Histogram Range — Диапазон цен с гистограммой, двумя ползунками и полями
- Rating Input — Оценка звёздами
- Text Input — Текстовые поля
- Textarea — Многострочный ввод
- Search Input — Поисковая строка
- Mentions Input — Текст с @упоминаниями и #тегами, асинхронные подсказки
- Tags Input — Ввод тегов
- Select — Выбор из списка
Назад: Checkbox Group · Далее: Switch · Весь раздел «Формы и ввод»