Radio
Radios allow users to select one option from a set.
Overview
Import
Import the component from @faststore/ui
import { Radio } from '@faststore/ui'
Import Styles into your FastStore project
To apply the styles of this component in your FastStore project, import the following into your stylesheet:
@import '@faststore/ui/src/components/atoms/Radio/styles.scsss';
Follow the instructions in the Importing FastStore UI component styles tutorial.
Usage
<Radio />
Props
Name | Type | Description | Default |
---|---|---|---|
testId | string | ID to find this component in testing tools (e.g.: cypress, testing library, and jest). | fs-radio |
Design Tokens
Local token | Default value/Global token linked |
---|---|
--fs-radio-width | 1.25rem |
--fs-radio-height | var(--fs-radio-width) |
--fs-radio-border-width | var(--fs-border-width) |
--fs-radio-border-radius | var(--fs-border-radius-circle) |
--fs-radio-border-color | var(--fs-border-color) |
--fs-radio-border-color-hover | var(--fs-border-color-hover) |
--fs-radio-transition | border var(--fs-transition-timing) var(--fs-transition-function), background-color var(--fs-transition-timing) var(--fs-transition-function), box-shadow var(--fs-transition-timing) var(--fs-transition-function) |
--fs-radio-bkg-color-hover | var(--fs-color-primary-bkg-light) |
--fs-radio-shadow-hover | 0 0 0 var(--fs-radio-border-width) var(--fs-border-color-active) |
Nested Elements
Knob
Local token | Default value/Global token linked |
---|---|
--fs-radio-knob-width | var(--fs-spacing-1) |
--fs-radio-knob-height | var(--fs-radio-knob-width) |
--fs-radio-knob-bkg-color | var(--fs-color-body-bkg) |
--fs-radio-knob-disabled-bkg-color | var(--fs-color-neutral-5) |
Variants
Checked
<Radio checked />
Local token | Default value/Global token linked |
---|---|
--fs-radio-checked-bkg-color | var(--fs-color-primary-bkg) |
--fs-radio-checked-bkg-color-hover | var(--fs-color-primary-bkg-hover) |
Disabled
<Radio checked disabled />
Local token | Default value/Global token linked |
---|---|
--fs-radio-disabled-bkg-color | var(--fs-color-disabled-bkg) |
--fs-radio-disabled-border-width | var(--fs-radio-border-width) |
--fs-radio-disabled-border-color | var(--fs-border-color-disabled) |
--fs-radio-disabled-text-color | var(--fs-color-disabled-text) |
Customization
For further customization, you can use the following data attributes:
data-fs-radio
Best Practices
✅ Do's
- Provide a Label when using radio input. Descriptive labels help users understand the purpose of a form control.
Related components
RadioField
RadioField wraps a Radio input and its corresponding Label.
See more