Skip to content

Shows contextual status messages.

import { BbAlert } from 'bitboss-ui';

On this page

Props

NameDescription
ariaLive Type: "off" | "polite" | "assertive"

ARIA live region politeness. Unset, it follows role when you set one ('alert' → 'assertive', 'status' → 'polite'), else the variant: 'assertive' for destructive/warning, otherwise 'polite'.

Only override it when visual tone and urgency come apart — a quiet outline alert that still has to interrupt. A registered custom variant is polite whatever its name, so urgent instances of one need this set by hand.

See example
closeLabel Type: string

Visually hidden string used to label the close button.

Defaults to a localised "Close" from the plugin locale. Worth setting as soon as a page carries more than one dismissible alert, so the two buttons do not read the same to a screen reader.

See example
hideClose Type: booleanDefaultfalse

Defines whether to hide the close button.

The only way to make an alert permanent: an unbound alert is still dismissible, because the internal model starts at true. Replaces v2 show-close, with the polarity inverted.

See example
hideIcon Type: booleanDefaultfalse

Hide the icon, its own or its variant's; with neither it does nothing.

icon Type: string

Name of a registered icon to use, or a full raw <svg> string (e.g. an SVG file imported with ?raw). Without one, the variant's icon from the build plugin's alertVariants object form shows (none by default).

No variant implies an icon — pass one, and pick it together with the variant. It reinforces the message; title and text still have to carry it alone.

See example
iconSize Type: number | CssSize | keyof SizesDefault"16"

Size of the icon to use.

modelValue Type: booleanDefaulttrue

Used by v-model. Alerts are visible on mount; the model dismisses them.

pt Type: PtMap<BbAlertPtPart, "outline" | "primary" | "destructive" | "warning">

Passthrough, object form: 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: close, icon, root, text, title. States: destructive, outline, primary, warning.

See example
role Type: "alert" | "status"

Accessibility role for the alert container. Defaults to 'alert' for destructive/warning variants, otherwise 'status'.

Derived from the variant, so setting it is a deliberate disagreement with that derivation. Reserve alert for genuinely urgent messages: several assertive alerts appearing together talk over each other.

See example
text Type: string

Text content of the alert body.

For when a string is all you have — a server message, an item in a v-for. When the body is written in the template, the default slot reads better and wins over this prop.

See example
title Type: string

Text content of the alert title.

transitionDuration Type: numberDefault250

Transition duration in milliseconds for enter/leave.

variant Type: keyof AlertVariantRegistryDefault"outline"

Visual variant of the alert.

An open registry, not a closed enum: alertVariants in the plugin config adds typed names, which then ship no CSS of their own. There is no success or info: a confirmation is usually a toast and a neutral note is outline with an icon; register one when the app needs it and colour it from --bb-success / --bb-info.

See example

v-model

Values kept in sync through v-model.

NameDescription
modelValue Type: boolean

A boolean that starts at true: the alert is visible on mount and the close button sets it to false, bound or not. Set it back to true and the alert re-enters with the same transition.

See example

Events

NameDescription
update:modelValue Type: (value: boolean): void

Emitted with the new value whenever v-model changes.

Slots

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

NameDescription
default Type: any

The alert body, the shortest form: <BbAlert>Something went wrong</BbAlert>. The most specific source wins: #text > children > the text prop.

text Type: BbAlertTextSlotProps

Replaces the default alert body text. Wins over children and text.

Receives { text }, the value of the text prop, so it can decorate the string instead of restating it. Precedence for the body, most specific first: #text, child content, the text prop.

See example
title Type: BbAlertTitleSlotProps

Replaces the default alert title text.

See example

Renamed and removed

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

  • showClosehideClosefails silently
  • themevariantfails silently