Skip to content

BbColorInput

Edit a hex color in a form, with a masked field and an optional picker.

import { BbColorInput } from 'bitboss-ui';

On this page

Use it for

Use BbColorInput when color is an editable form value with a label, validation, and a readable hex representation.

Use something else when

  • BbColorPalette — color is assigned from a trigger you own
  • BbSelect — users must choose from a closed palette

Pass Through

Hover or tap a part to outline it. Toggles flip loading, errors and warnings when the component has them — only parts highlight.

$USDGuidance while the control is focused.

Edit a label color

Bind a seeded string | null model. The field emits only a complete lowercase #RRGGBB value, or null when cleared.

regression

Partial text never reaches the model. Convert rgb() or hsl() at your data boundary, and pass name when a native form post must include the value.

Picker options and limits

Add picker features together when the task needs them; they do not define separate field variants.

  • swatches takes true or string[][]; each inner array is a column.
  • alpha changes both the picker and model to #RRGGBBAA. Without it, an eight-digit input cannot round-trip.
  • eye-dropper is progressive enhancement. Its button is absent in Safari and Firefox, and sampled colors are opaque.
Coming from v2picker → eye-dropper

picker became eye-dropper. The old attribute falls through to $attrs and silently does nothing.

Validation and locked values

Validate presence and business rules, not hex syntax: the mask already owns the format.

Pick a brand color before saving.

readonly keeps an imported color focusable and copyable; disabled removes it from the tab order. Both block the picker. clearable emits null.

Application-owned persistence

Picker drags emit on every frame. Repaint a preview directly from the model, but debounce remote persistence or save on blur or form submit.

Model: #4f46e5

Do not parse the forwarded input event: it can contain partial text. The model is the validated channel.

Mobile picker

With adaptive (the default), only the picker becomes a bottom sheet below config.mobileMaxWidth; the text field does not change.

The surface is chosen when it opens. Use off-canvas-props for sheet controls and pt:sheet for sheet-only geometry.