Skip to content

NbField is a labeled row: a label and a control sharing one grid. A stack of NbFields lines up on a single spine automatically — no per-field CSS — which makes it the building block of an inspector or a settings panel. Wrap any control and it falls into place.

Basic ​

vue
<template>
  <NbField label="Name"><NbTextInput v-model="name" size="sm" /></NbField>
  <NbField label="Channel"
    ><NbSelect v-model="ch" :options="channels" size="sm"
  /></NbField>
</template>

Every field reads --nb-field-label-width, so fields share one label column. Set it on the container to shift the whole spine:

css
.my-panel {
  --nb-field-label-width: 8rem;
}

Stack a control ​

orientation="stack" puts the label on its own line above a full-width control — for a control that wants the whole width (a tall text area, a prominent slider), or a label too long to sit beside it.

Small controls: control="fit" ​

For a small control such as a switch, control="fit" lets the label run wide and pushes the control to the right edge, instead of squeezing the label into the fixed column.

Label association ​

The default slot receives a generated id; bind it to your control so the label points at it (or pass your own via labelFor):

vue
<NbField label="Name" v-slot="{ id }">
  <NbTextInput :id="id" v-model="name" />
</NbField>

Mixed controls align ​

Every form control puts the same vertical gap between its label and its field, so a row that mixes control types lines its field tops up to the pixel. The gap is one token, --nb-field-label-gap, shared by NbTextInput, NbDatePicker, NbSelect, NbNumberInput, NbSlider and NbField's stack mode. It holds with or without a helper line.

With a helper or error line under one of them, the field tops still align. The message only adds height below the field:

To tighten or loosen every control at once, override the token on a container:

css
.my-form {
  --nb-field-label-gap: 4px;
}

In an inspector ​

Inside a .nb-inspector container, NbField picks up the inspector treatment automatically — a compact spine, sliders that stack with full-width tracks, compact numeric steppers, and section highlighting. See Building an inspector.

Props ​

PropTypeDefaultDescription
labelstringundefinedLabel text. Omit and use the #label slot for a custom label.
hintstringundefinedHelper text shown under the control, muted.
orientation'row' | 'stack''row'row: label beside the control on the shared spine. stack: label on its own line, control below.
align'center' | 'start''center'Vertical alignment of the label against the control. start top-aligns against a tall control.
control'fill' | 'fit''fill'fill: control fills the value column. fit: control hugs its content and the label runs wide.
labelForstringundefinedId of the control the label points at. Defaults to an auto-generated id, also exposed to the slot.

Slots ​

SlotDescription
defaultThe control. Receives { id } — bind it to your control for a label association.
labelCustom label content, replacing the label prop.
hintCustom hint content, replacing the hint prop.