Skip to content

BbTextInput

Captures single-line text values.

import { BbTextInput } from 'bitboss-ui';

On this page

Props

NameDescription
append:icon Type: string

Name of the icon to be added at the end of the input.

The append icon position shows one thing at a time, by priority: clear button, then spinner, then the error or warning icon, then this. On a clearable or validated field it disappears as soon as there is a value to clear or an error to show. Put anything that must stay visible in append:outer.

See example
autocomplete Type: string

Guides to the browser as to the type of information expected in the field.

Set it on every field in an auth or checkout flow. Search and filter boxes need autocomplete="off" just as much: they are text inputs on a page that has seen a login, so the browser offers a saved email over the results being filtered.

See example
autofocus Type: Booleanish

Focuses the field when it mounts (a dialog already open included), unless the user is typing in another field.

The replacement for the template-ref API v3 removed: there is no exposed focus() / blur() / select(), and a leftover call is undefined at runtime rather than a compile error. Use at most one per view. For anything more, take the native <input> through pt:input (attrs: { ref }).

See example
clearable Type: booleanDefaultfalse

Displays a clear button when the input has a value and is being interacted with.

There is no clear event: the button emits null through the model, so watch the model instead. Suppressed on disabled and readonly fields, and never worth rebuilding in an append slot.

See example
compact Type: booleanDefaultfalse

Compact density: the field uses the -compact twins of --bb-input-h, --bb-input-py and --bb-label-spacing-y, so a --bb-input-h set on the component is ignored while it is on. Size a compact field with --bb-input-h-compact (and --bb-input-py-compact).

A property of a view, not of a field. Two densities in one form read as a seam.

See example
counter Type: booleanDefaultfalse

Shows a character count at the end of the hint row: 42, or 42 / 140 with the native maxlength (which also stops input). It brightens from 90 % and takes the warning colour at the limit; screen readers hear it only when it crosses 90 % or the limit.

description Type: string

Text between the label and the input. Unlike the hint it is always visible; it joins the input's aria-describedby after any errors / warnings, before the hint.

Always visible, and read before typing: the place for an instruction. hint is the one that speaks while the field has focus.

See example
disabled Type: booleanDefaultfalse

Disables the component.

Blocks the keyboard too, so a disabled value is unreachable for someone navigating that way. Prefer readonly for derived or provisioned values.

See example
emitMasked Type: booleanDefaultfalse

Emits the masked value of the input.

Off by default, so the model holds the digits while the field shows the separators. Turn it on when the formatted string is the value you store, and do not strip formatting server-side that was never sent.

See example
errors Type: string | string[]

Error messages under the field, a string or array, in an aria-live="polite" region and first in the control's aria-describedby, so they are re-read when it regains focus.

A non-empty value implies the error state, so has-errors is only for when the message lives elsewhere. Rendered in an aria-live region and referenced first from aria-describedby, so it is announced on change and re-read on focus.

See example
formless Type: booleanDefaultfalse

Keep this control out of the enclosing BbForm entirely: not submitted, not dirty, not reset, not validated. For a control that is not form data (a filter, a "show advanced" switch).

For a field inside a BbForm that is not form data, such as a filter above a list. Without it, a field with no name joins the form under its label slug.

hasErrors Type: booleanDefaultfalse

Define if the component should be in an error state. It usually attaches a CSS class for styling purposes.

Sets aria-invalid and the error chrome without a message, for a field whose error is reported by a form-level summary.

See example
hasWarnings Type: booleanDefaultfalse

Define if the component should be in a warning state. Same chrome as errors with --bb-warn; errors take priority.

The warning counterpart of has-errors: amber chrome, no aria-invalid. Errors win when both states are set.

See example
hideLabel Type: booleanDefaultfalse

Visually hides the label of the input while maintaining accessibility.

Keeps the accessible name and removes only the visible text. It is the answer for a search box that shows just a placeholder; omitting label is not the same thing and never is.

See example
hint Type: string

Text box to be displayed near the input, usually to indicate instructions.

Shown while the field has focus, unless persistent-hint keeps it. A form where every field carries permanent text below it is a form nobody reads.

See example
id Type: string

