Skip to content
Nana UI

Forms & Inputs

Radio Button

A button-styled radio option — interchangeable with nana-radio inside a nana-radio-group. Inside a horizontal group the buttons read as a segmented control. The group owns selection, keyboard roving and form association; on its own one still renders, selects and fires nana-change.

View .md Download

A button-styled radio option — interchangeable with nana-radio inside a nana-radio-group. Inside a horizontal group the buttons read as a segmented control. The group owns selection, keyboard roving and form association; on its own one still renders, selects and fires nana-change.

Monthly Yearly Lifetime
npm install @nana-tec/ui-components
import "@nana-tec/ui-components/radio-button";

Already registered if you imported @nana-tec/ui-components/radio-group.

<nana-radio-group label="Billing period" orientation="horizontal" value="monthly">
<nana-radio-button value="monthly">Monthly</nana-radio-button>
<nana-radio-button value="yearly">Yearly</nana-radio-button>
</nana-radio-group>

orientation="horizontal" on the group is what makes a row of these read as one segmented control. In a vertical group they stay as separate stacked buttons — useful when the options are long, or when each needs its own description.

First option Second option First Second

nana-radio and nana-radio-button are interchangeable children of the same group, so a form can use a circle where it needs a description and a button where it does not.

<nana-radio-group label="Delivery" orientation="vertical" value="standard">
<nana-radio-button value="standard">Standard</nana-radio-button>
<nana-radio value="express" label="Express" description="Next working day"></nana-radio>
</nana-radio-group>

size is sm, md (default) or lg. Set it on the group to size every child at once, or on a single option to override it.

Small Small Large Large

The prefix slot takes a leading icon — a nana-icon, or anything else.

List Grid Board

Outside a group, drive checked yourself. Inside one, the group sets it from value — write checked and the group will overwrite it on the next render, so leave it to the group there.

<nana-radio-button value="a" checked>Selected</nana-radio-button>
<nana-radio-button value="b" disabled>Unavailable</nana-radio-button>

invalid is a styling hook the group sets when its error is non-empty; it paints the border in the danger colour. Set it directly only outside a group.

KeyDoes
Space EnterSelect this option
↓ → ↑ ←Move and select — handled by the group

Inside a group, the group’s roving tabindex decides which option is tabbable and the arrows do the moving, so this element only answers the activation keys. The host delegates focus to its inner <button>, which is what lets that roving tabindex land on the visible control.

Properties

PropertyAttributeTypeDefaultDescription
checkedcheckedbooleanfalseSelected state (normally driven by nana-radio-group)
disableddisabledbooleanfalseDisable the control
invalidinvalidbooleanfalseInvalid styling (set by the group when its validation fails)
sizesizeRadioSize'md'Control size
valuevaluestring''Submitted / emitted value for this option

Events

EventDescription
nana-changeFired on selection (detail.value)

Slots

SlotDescription
(default)The label
prefixLeading icon

CSS parts

PartDescription
::part(button)The interactive button

CSS custom properties

PropertyDescription
--nana-radio-button-accentSelected fill / border colour
--nana-radio-button-on-accentText colour when selected
--nana-radio-button-borderUnselected border colour
--nana-radio-button-bgUnselected background
--nana-radio-button-radiusCorner radius of the segmented button
  • The host carries role="radio" with a live aria-checked, and aria-disabled when disabled.
  • The visible control is a real <button type="button">, so it is reachable and activatable without the host’s role doing the work.
Explore Radio Button interactively Every state, prop, and edge case — with live controls — in Storybook.
View in Storybook