Esta página aún no está disponible en tu idioma.
A custom radio group component with support for sizes and colors. Form compatible.
---import { RadioGroup } from 'studiocms:ui/components';---
<RadioGroup label='Label' options={[ { label: 'Option 1', value: 'opt-1' }, { label: 'Option 2', value: 'opt-2' } ]}/>You can change a radio group to be displayed horizontally by using the horizontal prop:
---import { RadioGroup } from 'studiocms:ui/components';---
<RadioGroup label='Label' horizontal options={[ { label: 'Option 1', value: 'opt-1-h' }, { label: 'Option 2', value: 'opt-2-h' } ]}/>You can set a default selected option via the defaultValue prop.
---import { RadioGroup } from 'studiocms:ui/components';---
<RadioGroup label='Default Selected' defaultValue='opt-1' options={[ { label: 'Option 1', value: 'opt-1' } ]}/><!-- Other colors omitted for simplicity -->The radio group component supports all default colorways.
---import { RadioGroup } from 'studiocms:ui/components';---
<RadioGroup label='Default Selected' defaultValue='opt-1' options={[ { label: 'Option 1', value: 'opt-1' } ]} color='primary'/><!-- Other colors omitted for simplicity -->You can disable either the entire radio group (by passing the disabled prop) or a single option via the options. The example
below shows how to do the latter:
---import { RadioGroup } from 'studiocms:ui/components';---
<RadioGroup label='Default' options={[ { label: 'Option 1', value: 'opt-1', disabled: true }, { label: 'Option 1', value: 'opt-2' } ]} color='primary'/><!-- Other colors omitted for simplicity -->Inputs have full form support. You can use the isRequired and name attributes as needed.
The first one does what it says it does, while the latter sets the name attribute so you can access the input in, for example,
the FormData returned by a submission. Here’s an example showing how to set both of them:
---import { RadioGroup } from 'studiocms:ui/components';---
<RadioGroup label='Required & Custom Name' isRequired name='required-radio' options={[ { label: 'Option 1', value: 'opt-1' }, { label: 'Option 2', value: 'opt-2' } ]}/>