Skip to content

Input

The bq-input component is a fully accessible text input with label, error, hint, and prefix/suffix slot support.

Basic Usage

html
<bq-input label="Name" placeholder="John Doe" />

With Error

html
<bq-input
  label="Email"
  type="email"
  value="not-an-email"
  error="Please enter a valid email address"
/>

With Hint

html
<bq-input
  label="Password"
  type="password"
  hint="At least 8 characters, one uppercase letter"
/>

Password with Visibility Toggle

When type="password", the input automatically renders a toggle button that allows users to show or hide the password. The toggle uses localized labels from the i18n system (input.showPassword / input.hidePassword).

html
<bq-input label="Password" type="password" />

The toggle button:

  • Shows aria-pressed state reflecting visibility
  • Provides a localized aria-label for screen readers
  • Switches the input type between password and text

Character Counter

Use show-counter together with maxlength to display a character counter below the input. The counter uses the localized input.characterCount string.

html
<bq-input
  label="Username"
  maxlength="20"
  show-counter
/>

The counter:

  • Displays in the format "{count} of {max} characters"
  • Turns red when the character limit is exceeded
  • Includes aria-live="polite" for screen reader announcements
  • Is linked to the input via aria-describedby

Required Field

html
<bq-input label="Username" required />

Disabled & Readonly

html
<bq-input label="Read Only" value="Can't change this" readonly />
<bq-input label="Disabled" value="Disabled" disabled />

Sizes

html
<bq-input size="sm" placeholder="Small" />
<bq-input size="md" placeholder="Medium (default)" />
<bq-input size="lg" placeholder="Large" />

With Icons (Slots)

html
<bq-input label="Search" placeholder="Search…">
  <span slot="prefix">🔍</span>
</bq-input>

Properties

PropertyTypeDefaultDescription
labelstringInput label
typestringtextHTML input type
valuestringInput value
placeholderstringPlaceholder text
namestringForm field name
sizesm | md | lgmdInput size
disabledbooleanfalseDisables input
readonlybooleanfalseMakes input read-only
requiredbooleanfalseMarks as required
errorstringError message
hintstringHint / helper text
maxlengthstringMaximum character count
show-counterbooleanfalseShow character counter (requires maxlength)

Events

EventDetailDescription
bq-input{ value: string }Fired on each keystroke
bq-change{ value: string }Fired when value is committed
bq-focusFired on focus
bq-blurFired on blur

Slots

SlotDescription
prefixLeading icon/element inside the input
suffixTrailing icon/element inside the input

CSS Parts

PartDescription
fieldThe field wrapper
labelLabel text element
input-wrapThe input container with border
inputThe native input element
prefixPrefix slot wrapper
suffixSuffix slot wrapper
password-toggleThe password visibility toggle button
footerThe footer area below the input
errorError message element
hintHint text element
counterCharacter counter element

Accessibility

  • Links label to input via for/id
  • Sets aria-invalid when error is present
  • Links error/hint/counter to input via aria-describedby
  • Password toggle has aria-label and aria-pressed
  • Character counter uses aria-live="polite" for updates
  • Required mark is aria-hidden (label itself conveys required state)

Localization

The following i18n keys are used:

KeyDefaultUsage
input.showPassword"Show password"Password toggle label (hidden state)
input.hidePassword"Hide password"Password toggle label (visible state)
input.characterCount"{count} of {max} characters"Character counter text

Released under the MIT License.