Skip to main content
Neighborhood Design System v5.1.0

Checkbox

Ready

A checkbox component that lets users select or deselect an option.

Preview

Open in Storybook (opens in new tab)

Code

Install
npm install @fbin-web/neighborhood-core
Import
import { NbhdCheckbox } from '@fbin-web/neighborhood-core';
Usage
<nbhd-checkbox
  label="Checkbox Label"
  id="checkbox-1">
</nbhd-checkbox>

Properties

PropertyAttributeTypeDefaultDescription
labellabelstring—The label text for the checkbox.
valuevaluestring—The value of the checkbox.
titletitlestring—The title of the checkbox.
namenamestring—The name of the checkbox. The form field name it submits under.
formformstring—ID of a
elsewhere on the page to belong to, like a native control’s `form` attribute.
ididstring—The id of the checkbox.
cssClasscss-classstring—Additional CSS classes to apply to the checkbox.
ariaLabelaria-labelstring—Descriptive text for additional context.
errorTexterror-textstring—Error message text to display when invalid. Defaults to "This field has an error." when empty.
helpTexthelp-textstring—Help text to provide additional context.
invalidinvalidbooleanfalseMarks the checkbox as invalid and shows the error text.
disableddisabledbooleanfalseDisables the checkbox from being selected.
checkedcheckedbooleanfalseWhether the checkbox is checked initially.
requiredrequiredbooleanfalseWhether the checkbox is required.

Events

NameDescriptionEvent Detail
clickFired when the checkbox is clicked.MouseEvent
inputFired when the checkbox value changes.InputEvent
nbhd-changeEmitted when the checkbox is checked or unchecked. The value is the checkbox’s `value` when checked, or an empty string when unchecked.{ value: string }
changeEmitted alongside nbhd-change.{ value: string }

Form methods

Form-associated: inside a it submits under its `name`, resets with the form, is disabled by a disabled

, and blocks submission with the browser’s validation message when required and unchecked (`invalid` only shows the error state). A page-level

Slots

NameDescription
labelCustom content for the checkbox label. When omitted, the label property value is rendered.
helpHelp text content displayed below the checkbox when not in an invalid state.
errorError message content displayed below the checkbox when in an invalid state.

CSS Parts

NameDescription
baseThe wrapper div for the checkbox form control.
labelThe label element for the checkbox.
label-slotThe named label slot inside the checkbox label.
label-textThe fallback text element that displays the label property value.
requiredThe required marker (*) shown in the label when required. Hidden from assistive technology, which announces the native required state.
textThe wrapper div for help and error text.
helpThe help slot element.
errorThe error slot element.
nbhd-checkbox::part(base) {
  /* your styles */
}

CSS Properties

Set these on nbhd-checkbox or an ancestor to override the defaults. Token is the design token a default comes from and Value is what it resolves to in core Neighborhood; brands may override them. Properties that adapt to surface follow the light or inverse surface they sit on until you set them.

Checkbox

PropertyTokenValue Copy
--nbhd-checkbox-box-borderRadius--nbhd-border-radius-sm2px
--nbhd-checkbox-indicator-borderRadius--nbhd-border-radius-none0

Form control

PropertyTokenValue Copy
--nbhd-formControl-display—inline
--nbhd-formControl-field-appearance—none
--nbhd-formControl-field-borderRadius--nbhd-border-radius-none0
--nbhd-formControl-field-color--nbhd-context-color-control-foregroundAdapts to surface
--nbhd-formControl-field-display—inline-block
--nbhd-formControl-field-fontFamily--nbhd-typography-body-fontFamilysans-serif
--nbhd-formControl-field-fontSize--nbhd-typography-body-fontSize1rem
--nbhd-formControl-field-inlineSize—100%
--nbhd-formControl-field-position—relative
--nbhd-formControl-fontFamily--nbhd-typography-body-fontFamilysans-serif
--nbhd-formControl-host-display—block
--nbhd-formControl-label-color--nbhd-context-color-text-primaryAdapts to surface
--nbhd-formControl-label-display—block
--nbhd-formControl-label-fontFamily--nbhd-typography-label-fontFamilysans-serif
--nbhd-formControl-label-fontSize--nbhd-typography-label-fontSize1rem
--nbhd-formControl-label-fontWeight--nbhd-typography-label-fontWeight600
--nbhd-formControl-label-letterSpacing—inherit
--nbhd-formControl-label-marginBlock--nbhd-space-0 --nbhd-space-050px 2px
--nbhd-formControl-label-position—relative
--nbhd-formControl-label-textTransform—inherit
--nbhd-formControl-marginBlock--nbhd-space-00px
--nbhd-formControl-maxInlineSize—100%
--nbhd-formControl-paddingBlock--nbhd-space-00px
--nbhd-formControl-paddingInline--nbhd-space-00px
--nbhd-formControl-position—relative
--nbhd-formControl-required-gap--nbhd-space-052px
--nbhd-formControl-text-marginBlock--nbhd-space-1 --nbhd-space-04px 0px

Selection control

PropertyTokenValue Copy
--nbhd-selectionControl-box-blockSize—18px
--nbhd-selectionControl-box-borderColor--nbhd-context-color-control-borderAdapts to surface
--nbhd-selectionControl-box-borderRadius--nbhd-border-radius-sm2px
--nbhd-selectionControl-box-borderStyle—solid
--nbhd-selectionControl-box-borderWidth--nbhd-border-width-subtle1px
--nbhd-selectionControl-box-inlineSize—18px
--nbhd-selectionControl-checked-label-fontWeight—600
--nbhd-selectionControl-focus-outlineColor--nbhd-context-color-focus-outlineAdapts to surface
--nbhd-selectionControl-formControl-marginBlock--nbhd-space-14px
--nbhd-selectionControl-formControl-paddingBlock--nbhd-space-14px
--nbhd-selectionControl-host-display—block
--nbhd-selectionControl-indicator-backgroundColor—transparent
--nbhd-selectionControl-indicator-blockSize—10px
--nbhd-selectionControl-indicator-inlineSize—10px
--nbhd-selectionControl-indicator-marginInline--nbhd-space-1 --nbhd-space-04px 0px
--nbhd-selectionControl-label-alignItems—center
--nbhd-selectionControl-label-cursor—pointer
--nbhd-selectionControl-label-display—flex
--nbhd-selectionControl-label-fontWeight--nbhd-typography-body-fontWeight400
--nbhd-selectionControl-label-gap--nbhd-space-14px
--nbhd-selectionControl-label-justifyContent—start
--nbhd-selectionControl-label-paddingInline--nbhd-space-9 --nbhd-space-036px 0px
--nbhd-selectionControl-label-textTransform—normal
--nbhd-selectionControl-text-paddingInlineStart--nbhd-space-936px

Dependencies

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

Esc
↑ ↓ to move↵ to open