The id of the native control; the label's for and the description and message ids derive from it. Generated when omitted.

inputAlign Type: FieldCrossAlign

Vertical position of the control in a side-by-side row; not inputPosition, the horizontal one. Omitted, the control's first line meets the label's.

inputMode Type: "text" | "none" | "search" | "tel" | "url" | "email" | "numeric" | "decimal"

The inputmode of the input.

Steers the mobile keyboard independently of type: that is how a masked code field stays type="text" and still gets a number pad.

See example
label requiredType: string

Text content of the label of the element.

Required, and display and accessibility only: it does not set the name attribute. Hide it with hide-label rather than dropping it.

See example
labelAlign Type: FieldCrossAlign

Vertical position of the label block in a side-by-side row; not labelPosition, the horizontal one. Omitted, the label's first line meets the control's.

labelMode Type: "outside" | "floating" | "inside"

Label rendering mode.

A bare floating attribute is not a prop and never was: it falls through $attrs and does nothing. The spelling is label-mode="floating". Unset, the value comes from defaultInputLabelMode in the plugin config, so a project can float every field without touching call sites.

See example
labelPosition Type: "left" | "center" | "right"

Sets the text alignment of the label.

layout Type: Responsive<FieldLayout>

How label and input sit together: 'vertical', 'horizontal' (50/50), 'auto', 'label-fill', 'input-fill', a ratio like 'xx xxxxx', or a per-breakpoint map ({ default: 'vertical', md: 'xx xxxxx' }).

Applies only while the resolved label mode is outside. floating and inside embed the label in the field and force the vertical layout, ignoring this without a warning. Check defaultInputLabelMode before concluding the prop is broken.

See example
loading Type: booleanDefaultfalse

Sets the component in a loading state, usually triggering some visual styles.

Visual only: the field stays editable. If the value must not change while an async check runs, write that guard yourself and tag requests so a stale response cannot overwrite a newer one.

See example
mask Type: MaskInputOptions

A maska options object, not a string: { mask: '#### #### #### ####' }. Please visit https://beholdr.github.io/maska/v3 for syntax examples.

A maska config, live-reactive: changing the options reformats the current value. Masks format, they do not validate: a complete-but-wrong value still needs an error.

See example
modelValue Type: string | null

Used by v-model.

name Type: string

Defines the name of the input.

Unset, the rendered <input> carries no name at all, so a native form post or a FormData read drops the value silently. label does not fill this in.

See example
nullValue Type: E

What the field emits once emptied (typing, the clear button, an empty mask): 'null' emits null, 'string' emits ''. Unset: formControls.textInputNullValue ('null'). With 'string', the update:modelValue payload types as string.

persistentHint Type: booleanDefaultfalse

Keeps the hint displayed.

placeholder Type: string

Text shown while the field is empty.

prepend:icon Type: string

Name of the icon to be added at the start of the input.

pt Type: (PtMap<BbTextInputPtPart, BbTextInputPtState> & { "root:outline"?: PtValue | undefined; "icon:outline"?: PtValue | undefined; "root:secondary"?: PtValue | undefined; "icon:secondary"?: PtValue | undefined; "spinner:outline"?: PtValue | undefined; "spinner:secondary"?: PtValue | undefined; "clear:outline"?: PtValue | undefined; "clear:secondary"?: PtValue | undefined; "root:ghost"?: PtValue | undefined; "icon:ghost"?: PtValue | undefined; "spinner:ghost"?: PtValue | undefined; "clear:ghost"?: PtValue | undefined; "label:outline"?: PtValue | undefined; "label:secondary"?: PtValue | undefined; "label:ghost"?: PtValue | undefined; "description:outline"?: PtValue | undefined; "description:secondary"?: PtValue | undefined; "description:ghost"?: PtValue | undefined; "message:outline"?: PtValue | undefined; "message:secondary"?: PtValue | undefined; "message:ghost"?: PtValue | undefined; "hint:outline"?: PtValue | undefined; "hint:secondary"?: PtValue | undefined; "hint:ghost"?: PtValue | undefined; "input:outline"?: PtValue | undefined; "input:secondary"?: PtValue | undefined; "input:ghost"?: PtValue | undefined; "box:outline"?: PtValue | undefined; "box:secondary"?: PtValue | undefined; "box:ghost"?: PtValue | undefined; "prefix:outline"?: PtValue | undefined; "prefix:secondary"?: PtValue | undefined; "prefix:ghost"?: PtValue | undefined; "suffix:outline"?: PtValue | undefined; "suffix:secondary"?: PtValue | undefined; "suffix:ghost"?: PtValue | undefined; })

