Skip to content

Text Input

Last updated 24 Nov 2026

NbTextInput is the primary text entry component. It wraps a native <input> or <textarea> with a label, validation messages, two layout variants, and four sizes. It is designed to sit flush on the same grid line as buttons and other form controls.

Variants ​

The variant prop controls how the label and messages are positioned relative to the field box.

Default ​

Label sits above the field, message below. Standard form layout.

Fluid ​

The label sits inside the field box. While the field is empty and idle it rests where a placeholder would be, and the moment the field has a value or focus it steps up and shrinks above the value. A placeholder shows only once the label has stepped aside. The message is an icon at the end of the value line. The field keeps the height of its size, as NbSelect, NbNumberInput and NbDatePicker do in fluid, so a row of them lines up.

At sm (32px), for a filter bar or a toolbar:

vue
<NbTextInput v-model="name" variant="fluid" size="sm" label="Name" />

A floated label and its value need two lines, which 24px cannot hold, so a fluid field draws xs at sm. The label moves on transform on the quick motion step, and with reduced motion it moves without travel.

vue
<template>
  <NbTextInput v-model="value" variant="fluid" label="Label" />
</template>

Multiline ​

Set multiline to render a <textarea>. Use rows to control the initial height.

vue
<template>
  <NbTextInput v-model="value" label="Notes" multiline :rows="4" />
</template>

Leading icon ​

The #leading slot puts an icon before the text, for a search field or a field whose kind an icon says faster than a label. The slot is padded to where the text would otherwise start, so the icon lines up with the placeholders of the fields above and below it, and the text follows the icon by 8px. A multiline field keeps the icon on its first line. Without the slot, nothing about the field changes.

For a full search control (clear on Escape, an expandable mode for toolbars) use NbSearch, which is built this way.

vue
<NbTextInput
  v-model="query"
  label="Search the docs"
  placeholder="Search docs"
  size="lg"
>
  <template #leading>
    <NbIcon name="magnifying-glass" :size="20" />
  </template>
</NbTextInput>

Drop your own spacing

Before this release the slot had no padding, and the icon touched the field's left edge. If you added a margin to the icon to make up for it, remove it now, or the gap doubles.

Inline actions slot ​

Use the #actions slot to place buttons inside the field at the trailing edge (default variant only). An action is an icon-only NbButton, ghost, with a label: the label is its accessible name and its tooltip, so it never needs an aria-label or a tooltip of its own. Pass the icon as icon, never an NbIcon in the slot.

vue
<template>
  <NbTextInput v-model="value" label="AI Translate">
    <template #actions>
      <NbButton variant="ghost" size="sm" icon="sparkle" label="Translate" />
    </template>
  </NbTextInput>
</template>

Clear and password reveal ​

clearable shows an x button once the field has a value. It empties the field, emits clear and keeps focus in the field, and Escape does the same. revealable on a type="password" field puts an eye at the far right that shows and hides the characters. Both buttons are named from the string catalogue (textInputClear, textInputShowPassword, textInputHidePassword).

Both variants have them. In fluid they sit at the trailing edge of the box and take the field's size, as in the default variant.

vue
<template>
  <NbTextInput v-model="name" label="Project name" clearable />
  <NbTextInput
    v-model="password"
    label="Password"
    type="password"
    revealable
    autocomplete="new-password"
  />
  <NbTextInput v-model="name" variant="fluid" label="Project name" clearable />
</template>

Suggestions ​

The #dropdown slot holds a popup anchored to the field. For autocomplete (an @mention, a reference, a tag) put an NbSuggestionList in it: it takes the keyboard from the field and makes it a combobox, so you only decide when it opens and what it offers.

Props ​

PropTypeDefaultDescription
modelValuestring | number''Bound value (v-model)
variant'default' | 'fluid''default'Layout variant
size'xs' | 'sm' | 'md' | 'lg''md'Field height: 24, 32, 40 or 48px, the same as NbButton
typestring'text'Native input type
labelstring-Label text
placeholderstring-Input placeholder
helperstring-Helper message (shown when no error or warning)
errorstring-Error message: highest priority
warningstring-Warning message: priority over helper
requiredbooleanfalseMarks field as required (adds asterisk)
disabledbooleanfalseDisables the input
readonlybooleanfalseMakes the input read-only
multilinebooleanfalseRender a <textarea> instead of <input>
rowsnumber-Initial textarea row count (multiline only)
idstringautoExplicit input ID
namestring-Native name attribute
maxlengthnumber-Maximum character length
showCountbooleanfalseShows 12/200 under the field when maxlength is set
clearablebooleanfalseA clear button while there is a value, and Escape clears
revealablebooleanfalseWith type="password", an eye button that shows the characters

Events ​

EventPayloadDescription
update:modelValuestring | numberEmitted on every keystroke
clear-The clear button or Escape emptied the field

Slots ​

SlotDescription
labelCustom label content (replaces the label prop text)
leadingAn icon before the text, padded to where the text would start (default variant only)
actionsButtons or icons rendered at the trailing edge (default only)
dropdownA popup anchored to the field, such as an NbSuggestionList

Exposed ​

NameTypeDescription
focus() => voidFocuses the input
blur() => voidBlurs the input
nativeElRef<HTMLInputElement | HTMLTextAreaElement>The native field, for the caret position