Skip to content

BbColorInput

Captures color values through input controls.

import { BbColorInput } from 'bitboss-ui';

On this page

Props

NameTypeDefaultDescription
adaptiveboolean | undefined`config.adaptive` (`true`)

When true, the color palette opens as a bottom off-canvas sheet on mobile viewports instead of a floating popover; on desktop it stays a popover. Mirrors the adaptive behaviour of BbSelect/BbDatePickerInput. When unset, falls back to the global config.adaptive.

Only the picker adapts: below config.mobileMaxWidth it opens as a bottom sheet instead of a popover, and the text field is untouched. The surface is latched when the picker opens, so a mid-open resize never swaps one for the other.

See example
alphaboolean | undefinedfalse

Enable the alpha channel. Shows an opacity slider and uses #RRGGBBAA hex8 format.

It widens the mask as well as the picker, which is why an incoming #RRGGBBAA value cannot be represented without it. Turn it on wherever eight-digit colors can occur — and expect every emitted value to carry the two extra digits, ff included.

See example
append:iconstring | undefined-

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

The append position is where the swatch dot already lives, and the clear button and error icon compete for it too. Anything that must stay visible belongs in append-outer.

See example
autocompletestring | undefined"off"

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

autofocusBooleanish | undefined-

Sets autofocus on page load.

clearableboolean | undefinedfalse

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

Emits null, which is the only value other than a complete hex this model ever holds. There is no clear event — watch the model.

See example
compactboolean | undefinedfalse

Displays the component in a compact version.

See example
descriptionstring | undefined-

Descriptive text displayed below the label and above the input. Unlike the hint it is always visible, and it is linked to the input via aria-describedby (after any errors / warnings, before the hint).

See example
directionInputDirection | undefined-

Direction of the layout of the component. Can either be a predefined value or a pattern separated by a space like xx xxxxx.

Worth reaching for on a settings page, where a column of colors reads better as label-then-swatch rows. As everywhere in the family it applies only while the resolved label mode is outside.

See example
disabledboolean | undefinedfalse

Disables the component.

Blocks the picker dot as well as the text. For an imported or derived color prefer readonly, which keeps the value focusable and copyable.

See example
errorsstring | string[] | undefined-

Can be a string or an array of string containing the messages to display. They render in an aria-live="polite" region (announced when they appear) and, while the list is non-empty, are referenced FIRST from the control's aria-describedby, so the reason the field is invalid is re-read whenever the control regains focus.

The mask guarantees the shape, so "that is not a color" is not an error this field can produce. What is left is presence — a null check on submit — and rules that live on your server.

See example
eyeDropperboolean | undefinedfalse

Show an eyedropper button to sample any color on screen. Uses the native EyeDropper API — hidden automatically on unsupported browsers.

The button renders only where the browser implements the native EyeDropper API — Chromium-based browsers, not Firefox or Safari — and is simply absent elsewhere, with nothing in its place. Never the only path to a color. Called picker in v2; a leftover picker falls into $attrs and does nothing.

See example
hasErrorsboolean | undefinedfalse

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

hasWarningsboolean | undefinedfalse

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

hideLabelboolean | undefinedfalse

Visually hides the label of the input while maintaining accessibility.

hintstring | undefined-

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

See example
idstring | undefined-

The identifier of the component.

labelrequiredstring-

Text content of the label of the element.

Required, and display and accessibility only — it does not set the name attribute. hide-label is how you drop it visually without losing the accessible name.

See example
labelMode"outside" | "floating" | "inside" | undefined-

Label rendering mode: outside places the label above the input, floating overlays it on the field and shrinks it when a value is set, inside keeps it inside the field.

labelPosition"left" | "center" | "right" | undefined-

Sets the text alignment of the label.

loadingboolean | undefinedfalse

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

modelValuerequiredstring | nullnull

Used by v-model.

namestring | undefined-

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 color silently.

See example
offCanvasPropsPartial<BbOffCanvasProps> | undefined-

Props for the phone sheet. A pt inside it, object or colon keys, styles only that sheet. Extra props forwarded to the BbOffCanvas sheet when adaptive is active on mobile (e.g. size, persistent). Spread over the defaults: the sheet's title is the field label, it is draggable (the colour square and sliders never drag it) and it hides its ✕; pass { hideClose: false } to bring the ✕ back. A pt inside it styles ONLY the sheet, in BbOffCanvas's part words (root, header, title, description, content, footer, close; state open), object ({ pt: { header: '…' } }) or colon keys ({ 'pt:header': '…' }) alike. It merges after what this component forwards to its sheet, so it wins a conflict and drops nothing — see the passthrough guide § Inside the sheet. For this component it is the only way to style the sheet's header, title and ✕: none of its own parts reach inside the sheet.

persistentHintboolean | undefinedfalse

Keeps the hint displayed.

placeholderstring | undefined-

String displayed when there's no data.

