Skip to main content
Neighborhood Design System v5.1.0

Input

Ready

A customizable text input component for collecting user data with support for various input types, validation, and styling options.

Preview

Open in Storybook (opens in new tab)

Code

Install
npm install @fbin-web/neighborhood-core
Import
import { NbhdInput } from '@fbin-web/neighborhood-core';
Usage
<nbhd-input
  type="text"
  inputmode="text"
  name="the-input"
  id="id"
  help-text="This is some help text for the input."
  error-text="This is an error message for the input."
  title="the input"
  label="Form Label"
  autocomplete="off"
  spellcheck="true">
</nbhd-input>

Properties

PropertyAttributeTypeDefaultDescription
surfacesurfacenoneprimarysecondaryinverseinverse-secondaryprimarySets the surface color treatment for the input.
typetypetextdatedatetime-localtelnumbersearchemailpasswordtextThe type of input element.
inputmodeinputmodenonetextdecimalnumerictelsearchemailurl—Hints at the type of data that might be entered for mobile keyboards.
spellcheckspellcheckbooleantrueWhether to enable spell checking.
placeholderplaceholderstring—Placeholder text displayed when the input is empty.
valuevaluestring—The current value of the input.
namenamestring—The name of the input for form submission. The form field name it submits under.
labellabelstring—The label text for the input.
titletitlestring—The title attribute for the input.
ididstring—The id of the input element.
cssClasscss-classstring—Additional CSS classes to apply to the input.
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.
patternpatternstring—Regular expression pattern for validation.
maxlengthmaxlengthnumber—Maximum length of the input value.
minlengthminlengthnumber—Minimum length of the input value.
maxmaxnumberstring—Maximum value for number or date inputs.
minminnumberstring—Minimum value for number or date inputs.
invalidinvalidbooleanfalseMarks the input as invalid for validation.
disableddisabledbooleanfalseDisables the input.
requiredrequiredbooleanfalseMarks the input as required.
autofocusautofocusbooleanfalseAutomatically focuses the input when the page loads.
readonlyreadonlybooleanfalseMakes the input read-only.
autocompleteautocompletestring—Controls browser autocomplete behavior.
autocorrectautocorrectbooleantrueControls whether the browser may automatically correct input text.

Events

NameDescriptionEvent Detail
nbhd-changeEmitted as the value changes, while typing and when the input loses focus.{ 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 mirrors the native input’s validation (required, type, pattern, min/max, length). Enter submits the form. A page-level

Slots

NameDescription
labelCustom content for the input label. Defaults to the label property value.
helpHelp text content displayed below the input when not in an invalid state.
errorError message content displayed below the input when in an invalid state.

CSS Parts

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

CSS Properties

Set these on nbhd-input 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.

Input

PropertyTokenValue Copy
--nbhd-input-backgroundColor--nbhd-context-color-control-backgroundAdapts to surface
--nbhd-input-borderColor--nbhd-context-color-control-borderAdapts to surface
--nbhd-input-borderRadius--nbhd-border-radius-none0
--nbhd-input-borderStyle—solid
--nbhd-input-borderWidth--nbhd-border-width-subtle1px
--nbhd-input-focus-outlineColor--nbhd-context-color-focus-outlineAdapts to surface
--nbhd-input-focus-outlineOffset--nbhd-space-00px
--nbhd-input-focus-outlineStyle--nbhd-focus-control-outlineStylesolid
--nbhd-input-focus-outlineWidth--nbhd-border-width-subtle1px
--nbhd-input-fontFamily--nbhd-typography-body-fontFamilysans-serif
--nbhd-input-fontSize--nbhd-typography-body-fontSize1rem
--nbhd-input-host-display—block
--nbhd-input-inlineSize—100%
--nbhd-input-lineHeight--nbhd-typography-body-lineHeight1.5
--nbhd-input-paddingBlock--nbhd-space-28px
--nbhd-input-paddingInline--nbhd-space-312px

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

Dependencies

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

Used by

Esc
↑ ↓ to move↵ to open