Skip to content

BbColorInput

Edit a hex colour in a form: a masked field with a built-in picker.

import { BbColorInput } from 'bitboss-ui';

On this page

Use it for

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

Use something else when

  • BbColorPalette, when colour is assigned from a trigger you own
  • BbSelect, when users must choose from a closed palette

Also see: Validated forms.

Passthrough

Hover or tap a part to outline it. The toggles turn on loading, errors and warnings where the component has them; only parts get a row.

Guidance while the control is focused.

Edit a label colour

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, and a partial hex left in the field reverts to the last valid colour on blur, so the field, the model and a native form post always agree. The field keeps the case you type until you leave it, then shows the lowercase value it emitted.

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.

Stored as #RRGGBBAA.
  • 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, with nothing logged (test 'EyeDropper' in window if your UI must say so), and sampled colours are opaque.
Coming from v2picker → eye-dropper

picker became eye-dropper. The old attribute falls through to $attrs and has no effect; a development build warns about the rename, and npx bitboss-ui check --fix rewrites it.

Validation and locked values

Validate presence and business rules, not hex syntax: the mask already owns the format. Save the theme with no brand colour to see the rule.

Workspace theme

Managed by your organization.

Inside a BbForm, rules="required" flags an empty field when you leave it or submit; outside a form, pass required for the asterisk and errors yourself. A colour that only drives a preview, and is not saved with the form, takes formless.

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

variant="none" drops every colour, focus ring included, for a field you style yourself, like the flat search field on BbTextInput.

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.

Brand

Applied to buttons and links in your customer portal.

Book a demo View pricing

All changes saved.

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

Settings rows and the mobile sheet

In a settings column, compact rows with the same layout ratio line the swatches up (Variants, density and layout explains both). With adaptive (the default), only the picker becomes a bottom sheet below config.mobileMaxWidth; the text field does not change.

Narrow the window below 768px and open a swatch to get the bottom sheet.

Below the same breakpoint the rows switch to vertical: layout takes a per-breakpoint map, { default: 'vertical', md: 'xx xxxxx' }, with no screen-size code of yours. The surface is chosen when it opens. Use off-canvas-props for sheet controls and pt:sheet for sheet-only geometry.