prepend:iconstring | undefined-

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

pt(PtMap<BbColorInputPtPart, FormControlPtState> & { 'swatch:selected'?: PtValue | undefined; }) | undefined-

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

pt:boxPtValue | undefined-
pt:box:disabledPtValue | undefined-
pt:box:errorsPtValue | undefined-
pt:box:has-valuePtValue | undefined-
pt:box:loadingPtValue | undefined-
pt:box:readonlyPtValue | undefined-
pt:box:warningsPtValue | undefined-
pt:clearPtValue | undefined-
pt:clear:disabledPtValue | undefined-
pt:clear:errorsPtValue | undefined-
pt:clear:has-valuePtValue | undefined-
pt:clear:loadingPtValue | undefined-
pt:clear:readonlyPtValue | undefined-
pt:clear:warningsPtValue | undefined-
pt:descriptionPtValue | undefined-
pt:description:disabledPtValue | undefined-
pt:description:errorsPtValue | undefined-
pt:description:has-valuePtValue | undefined-
pt:description:loadingPtValue | undefined-
pt:description:readonlyPtValue | undefined-
pt:description:warningsPtValue | undefined-
pt:hintPtValue | undefined-
pt:hint:disabledPtValue | undefined-
pt:hint:errorsPtValue | undefined-
pt:hint:has-valuePtValue | undefined-
pt:hint:loadingPtValue | undefined-
pt:hint:readonlyPtValue | undefined-
pt:hint:warningsPtValue | undefined-
pt:iconPtValue | undefined-
pt:icon:disabledPtValue | undefined-
pt:icon:errorsPtValue | undefined-
pt:icon:has-valuePtValue | undefined-
pt:icon:loadingPtValue | undefined-
pt:icon:readonlyPtValue | undefined-
pt:icon:warningsPtValue | undefined-
pt:indicatorPtValue | undefined-
pt:indicator:disabledPtValue | undefined-
pt:indicator:errorsPtValue | undefined-
pt:indicator:has-valuePtValue | undefined-
pt:indicator:loadingPtValue | undefined-
pt:indicator:readonlyPtValue | undefined-
pt:indicator:warningsPtValue | undefined-
pt:inputPtValue | undefined-
pt:input:disabledPtValue | undefined-
pt:input:errorsPtValue | undefined-
pt:input:has-valuePtValue | undefined-
pt:input:loadingPtValue | undefined-
pt:input:readonlyPtValue | undefined-
pt:input:warningsPtValue | undefined-
pt:labelPtValue | undefined-
pt:label:disabledPtValue | undefined-
pt:label:errorsPtValue | undefined-
pt:label:has-valuePtValue | undefined-
pt:label:loadingPtValue | undefined-
pt:label:readonlyPtValue | undefined-
pt:label:warningsPtValue | undefined-
pt:messagePtValue | undefined-
pt:message:disabledPtValue | undefined-
pt:message:errorsPtValue | undefined-
pt:message:has-valuePtValue | undefined-
pt:message:loadingPtValue | undefined-
pt:message:readonlyPtValue | undefined-
pt:message:warningsPtValue | undefined-
pt:panelPtValue | undefined-
pt:panel:disabledPtValue | undefined-
pt:panel:errorsPtValue | undefined-
pt:panel:has-valuePtValue | undefined-
pt:panel:loadingPtValue | undefined-
pt:panel:readonlyPtValue | undefined-
pt:panel:warningsPtValue | undefined-
pt:prefixPtValue | undefined-
pt:prefix:disabledPtValue | undefined-
pt:prefix:errorsPtValue | undefined-
pt:prefix:has-valuePtValue | undefined-
pt:prefix:loadingPtValue | undefined-
pt:prefix:readonlyPtValue | undefined-
pt:prefix:warningsPtValue | undefined-
pt:rootPtValue | undefined-
pt:root:disabledPtValue | undefined-
pt:root:errorsPtValue | undefined-
pt:root:has-valuePtValue | undefined-
pt:root:loadingPtValue | undefined-
pt:root:readonlyPtValue | undefined-
pt:root:warningsPtValue | undefined-
pt:sheetPtValue | undefined-
pt:sheet:disabledPtValue | undefined-
pt:sheet:errorsPtValue | undefined-
pt:sheet:has-valuePtValue | undefined-
pt:sheet:loadingPtValue | undefined-
pt:sheet:readonlyPtValue | undefined-
pt:sheet:warningsPtValue | undefined-
pt:spinnerPtValue | undefined-
pt:spinner:disabledPtValue | undefined-
pt:spinner:errorsPtValue | undefined-
pt:spinner:has-valuePtValue | undefined-
pt:spinner:loadingPtValue | undefined-
pt:spinner:readonlyPtValue | undefined-
pt:spinner:warningsPtValue | undefined-
pt:suffixPtValue | undefined-
pt:suffix:disabledPtValue | undefined-
pt:suffix:errorsPtValue | undefined-
pt:suffix:has-valuePtValue | undefined-
pt:suffix:loadingPtValue | undefined-
pt:suffix:readonlyPtValue | undefined-
pt:suffix:warningsPtValue | undefined-
pt:swatchPtValue | undefined-
pt:swatch:disabledPtValue | undefined-
pt:swatch:errorsPtValue | undefined-
pt:swatch:has-valuePtValue | undefined-
pt:swatch:loadingPtValue | undefined-
pt:swatch:readonlyPtValue | undefined-
pt:swatch:selectedPtValue | undefined-
pt:swatch:warningsPtValue | undefined-
readonlyboolean | undefinedfalse

