shadcn_ui-radio-group
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseShadcn UI — Radio Group
Shadcn UI — 单选按钮组
Instructions
使用说明
ShadRadioGroup<T>itemsShadRadio<T>valuelabelShadRadioGroupFormField<T>ShadFormidlabelitemsvalidatorShadRadioGroup<T>itemsvaluelabelShadRadio<T>ShadFormShadRadioGroupFormField<T>idlabelitemsvalidatorStandalone
独立使用
dart
ShadRadioGroup<String>(
items: [
ShadRadio(label: Text('Default'), value: 'default'),
ShadRadio(label: Text('Comfortable'), value: 'comfortable'),
ShadRadio(label: Text('Nothing'), value: 'nothing'),
],
)dart
ShadRadioGroup<String>(
items: [
ShadRadio(label: Text('Default'), value: 'default'),
ShadRadio(label: Text('Comfortable'), value: 'comfortable'),
ShadRadio(label: Text('Nothing'), value: 'nothing'),
],
)Form field
表单字段使用
dart
enum NotifyAbout { all, mentions, nothing; }
ShadRadioGroupFormField<NotifyAbout>(
label: const Text('Notify me about'),
items: NotifyAbout.values.map(
(e) => ShadRadio(
value: e,
label: Text(e.message),
),
),
validator: (v) {
if (v == null) return 'You need to select a notification type.';
return null;
},
)dart
enum NotifyAbout { all, mentions, nothing; }
ShadRadioGroupFormField<NotifyAbout>(
label: const Text('Notify me about'),
items: NotifyAbout.values.map(
(e) => ShadRadio(
value: e,
label: Text(e.message),
),
),
validator: (v) {
if (v == null) return 'You need to select a notification type.';
return null;
},
)