Passthrough, object form: { box: '…', 'box:errors': '…' } — the same keys as the pt:* attributes without the prefix. See the pt:<part> row.

pt:<part> Type: PtValue

Passthrough, attribute form: one attribute per part, pt:<part>, and per part and state, pt:<part>:<state>. Parts: box, clear, counter, description, hint, icon, input, label, message, prefix, root, spinner, suffix. States: atLimit, disabled, errors, ghost, hasValue, loading, nearLimit, outline, readonly, secondary, warnings.

See example
readonly Type: booleanDefaultfalse

Sets the input in a readonly state.

Keeps the value focusable, selectable and copyable while refusing edits: the right choice for a value the user did not set but may need to read or copy.

See example
required Type: booleanDefaultfalse

Sets the native required attribute, for a plain <form>. Inside a BbForm it is an error (nothing enforces it): use rules="required" or the form schema instead.

Forwards to the native input for the browser's own validation. It does not produce a message: errors still owns that.

See example
reverse Type: booleanDefaultfalse

Reverses the layout. Applicable in every direction the order of the label and the input is swapped.

rules Type: RuleExpression<string | null>

vee-validate rules for this field. Only inside a BbForm.

Read only inside a BbForm; outside one the field is plain and the rules do nothing. Whatever you pass to errors is merged with the rule messages rather than replaced.

See example
type Type: "text" | "search" | "tel" | "url" | "email" | "password"Default"text"

Type of the input. Restricted to the textual input types this component supports — use BbNumberInput for numbers and BbDatePickerInput for dates.

Narrowed in v3 to the text-like types. type="number" and type="date" no longer compile; those values move to BbNumberInput and BbDatePickerInput. There is no revealable: a password toggle is a type that changes plus a button in #append.

See example
validationLabel Type: string

The field's name in validation messages ({field}): "Email is not valid". Defaults to the label (or legend), then "This field"; never the name. Set it when the label is hidden or reads badly in a sentence (icon-only, a question). BbForm only.

validationMode Type: ValidationMode

When the field validates: aggressive (each change), balanced (on leave, then live while in error), lazy (on leave), submit-only, submit-live. Unset: the BbForm's validation-mode, then formControls.validationMode ('balanced'). BbForm only.

See example
variant Type: InputVariantTypeDefault'outline'

The field box's look, with BbButton's names and tokens. Colours only, so a form never reflows; 'ghost' has no border in any state, 'none' no look at all (you own hover, focus and the states). Register more with the plugin's inputVariants.

warnings Type: string | string[]

Warning messages under the field, a string or array: amber, in their own aria-live region and in the control's aria-describedby after the errors. Non-empty turns on the warning state; errors win when both are set.

The amber channel, for a value that is accepted and still worth a second look. Unlike errors it does not set aria-invalid, and it is suppressed entirely when the field also has errors.

See example

v-model

Values kept in sync through v-model.

NameDescription
modelValue Type: string | null

string | null: an emptied field emits null, or '' when the plugin option formControls.textInputNullValue says so. Inside a BbForm the binding is optional: the form holds the value under name.

See example

Events

NameDescription
blur Type: (event: FocusEvent): void

Emitted when the native input loses focus. Forwards the original DOM FocusEvent.

change Type: (event: Event): void

Emitted when the native input fires a change event. Forwards the original DOM Event.

Fires on commit (blur or Enter), which makes it the right hook for an expensive side effect. input fires on every keystroke.

click Type: (event: MouseEvent): void

Emitted when the input receives a click interaction. Forwards the original DOM MouseEvent.

compositionend Type: (event: CompositionEvent): void

Emitted when a composition session ends (e.g. CJK IME confirmed). Forwards the original DOM CompositionEvent.

