Skip to main content
Neighborhood Design System v5.0.0-rc.2

Radio Group

Ready

Groups radio buttons into a single choice with one tab stop and arrow-key navigation.

Preview

Open in Storybook (opens in new tab)

Code

Install
npm install @fbin-web/neighborhood-core
Import
import { NbhdRadioGroup } from '@fbin-web/neighborhood-core';
Usage
<nbhd-radio-group
  label="Finish"
  name="finish"
  value="chrome">
  <nbhd-radio
    label="Chrome"
    value="chrome"></nbhd-radio>
  <nbhd-radio
    label="Matte Black"
    value="matte-black"></nbhd-radio>
  <nbhd-radio
    label="Brushed Gold"
    value="brushed-gold"></nbhd-radio>
</nbhd-radio-group>

Properties

PropertyAttributeTypeDefaultDescription
labellabelstring—Visible label that names the group.
namenamestring—Name applied to every radio in the group. The form field name it submits under.
valuevaluestring—Value of the checked radio. Setting it checks the matching radio.
ariaLabelaria-labelstring—Accessible name for the group when there is no visible label.
cssClasscss-classstring—Additional CSS classes to apply to the group wrapper.
helpTexthelp-textstring—Help text to provide additional context.
errorTexterror-textstring—Error message text to display when invalid. Defaults to "This field has an error." when empty.
invalidinvalidbooleanfalseMarks the group as invalid and shows the error text.
requiredrequiredbooleanfalseMarks the group as required and shows the required marker.
disableddisabledbooleanfalseDisables every radio in the group; the group submits nothing.

Events

NameDescriptionEvent Detail
changeFired when the checked radio changes. Change events from the radios inside the group stop at the group.{ value: string }
nbhd-changeSame as change.{ value: string }

Form methods

Form-associated: submits the checked radio’s value under the group’s `name`. With `required`, nothing chosen blocks submission.

NameDescription
checkValidity()Returns false (and fires `invalid`) if the control fails validation.
reportValidity()Like checkValidity(), and shows the browser’s validation message on the control.
setCustomValidity(message)Marks the control invalid with your own message; an empty string clears it.
validityThe ValidityState (valueMissing, typeMismatch, customError, …).
validationMessageThe message the browser would show.
willValidateWhether the control takes part in form validation (false when disabled).
associatedFormThe
the control belongs to, or null.

Slots

NameDescription
(default)The nbhd-radio options.
labelCustom content for the group label. Defaults to the label property value.
helpHelp text content displayed below the options when not in an invalid state.
errorError message content displayed below the options when in an invalid state.

CSS Parts

NameDescription
baseThe group wrapper div.
labelThe group label.
label-slotThe slot element inside the label.
label-textThe text element that displays the label property value.
requiredThe required marker (*) shown in the label when required. Hidden from assistive technology, which announces aria-required.
optionsThe radiogroup element that wraps the radios.
textThe wrapper div for help and error text.
helpThe help slot element.
errorThe error slot element.
nbhd-radio-group::part(base) {
  /* your styles */
}

Dependencies

Child components <nbhd-radio-group> renders internally. Import them too when you tree-shake.

Esc
↑ ↓ to move↵ to open