Skip to content
Nana UI

Forms & Inputs

Radio

A single radio control — a circle + label. Selection is mutually exclusive and owned by the parent nana-radio-group, which manages the checked value, keyboard roving and form association; on its own a radio still renders and fires nana-change. Rebrand by overriding --nana-radio-accent (or the global --nana-surface-accent) — no need to fork the component.

View .md Download
Card Cash
Plan

Install the package for a versioned dependency:

npm install @nana-tec/ui-components

Or copy the source in and own it:

npx @nana-tec/ui add radio --framework web-components
npx @nana-tec/ui add radio --framework svelte

Lands in src/lib/components/ui/radio/ as NanaRadio.svelte and NanaRadioGroup.svelte, styled with Tailwind classes that resolve to the design tokens. Requires Tailwind v4.

Import the autoloader once, in your app's entry point. Every <nana-*> tag then works anywhere, and each component downloads only the first time a page uses it:

import "@nana-tec/ui-components/autoloader";
import "@nana-tec/ui-components/theme";

The second line gives every component the Nana look and the design tokens behind it. Leave it out to style the components entirely yourself.

Import a component directly when it must be ready at once: on screen at first paint, or when you call its methods straight away. The two mix freely:

import "@nana-tec/ui-components/radio";

Copied in with npx @nana-tec/ui add radio? Import your project's own @/lib/nana-ui/autoloader.js once instead; the CLI keeps it up to date.

<nana-radio-group value="card" label="Payment">
<nana-radio value="card">Card</nana-radio>
<nana-radio value="cash">Cash</nana-radio>
</nana-radio-group>
<script lang="ts">
import { NanaRadio, NanaRadioGroup } from '$lib/components/ui/radio';
let plan = $state('pro');
</script>
<NanaRadioGroup label="Plan" bind:value={plan}>
<NanaRadio value="free">Free</NanaRadio>
<NanaRadio value="pro">Pro</NanaRadio>
<NanaRadio value="team" disabled>Team</NanaRadio>
</NanaRadioGroup>

The group shares its name, size and disabled with every radio through context, so the children need only a value. orientation="horizontal" lays the options out in a row. For options drawn as buttons, NanaRadioButton goes in the same group; see Radio Button.

Each nana-radio takes a label and optional description.

Set orientation="horizontal" on the group.

Properties

PropertyAttributeTypeDefaultDescription
checkedcheckedbooleanfalseSelected state (normally driven by nana-radio-group)
descriptiondescriptionstring | undefined—Secondary descriptive text
disableddisabledbooleanfalseDisable the control
groupDisabled—booleanfalseSet by a disabled radio group so the radio reports itself disabled.
invalidinvalidbooleanfalseInvalid styling (set by the group when its validation fails)
labellabelstring | undefined—Convenience label text (slot wins if both are present)
sizesizeRadioSize'md'Control size
valuevaluestring''Submitted / emitted value for this option

Events

EventDescription
nana-changeFired on selection (detail.value)

Slots

SlotDescription
(default)The label (overrides the label attribute)
descriptionSecondary descriptive text

CSS parts

PartDescription
::part(control)The clickable row
::part(circle)The radio circle
::part(label)The label text
::part(text)The text
::part(description)The description

CSS custom properties

PropertyDescription
--nana-radio-accentSelected fill / border colour
--nana-radio-dot-colorInner dot colour
--nana-radio-borderUnselected border colour
--nana-radio-bgCircle background
--nana-radio-sizeCircle diameter (overrides size preset)
--nana-radio-radiusCorner radius of the control; fully round by default

The attributes on the parent — value, name, orientation, size, helper-text, error-message, required — belong to Radio Group, which is what wires a radio into a form. The button-styled alternative is Radio Button.

NanaRadio

PropType
valuerequiredstring
sizeRadioSize
labelstring
childrenSnippet

Also accepts Omit<HTMLInputAttributes, 'class' | 'size' | 'type' | 'value'>.

NanaRadioButton

PropType
valuerequiredstring
sizeRadioSize
labelstring
prefixSnippet
childrenSnippet

Also accepts Omit<HTMLInputAttributes, 'class' | 'size' | 'type' | 'value' | 'prefix'>.

NanaRadioGroup

PropTypeDefault
namestring
valuebind:stringundefined
sizeRadioSize'md'
orientationRadioGroupOrientation'vertical'
labelstring
disabledboolean
helperTextstring
errorMessagestring
invalidbind:booleanfalse
onValueChange(value: string) => void
childrenSnippet

Also accepts Omit<HTMLAttributes<HTMLDivElement>, 'class'>.