compositionstart Type: (event: CompositionEvent): void

Emitted when a composition session starts (e.g. CJK IME begins). Forwards the original DOM CompositionEvent.

focus Type: (event: FocusEvent): void

Emitted when the native input gains focus. Forwards the original DOM FocusEvent.

input Type: (event: Event): void

Emitted on native input events from the text field. Forwards the original DOM Event.

keydown Type: (event: KeyboardEvent): void

Emitted for keyboard interaction on the input. Forwards the original DOM KeyboardEvent.

keyup Type: (event: KeyboardEvent): void

Emitted when a key is released over the input. Forwards the original DOM KeyboardEvent.

mousedown Type: (event: MouseEvent): void

Emitted when a pointing device button is pressed over the input. Forwards the original DOM MouseEvent.

mouseup Type: (event: MouseEvent): void

Emitted when a pointing device button is released over the input. Forwards the original DOM MouseEvent.

paste Type: (event: ClipboardEvent): void

Emitted when content is pasted into the input. Forwards the original DOM ClipboardEvent.

update:modelValue Type: (value: string | NullValueOf<E>): void

Emitted when the value changes. Carries the new string, or the empty value (null-value, else the app's, null by default) when emptied. When mask is set, emits the masked or unmasked string depending on emitMasked.

Slots

The listed properties are the ones exposed to the slot scope.

NameDescription
append Type: object

Content rendered after the text input, at the end of the field box.

append:outer Type: object

Content rendered after the entire text input control, outside the input chrome.

Outside the field chrome, and the only affix position that may hold something interactive.

See example
description Type: BbTextInputDescriptionSlotProps

Replaces the description text. Provided alone (no description prop) it still renders the description region and wires it into aria-describedby.

label Type: BbTextInputLabelSlotProps

Replaces the default label text rendered above the input.

Receives { text, hasErrors, hasWarnings }, plus showAsterisk while the required marker shows, so a custom label can react to the field state. Replacing the label also replaces the marker: put it back with <BbAsterisk v-if="showAsterisk" />, or unconditionally on a required field in an app that turned requiredAsterisk off.

See example
prefix Type: object

Inline content rendered at the start of the input field area, before the typed text.

Short inline text at the inner edge of the box, beside the value. Affixes never take focus, so a click here lands in the input: a small button belongs in #append, a larger one in append:outer.

See example
prepend Type: object

Content rendered before the text input, at the start of the field box.

prepend:outer Type: object

Content rendered before the entire text input control, outside the input chrome.

suffix Type: object

Inline content rendered at the end of the input field area, after the typed text.

See example

Renamed and removed

Names from v2 and from earlier 3.0 betas that no longer work, and what to write instead.

  • slotappend-outerappend:outerfails silently
  • methodblurremovedfails silently

    No template-ref API in v3. Reach the <input> through pt: :pt="{ input: { attrs: { ref: (el) => (input = el) } } }", then input.blur() on that element; autofocus for focus on mount.

  • directionlayoutfails silently
  • methodfocusremovedfails silently

    No template-ref API in v3. Reach the <input> through pt: :pt="{ input: { attrs: { ref: (el) => (input = el) } } }", then input.focus() on that element; autofocus for focus on mount.

  • hasWarninghasWarningsfails silently
  • slotprepend-outerprepend:outerfails silently
  • methodselectremovedfails silently

    No template-ref API in v3. Reach the <input> through pt: :pt="{ input: { attrs: { ref: (el) => (input = el) } } }", then input.select() on that element; autofocus for focus on mount.

  • validateOnvalidationModefails silently

    An array of events became one mode (aggressive | balanced | lazy | submit-only | submit-live). The old defaults (['blur'], ['inactive'], a toggle's ['update:modelValue', 'change', 'blur']) are balanced, the new default: delete the prop. A text field on ['update:modelValue'] is validation-mode="aggressive". Set it once on <BbForm validation-mode> instead of per field.

  • vidremovedfails silently

    A display name (v2: vid="Email address") is now validation-label; a field path (3.0 betas: vid="address.city") is now name (brackets for a native post: address[city]). check --fix picks by the value.