ClickorAltL

Dragto resize

Nord Design System SearchDeveloperDeveloperGetting startedUsing Web ComponentsWebfontsCDNLocalizationCSS Framework Legacy ESLint PluginWorking with AIFAQDesignDesignGetting startedFoundationsThemesBrand assetsToolsComponentsComponentsAccordion New Aside New Autocomplete New AvatarBadgeBanner Updated ButtonButton GroupCalendar Updated CardCheckbox Updated Collapsible New Combobox New Command MenuDate Picker Updated Date Range Picker New DividerDrawerDropdownEmpty StateField New FieldsetFilter Bar New FooterHeaderIconInput Updated Item New Kbd New LayoutMessageMeter New ModalNavigationNotificationNumber Field New Otp Field New Outline New Pagination New Popout Updated ProgressProgress BarQrcodeRadio Updated Range Updated Scroll Area New Segmented ControlSelect Updated SkeletonSpinnerStackTabTableTagTextarea Updated Time Picker New ToastToggle Updated TooltipTop BarTruncate New Visually HiddenDesign TokensDesign TokensTailwind CSSTailwind CSSBlocksBlocksTemplatesTemplatesIconsIconsPlaygroundPlaygroundLatest UpdatesLatest UpdatesChangelogChangelogMigration guidesMigration guides
GitHub

Radio Updated

Open in Storybook

Allows the user to choose only one option from a predefined set of mutually exclusive options.

Loading...

Usage

Radio buttons let users choose a single option from a set of mutually exclusive choices. Give every radio in a group the same name so selecting one deselects the others, and a distinct value.

Radios are always grouped, so wrap them in a Field Set with a Field Legend: the legend labels the question the radios answer, and the Field Set exposes the group to assistive technology. Add a Field Description for a group-level hint and a Field Error for validation. Each radio also renders its own built-in label when used standalone; inside a Field Set it steps aside automatically.

Copy code
import "@nordhealth/components/lib/Radio"
import "@nordhealth/components/lib/Field"
import "@nordhealth/components/lib/FieldLabel"
import "@nordhealth/components/lib/FieldSet"
import "@nordhealth/components/lib/FieldLegend"
import "@nordhealth/components/lib/FieldGroup"
import "@nordhealth/components/lib/FieldDescription"
import "@nordhealth/components/lib/FieldError"
Subscription plan Choose the plan that suits you. Monthly Annual Lifetime

Standalone or inside a Field

Use the control on its own with its built-in label, hint and error, or wrap it in a Field — the Field then provides the labelling. Both render the same control:

InlineWith Field

Examples

Checked

Set checked on the radio that should be selected by default.

Sizes

The size attribute accepts s, m (default) and l.

Disabled

Use disabled to prevent interaction.

Required

Set required on the Field Label to show the indicator and mark the group required.

Hidden label

Visually hide the per-radio label when the legend and surrounding layout already convey each option, keeping it available to assistive technology.

Subscription plan

A real-world group of radios laid out as a set of plans the user chooses between.

Hint and error

Give the group a hint with a Field Description, show validation with a Field Error and mark the Field Set invalid.

Contact method We will only use this to confirm your appointment. Email Phone Select a contact method.

RTL

Radios follow the document or container direction. Toggle the direction to see the label and control mirror.

Accessibility

  • All radios in one group must share the same name so they behave as a single, mutually-exclusive set and arrow keys move selection between them.
  • Group radios under a Field Set with a Field Legend so the question the radios answer is announced — the Field Set exposes role="group" named by its legend.
  • Give each radio an accessible name with a Field Label connected via for.
  • Mark a required group by setting required on the Field Label of the relevant control, or convey it in the legend.
  • Convey validation with a Field Error rather than colour alone — it is a live region announced to assistive technology, and marking the Field Set invalid keeps the styling in sync.

API reference

Radio

Radio buttons are graphical user interface elements that allow user to choose only one option from a predefined set of mutually exclusive options.

<nord-radio></nord-radio>

Props