Sets the input in a readonly state.

Blocks the picker dot too, while the hex stays focusable, selectable and copyable. The honest state for a color that was imported rather than chosen.

See example
requiredboolean | undefinedfalse

Sets the input as required.

reverseboolean | undefinedfalse

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

swatchesboolean | string[][] | undefined-

Controls swatches display in the picker: - true — show the built-in Material-palette swatches - string[][] — show custom swatches (each inner array = a column of shades) - false / omitted — no swatches section

Each inner array is a **column** of shades, so ramps are designed vertically. A row-wise string[][] type-checks and renders a grid nobody can scan. Presets never restrict the value: the gradient and the text field stay available beside them.

See example
variantInputVariantType | undefined'outline'

Visual variant of the field box — the same names and tokens as the BbButton variants. Colours only: height, padding and border width are identical across variants, so a form never reflows when one changes. 'ghost' has no border in any state (errors and warnings show through the icon and the messages); every variant keeps the focus ring. Register extra names with the plugin's inputVariants option.

warningsstring | string[] | undefined-

Warning messages to display beneath the field, in their own aria-live region and amber (--bb-text-warn). A string or array; a non-empty list implies the warning state. Errors suppress warnings when both are set. While displayed they are also referenced from the control's aria-describedby, after any errors and before the description/hint.

v-model

Values kept in sync through v-model.

NameTypeDescription
modelValuestring | null

Hex only, lowercase on emit, and it moves only when the typed text is a complete color — or null when the field is emptied. Half-typed values never reach it, so nothing downstream needs to guard against one.

See example

Events

NameTypeDescription
blur(event: "blur", event: FocusEvent): void
change(event: "change", event: Event): void
click(event: "click", event: MouseEvent): void
compositionend(event: "compositionend", event: CompositionEvent): void
compositionstart(event: "compositionstart", event: CompositionEvent): void
focus(event: "focus", event: FocusEvent): void
hidden(event: "hidden"): void
hide(event: "hide"): void
input(event: "input", event: Event): void

The raw DOM event, fired per keystroke on text that may not be a color yet. Do not parse it — the model is the one that only ever holds a complete hex.

See example
keydown(event: "keydown", event: KeyboardEvent): void
keyup(event: "keyup", event: KeyboardEvent): void
mousedown(event: "mousedown", event: MouseEvent): void
mouseup(event: "mouseup", event: MouseEvent): void
paste(event: "paste", event: ClipboardEvent): void
show(event: "show"): void
shown(event: "shown"): void
update:modelValue(event: "update:modelValue", value: string | null): void

Fires on every drag frame while someone is inside the picker, so a live preview is free and a save on this event is not. Debounce persistence, or hang it on blur or on submit.

See example

Slots

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

NameTypeDescription
appendRecord<string, never>

Content rendered after the color picker indicator button, at the end of the inner container. Mutually exclusive with suffix: the suffix slot renders inside this slot's default content, so providing append replaces the suffix rendering entirely and any suffix content is silently dropped. This slot receives no scoped props.

Renders after the swatch dot the component draws there, and replaces the default suffix wrapper. For an action beside the field use append-outer, which nothing competes for.

See example
append-outerRecord<string, never>

Content rendered after the entire input control, outside the input chrome. This slot receives no scoped props.

descriptionBbColorInputDescriptionSlotProps

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

labelBbColorInputLabelSlotProps

Replaces the default label text rendered above the color input.

prefixRecord<string, never>

Inline content rendered at the start of the input field area, before the typed text. This slot receives no scoped props.

prependRecord<string, never>

Content rendered before the text input, at the start of the inner container. This slot receives no scoped props.

prepend-outerRecord<string, never>

Content rendered before the entire input control, outside the input chrome. This slot receives no scoped props.

suffixRecord<string, never>

Inline content rendered at the end of the input field area, after the typed text. Renders inside the default append area's suffix wrapper — mutually exclusive with append: if an append slot is provided it replaces this wrapper and the suffix content is not rendered. This slot receives no scoped props.

Changes from v2

Props removed or renamed in 3.0. If you are coming from v2, the answer is here.

  • hasWarninghasWarningsfails silently
  • pickereyeDropperfails silently