DocsBlog
  • 0.25.3

  • light

    dark

    system

    Switch mode
  • Cerberus

    Acheron

    Elysium

Get Started
Components
Styling
Theming

Concepts

OverviewCompositionTesting

Layout

Aspect RatioBleedBoxCenterContainerDividerFlexFloatGridLink OverlayScrollableStackWrap

Components

AccordionAdmonitionAvatarButtonCarouselCheckboxClipboardCollapsibleComboboxConfirm ModalCTAModalDate PickerDialogFieldFieldsetFile UploaderIcon ButtonInputLoading StatesMenuNotificationsNumber InputPin InputProgressPrompt ModalRadioRatingSelectSplit ButtonSwitchTableTabsTagTextTextareaToggleTooltip

Utilities

Client OnlyDownload TriggerEnvironmentFeature FlagsFocus TrapForFormat ByteFormat NumberFormat Relative TimeFrameHighlightJSON Tree ViewLocaleLocal StoragePortalPresenceShowsplitPropsTheme

Radio

The Radio component allows users to select one option from a set of choices.

  • npm
  • source
  • recipe
  • Ark
import { RadioGroup, Radio, RadioParts } from '@cerberus/react'

Usage

The Radio component is a controlled component that can be used to select one option from a set. Simply wrap the Radio components in a RadioGroup component to create a group of radio buttons.

Copy
basic demo
import { Radio, RadioGroup } from '@cerberus/react'
export function BasicDemo() {
return (
<RadioGroup defaultValue="cerberus">
<Radio value="cerberus">Cerberus</Radio>
<Radio value="hades">Hades</Radio>
<Radio value="zeus">Zeus</Radio>
</RadioGroup>
)
}

Orientation

The RadioGroup component supports two orientations: horizontal, and vertical. The default orientation is horizontal.

Copy
Orientation demo
import { Radio, RadioGroup } from '@cerberus/react'
export function OrientationDemo() {
return (
<RadioGroup defaultValue="cerberus" orientation="vertical">
<Radio value="cerberus">Cerberus</Radio>
<Radio value="hades">Hades</Radio>
<Radio value="zeus">Zeus</Radio>
</RadioGroup>
)
}

Sizes

The Radio component supports two sizes: sm, and md. The default size is sm.

Copy
size demo
import { Radio, RadioGroup } from '@cerberus/react'
export function SizeDemo() {
return (
<RadioGroup defaultValue="cerberus">
<Radio size="md" value="cerberus">Cerberus</Radio>
<Radio size="md" value="hades">Hades</Radio>
<Radio size="md" value="zeus">Zeus</Radio>
</RadioGroup>
)
}

Primitives

You can utilize the primitive components or the css prop to customize the radio.

ComponentDescription
RadioGroupRootThe context provider for the RadioGroup parts
RadioGroupLabelThe label of the radio
RadioGroupIndicatorThe indicator of the radio state
RadioGroupItemThe container of the label and control of the radio
RadioGroupItemTextThe label for a single radio
RadioGroupItemControlThe visual input of a single radio
RadioGroupItemHiddenInputThe native input for the radio
Copy
custom radio demo
import { RadioParts } from '@cerberus/react'
function CustomDemo() {
return (
<RadioParts.Root>
<RadioParts.Item>
<RadioParts.ItemText
css={{
textStyle: 'body-lg',
}}
>
Cerberus
</RadioParts.ItemText>
<RadioParts.ItemControl
css={{
bgColor: 'info.bg.initial',
h: 8,
w: 8,
transform: 'skew(-10deg)',
_checked: {
bg: 'warning.bg.initial',
},
}}
/>
<RadioParts.ItemHiddenInput />
</RadioParts.Item>
</RadioParts.Root>
)
}

API

Props

RadioGroup

The RadioGroup component is an abstraction of the primitives and accepts the following props:

NameDefaultDescription
orientationhorizontalThis orientation of the group.

The RadioGroup component also accepts all the props of the RadioGroupRoot primitive props

Radio

The Radio component is an abstraction of the primitives and accepts the following props:

NameDefaultDescription
sizesmThe size of the radio.

The Radio component also accepts all the props of the RadioGroupItem primitive props

Parts

The RadioParts API is an Object containing the full family of components.

Note

It is best to only use the RadioParts if you are building a custom solution. Importing Object based components will ship every property it includes into your bundle, regardless if you use it or not.

NameDescription
RootThe RadioGroupRoot component which is the Provider for the family.
LabelThe RadioGroupLabel component which displays the label and "required" notice.
IndicatorThe RadioGroupIndicator component which displays based on the checked state.
ItemThe RadioGroupItem component which is the container to a single radio item.
ItemTextThe RadioGroupItemText component which is the label of the radio.
ItemControlThe RadioGroupItemControl component which is the visual field.
HiddenInputThe RadioGroupHiddenInput component which displays the native input.

On this page

  • Edit this page on Github
Cerberus Design System | Docs