PropertyAttribute Description TypeDefault
checkedcheckedControls whether the checkbox is checked or not.booleanfalse
sizesizeThe size of the component.'s' | 'm' | 'l''m'
placeholderplaceholderPlaceholder text to display within the control.string | undefined
requiredrequiredDetermines whether the control is required or not. A required control is announced as such to assistive technology and, inside a <nord-field>, drives the required indicator on the <nord-field-label>. When using this property you need to also set “novalidate” attribute on a form element to prevent browser from displaying its own validation errors.booleanfalse
disableddisabledMakes the component disabled. This prevents users from being able to interact with the component, and conveys its inactive state to assistive technologies.booleanfalse
namenameThe name of the form component.string | undefined
valuevalueThe value of the form component.string''
formformGets the form, if any, associated with the form element. The setter accepts a string, which is the id of the form.HTMLFormElement | null

Field properties

PropertyAttribute Description TypeDefault
labellabelLabel for the control. Ignored when the control is wrapped in a <nord-field>, which provides the label via <nord-field-label>.string''
hinthintOptional hint text shown with the control. Ignored inside a <nord-field>, which provides it via <nord-field-description>.string | undefined
hintBelowhint-belowRenders the hint below the control and any error instead of below the label.booleanfalse
hideLabelhide-labelVisually hide the label, but still expose it to assistive technologies.booleanfalse
errorerrorOptional error shown with the control. Ignored inside a <nord-field>, which provides it via <nord-field-error>.string | undefined
hideRequiredhide-requiredVisually hide the required indicator, but still expose the required state to assistive technologies.booleanfalse

Slots

Slot name Description
labelUse when a label requires more than plain text.
hintOptional slot that holds hint text for the input.
errorOptional slot that holds error text for the input.

Methods

Method nameParameters Description
focus(options?: FocusOptions) => voidoptions: An object which controls aspects of the focusing process.Programmatically move focus to the component.
blur() => voidN/AProgrammatically remove focus from the component.
click() => voidN/AProgrammatically simulates a click on the component.
EventDetail TypeDescription
inputNordEventFired as the user types into the input.
changeNordEventFired whenever the input's value is changed via user interaction.

CSS Properties

CSS Custom Properties provide more fine grain control over component presentation. We advise utilizing existing properties on the component before using these.

PropertyDescriptionDefault
--n-label-colorControls the text color of the label, using our color tokens.var(--n-color-text)
Design guidelinesFor designers

Usage

This section includes guidelines for designers and developers about the usage of this component in different contexts.

Do

  • Use a radio component when users can only select one option from a list.
  • Favor radios over a select component when there are a small number of options. This reduces the number of clicks a user has to make, increasing efficiency.
  • Radio buttons are grouped by their name attribute. Therefore, it is crucial that the same name is used for a group of radios.
  • Give each radio within a group a unique value.
  • Radios must be grouped for accessibility — wrap them in a Field Set with a Field Legend. The legacy Fieldset still works but is deprecated.
  • In most cases, a stack component should be used to layout a group of radio buttons.

Don’t

  • Don’t place interactive content (buttons, links etc) inside the label.
  • Don’t use when a user can select more than one option. In this case, use a checkbox instead.
  • Don’t use for “accepting terms of service” and similar functionality. Use a checkbox instead.
  • When you have more than 10 options to choose from. Consider using a select instead.

Hint placement

Hint text is rendered above the control by default to preserve existing behavior for current consumers. Use the hint-below property to opt in to rendering the hint below the control and any error.

This is a non-breaking rollout for teams adopting the new layout gradually. Existing integrations keep the current placement unless hint-below is explicitly set.

Content guidelines

Radio button labels should be clear, accurate and predictable. It should be possible for the user to understand what they are enabling or disabling:

User settings
Option 1

When writing radio button labels, always write them in sentence case, not title case. The first word should be capitalized and the rest lowercase (unless a proper noun):

My tasks
My Tasks

Avoid ending in punctuation if it’s a single sentence, word, or a fragment:

Blue
Blue.

Do not use commas or semicolons at the end of each line

Patient
Patient;

Additional considerations

  • Hint text can be used to offer further information or explanation for an option.
  • Once a radio has been selected, users cannot return to having no radios selected without refreshing their browser window. Therefore, you should include "None of the above" or "I do not know" if they are valid options.
  • In most cases, radio buttons should be stacked vertically. However, radio buttons can be stacked horizontally when there are only two options with short labels. An example might be a yes/no question.