Skip to content

Radio ​

Radio button input with label support.

Also known as: radio button, option button, single choice

View in Storybook

When to use ​

  • Mutually exclusive choice from 2-5 options. For more options, use Select.
  • For card-style, use RadioCard. For grouped layout, use RadioGroup.

Import ​

tsx
import { Radio } from '@vacano/ui'

Usage ​

tsx
const [selected, setSelected] = useState('option1')

<Radio
  checked={selected === 'option1'}
  onChange={() => setSelected('option1')}
  label="Option 1"
  name="options"
/>
<Radio
  checked={selected === 'option2'}
  onChange={() => setSelected('option2')}
  label="Option 2"
  name="options"
/>

Variants ​

tsx
<Radio variant="normal" checked={true} onChange={() => {}} label="Normal" />
<Radio variant="error" checked={true} onChange={() => {}} label="Error" />

Disabled ​

tsx
<Radio disabled checked={true} onChange={() => {}} label="Disabled checked" />
<Radio disabled checked={false} onChange={() => {}} label="Disabled unchecked" />

Props ​

PropTypeDefaultDescription
checkedbooleanrequiredChecked state
onChangeChangeEventHandler<HTMLInputElement>requiredChange handler
labelReactNode-Label content (text or any renderable node)
variant'normal' | 'error''normal'Visual variant
disabledbooleanfalseDisable radio
namestring-Input name for grouping
classNamestring-CSS class name for the root element
classnamesRadioClassNames-Custom class names for inner elements
refRef<HTMLInputElement>-Ref to the underlying input element
data-test-idstring-Test identifier attribute

All standard HTML input attributes are also supported (except type, checked, onChange, and className which are controlled by the component).

ClassNames ​

KeyDescription
inputHidden input element
boxVisual radio circle
dotSelected dot indicator
labelLabel text

Released under the MIT License.