Skip to content

BbDropdown

Displays contextual action menus and menu content (includes the co-located BbDropdownBinding export, which is how a selectable group is bound).

import { BbDropdown } from 'bitboss-ui';

On this page

Props

NameDescription
activator Type: ElementOrComponentRef

An external activator (element or component ref): the slot isn't rendered; the listeners and ARIA (aria-haspopup / aria-expanded / aria-controls) go on it, so don't add your own.

The no-wrapper alternative to the activator slot, for when you already hold an element or component ref. It gets the same aria-haspopup / aria-expanded / aria-controls attached programmatically — so do not hand-write those on the referenced element either.

See example
adaptive Type: booleanDefaultall.adaptive (true)

On mobile (below config.mobileMaxWidth), the menu is a bottom sheet drilling into submenus a level at a time, not hover flyouts; slots and selection unchanged. Unset: the global all.adaptive.

Unset resolves to the global adaptive config, which is true: on a small viewport the menu is a bottom sheet, not a flyout. Pin it false for a desktop-only dense tool, or for a test that asserts against one surface.

See example
anchor Type: ElementOrComponentRef | VirtualAnchorDefaultthe activator element

What the panel positions against instead of the activator (e.g. a wrapper around it): an element, a component ref or a virtual box. It also sets a percentage width. Ignored with placement="cursor".

Positions the panel against something other than the trigger — the case being a control whose trigger is only part of it, like the toggle half of a split button. A percentage width then resolves against the anchor too. Ignored when placement is cursor.

See example
boundary Type: string | ElementOrComponentRef

Keeps the panel inside this element beside its trigger (sideways under a menu); away from it only the viewport flips it. An element, component ref or CSS selector (a useTemplateRef, not $refs.x). In a BbTable: its left and right edges.

closeOnSelect Type: booleanDefaultunset (close after a single-choice change)

Whether a selection closes the menu. Unset: a single-choice group's change closes it (an untick too, any depth), a multiple group stays open. true: every change closes it; false: none.

compact Type: boolean

Compact density, the BbSelect ladder: flyout rows 28 → 24px, sheet rows 44 → 36px (still a touch target). The label size stays.

See example
disabled Type: booleanDefaultfalse

Disables the component

Freezes the whole component, trigger included. It is not the same as disabling every item: a disabled item is skipped by keyboard navigation while the menu still opens.

eager Type: booleanDefaultfalse

Renders the panel (the phone sheet's too) at mount, not on the first open, and keeps its rows after a close; otherwise rows mount on each open and go after the close.

emptyText Type: string

A pipeline group's no-items row; its own emptyText wins. Default: common.emptyText, or common.noMatchesText when a search matched nothing.

The empty-result counterpart of loadingText, with the same per-group override and the same locale fallback. A getter that throws is not empty: its group shows the failure row (failedText and a built-in "Try again") instead.

See example
enforceCoherence Type: booleanDefaultfalse

Default for pipeline groups: drop selections that are no longer present in a group's current items (e.g. after a dependencies re-fetch) from the selection and v-model. A group's own enforceCoherence overrides this.

The dropdown-level default for pipeline groups, overridable per group. It stays lazy: a group nobody opened never fetches and never prunes, and pruning never runs against an empty or still-loading item set.

failedText Type: string

A pipeline group's failed-load row (its getter threw); its own failedText wins. Default: common.failedText.

highlighted Type: unknown

The row focus is on (v-model:highlighted): its item's value, null when none (closed). Moving focus emits it; a written value focuses that first-level row of the open menu, and an opening (flyout or phone sheet) lands on it; it is not written back.

id Type: string

Names this dropdown: the activator's id (unless it already has one), the menu's menu_<id>, and the key useBbDropdown(id) and a companion BbDropdownBinding pair by. Generated when omitted.

Name the dropdown when something outside it reads its state: useBbDropdown(id) returns values, the menu's state by entry id (writable: a write moves the tick), and groups, each selectable group with its resolved picks (read-only).

See example
items requiredType: (BbDropdownItem | PrimitiveRow)[]Default[]

The menu rows, each a BbBaseButton (button, a or router-link): a flat array for one group, nested arrays for divider-separated groups, or InternalGroup objects for titled / selectable groups. A row's own items opens a submenu.

Three shapes, mixable: an item, a nested array (a divider-separated section), or a group object. label is what a row says and a group's heading; a row is identified by value and a group by id (rows were { key, text } in v2 and early v3 betas). value is optional on a plain action or link row; a selectable row and a row with its own slot need one, and a selectable or bound group needs an id.

See example
keepActivator Type: booleanDefaultfalse

Keeps the trigger when no row is visible (by default it is hidden): inert, no popup ARIA, empty in the activator slot. A contextMenu trigger always stays.

loadingText Type: string

A pipeline group's loading row; its own loadingText wins. Default: common.loadingText.

Pipeline groups only, and the default for all of them; a group can override it with its own loadingText. Unset, it is the plugin locale’s "Loading…" string.

See example
model Type: Record<string, any>

Your object holding the menu's state by entry id (a group's value, a toggle's boolean, a custom row's data): written in place, never replaced; its values seed the menu. A <BbDropdownBinding v-model> on the same id wins.

Pass a deeply reactive object (reactive({}), a ref, Pinia state) and watch it with { deep: true }: the dropdown writes into it and never replaces it. A <BbDropdownBinding v-model> is the alternative for one id.

See example
modelValue Type: boolean

Whether the menu is open (v-model): true opens it from code at its activator or anchor. Unbound: the initial state.

offCanvasProps Type: Partial<Omit<BbOffCanvasProps, "hideClose">>

Props for the phone sheet (the BbOffCanvas that adaptive renders on mobile), spread over its defaults; a pt inside it styles only the sheet. The sheet never shows a ✕ (Escape, the backdrop and a swipe down close it), so hideClose is not part of it.

Merged over the sheet’s own side: "bottom", size: "auto", draggable: true. Ignored entirely when adaptive resolves to false, so it is not a way to configure the desktop panel.

See example
offset Type: numberDefault4

Space the floating container will maintain from the activator.

padding Type: numberDefault10

Minimum empty space to keep from the edge of the page

placement Type: "cursor" | PlacementDefault"bottom"

Position relative to the activator; 'cursor' anchors at the mouse/touch point. No arrow (tooltips only).

Every floating placement, plus cursor — which anchors the panel at the pointer and is what you pair with trigger: "contextMenu" for an OS-style menu. The panel flips on its own when there is no room.

See example
pt Type: (PtCompoundOf<"", { readonly parts: readonly ["root", "panel", "sheet", "header", "footer", "box", "input", "list", "groupLabel", "groupHeader", "item", "itemText", "itemIcon", "itemDescription", "check", "submenu"]; readonly states: readonly ["activeLink", "exactActiveLink", "selected", "disabled", "open"]; readonly wide: readonly ["open"]; readonly node: { readonly item: readonly ["activeLink", "exactActiveLink", "selected", "disabled"]; readonly itemText: readonly ["activeLink", "exactActiveLink", "selected", "disabled"]; readonly itemIcon: readonly ["activeLink", "exactActiveLink", "selected", "disabled"]; readonly itemDescription: readonly ["activeLink", "exactActiveLink", "selected", "disabled"]; readonly check: readonly ["activeLink", "exactActiveLink", "selected", "disabled"]; }; readonly variant: { readonly names: readonly ["default", "destructive"]; readonly option: "dropdownItemVariants"; readonly parts: readonly ["item", "itemText", "itemIcon", "itemDescription", "check"]; }; }> & { footer?: PtValue | undefined; header?: PtValue | undefined; input?: PtValue | undefined; list?: PtValue | undefined; root?: PtValue | undefined; panel?: PtValue | undefined; "header:open"?: PtValue | undefined; "root:open"?: PtValue | undefined; "panel:open"?: PtValue | undefined; "item:disabled"?: PtValue | undefined; "item:selected"?: PtValue | undefined; "itemDescription:disabled"?: PtValue | undefined; sheet?: PtValue | undefined; "sheet:open"?: PtValue | undefined; "footer:open"?: PtValue | undefined; box?: PtValue | undefined; "input:open"?: PtValue | undefined; "box:open"?: PtValue | undefined; "item:open"?: PtValue | undefined; groupLabel?: PtValue | undefined; groupHeader?: PtValue | undefined; "list:open"?: PtValue | undefined; "itemDescription:open"?: PtValue | undefined; "itemText:open"?: PtValue | undefined; "groupLabel:open"?: PtValue | undefined; "groupHeader:open"?: PtValue | undefined; "itemIcon:open"?: PtValue | undefined; "check:open"?: PtValue | undefined; "submenu:open"?: PtValue | undefined; "item:activeLink"?: PtValue | undefined; "item:exactActiveLink"?: PtValue | undefined; "itemDescription:activeLink"?: PtValue | undefined; "itemDescription:exactActiveLink"?: PtValue | undefined; "itemDescription:selected"?: PtValue | undefined; "itemText:disabled"?: PtValue | undefined; "itemText:activeLink"?: PtValue | undefined; "itemText:exactActiveLink"?: PtValue | undefined; "itemText:selected"?: PtValue | undefined; "itemIcon:disabled"?: PtValue | undefined; "itemIcon:activeLink"?: PtValue | undefined; "itemIcon:exactActiveLink"?: PtValue | undefined; "itemIcon:selected"?: PtValue | undefined; "check:disabled"?: PtValue | undefined; "check:activeLink"?: PtValue | undefined; "check:exactActiveLink"?: PtValue | undefined; "check:selected"?: PtValue | undefined; "item:default"?: PtValue | undefined; "item:destructive"?: PtValue | undefined; "itemDescription:default"?: PtValue | undefined; "itemDescription:destructive"?: PtValue | undefined; "itemText:default"?: PtValue | undefined; "itemText:destructive"?: PtValue | undefined; "itemIcon:default"?: PtValue | undefined; "itemIcon:destructive"?: PtValue | undefined; "check:default"?: PtValue | undefined; "check:destructive"?: PtValue | undefined; } & { item?: PtValue | PtItemFn<InternalItem, BbDropdownPtState, "default" | "destructive", { readonly item: InternalItem; }> | undefined; itemDescription?: PtValue | PtItemFn<InternalItem, BbDropdownPtState, "default" | "destructive", { readonly item: InternalItem; }> | undefined; itemText?: PtValue | PtItemFn<InternalItem, BbDropdownPtState, "default" | "destructive", { readonly item: InternalItem; }> | undefined; itemIcon?: PtValue | PtItemFn<InternalItem, BbDropdownPtState, "default" | "destructive", { readonly item: InternalItem; }> | undefined; check?: PtValue | PtItemFn<InternalItem, BbDropdownPtState, "default" | "destructive", { readonly item: InternalItem; }> | undefined; submenu?: PtValue | PtItemFn<InternalItem, BbDropdownPtState, "default" | "destructive", { readonly item: InternalItem; }> | undefined; })

Passthrough, object form: the same keys as the pt:* attributes without the prefix. See the pt:<part> row.

pt:<part> Type: PtValue | ((ctx: PtItemCtx<InternalItem, BbDropdownPtState, "default" | "destructive">) => PtItemResult)

Passthrough, attribute form: one attribute per part, pt:<part>, and per part and state, pt:<part>:<state>. Parts: box, check, footer, groupHeader, groupLabel, header, input, item, itemDescription, itemIcon, itemText, list, panel, root, sheet, submenu. States: activeLink, default, destructive, disabled, exactActiveLink, open, selected.

See example
queryDebounceTime Type: numberDefault300

Debounce (ms) applied to the async re-fetch a searchable group fires as the user types. Applies to every searchable group in the menu.

Applies to a searchable group’s own search field, debouncing the query before it reaches that group’s async getter. Nothing else on the component reads it.

See example
transitionDuration Type: numberDefault150

The open / close transition (ms). Menus take the fast 150, not the popovers' 250: a menu is picked from and gone, quicker than a panel you read or edit.

trigger Type: DropdownTrigger | DropdownTrigger[]Default"click"

What opens the menu, one or an array: 'click' (left-click / tap) or 'contextMenu' (right-click, Shift+F10 / the Menu key, long-press with a finger or a pen). A 'contextMenu'-only activator can be any element (a row, a card): it gets no popup ARIA, and the arrow keys do not open it.

Takes an array to combine them (["click", "contextMenu"]). contextMenu also opens on Shift+F10 or the Menu key, and on touch devices with a long press; right-clicking again while open moves the menu rather than closing it.

See example
width Type: string | numberDefault"auto"

Width of the dropdown in pixels, percentage, or 'auto' to fit content.

Content-sized by default with a 128px floor — not a fixed width. Pass a number when menus have to line up across the rows of a table, and a percentage when the panel should match its trigger.

See example

v-model

Values kept in sync through v-model.

NameDescription
highlighted Type: unknownSee example
modelValue Type: boolean

Events

NameDescription
hidden Type: (): void

Emitted once the menu has finished closing.

hide Type: (): void

Emitted as soon as the menu starts to close.

item:selected Type: (value: any): void

The user selected a row in a selectable group, at the click, even when a controlled companion's app then refuses it. Payload: the row's value (item-value for pipeline groups, else value).

Fires for any selectable group with the changed item’s value — its itemValue in a pipeline group, otherwise its value. Bind the companion’s v-model when you want the state; use this when you want the moment.

See example
item:unselected Type: (value: any): void

The user unselected a row (a multiple toggle, a clearable re-click, a chip ×, or the old value a single pick replaces). Payload is the item's resolved value, matching item:selected.

Fires when a row of a multiple group is unticked, or when the picked row of a clearable single group is clicked again. A plain single group is a radio group: re-clicking its pick changes nothing, so neither event fires (the row’s onClick still runs).

See example
show Type: (): void

Emitted as soon as the menu (the popover, or the sheet on a phone) starts to open.

shown Type: (): void

Emitted once the menu is open and its open transition has finished.

update:highlighted Type: (value: unknown): void

v-model:highlighted: the focused row's item value, null when none.

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

The menu opened or closed (v-model): true on open, false on close.

Slots

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

NameDescription
<groupId>:append Type: BbDropdownItemSlotProps

The trailing region of that group's title line.

<groupId>:group Type: BbDropdownGroupSlotProps

That group's groupBy headings; beats group.

<groupId>:item Type: BbDropdownItemSlotProps

The content of every row of that group, and no other; a row's own #<value> still wins.

See example
<groupId>:item:append Type: BbDropdownItemSlotProps

The trailing region of every row of that group; replaces their append:icon. The check takes its place on the selected row.

See example
<groupId>:item:prepend Type: BbDropdownItemSlotProps

The leading region of every row of that group — e.g. an avatar per record, drawn from item.meta, while other rows keep their prepend:icon.

The switcher slot: draw each record (an avatar, a logo) from item.meta on this group’s rows while every other row keeps its prepend:icon. Set meta on each item, or through itemProps in a fetched group.

See example
<groupId>:label Type: BbDropdownItemSlotProps

That group's title content (item is the group, groupTitle is true).

<groupId>:prepend Type: BbDropdownItemSlotProps

The leading region of that group's title line.

<value> Type: BbDropdownItemSlotProps

One row's content (label and description), by its value; in a fetched group, by its resolved itemValue.

Named after the row’s value in kebab-case: billingInfo, billing_info and Billing info are all #billing-info. For a value with accents or punctuation, write #[slotKey(value)] (slotKey is exported from bitboss-ui) rather than spelling it by hand. A custom: true row is drawn by the slot named the same way after its id, with values, close() and toggle() in the scope.

See example
<value>:append Type: BbDropdownItemSlotProps

One row's trailing region; replaces its append:icon and its submenu chevron. The check takes its place on the selected row.

The only slot that can replace a row’s submenu chevron. On the selected row of a selectable group the check still wins.

See example
<value>:prepend Type: BbDropdownItemSlotProps

One row's leading region; replaces its prepend:icon.

See example
activator Type: BbDropdownActivatorSlotProps

The element that triggers the dropdown to open. Spread props onto your trigger element.

Spread its props onto a real focusable element or the menu has nothing to attach ARIA and keyboard handling to. The scope also carries loading, true while any item’s async onClick is still running — this replaces the exposed loading a v2 template ref read.

See example
default Type: any

Hosts <BbDropdownBinding> companions. They register their group with the dropdown and render nothing themselves.

empty Type: BbDropdownPlaceholderSlotProps

Replaces the placeholder row of a pipeline group that resolved to no items, once per empty group. A failed load is not empty: it keeps its own row (error icon, failedText).

group Type: BbDropdownGroupSlotProps

Every group's groupBy headings (BbSelect's #group scope); #<groupId>:group beats it.

header Type: BbDropdownEdgeSlotProps

Pinned above the rows, outside their scroll, with a divider — for a title or a filter field.

Pinned above the scrolling items and separated by a divider — a title, or a field that filters the list you build. On the adaptive sheet it becomes the sheet’s pinned header.

item:append Type: BbDropdownItemSlotProps

The trailing region of every row (and group label), replacing its append:icon wherever it renders. A named slot wins; a submenu chevron or a selected row's check takes its place.

Replaces the rows’ append:icon. It never replaces a submenu chevron, the check takes its place on the selected row, and a group’s or a row’s own named slot beats it.

See example
item:prepend Type: BbDropdownItemSlotProps

The leading region of every row (and group title line), replacing its prepend:icon wherever it renders. A named slot wins.

Rendered before every row’s content, group titles included — there groupTitle is true and item is the group. It replaces the rows’ prepend:icon, and a group’s or a row’s own named slot beats it. The payload is read-only: keep slot content presentational and leave clicks to the dropdown.

See example
loading Type: BbDropdownPlaceholderSlotProps

Replaces the default loading placeholder row shown in a pipeline group while its async items load. Rendered once per loading group.

Renamed and removed

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

  • slot<groupId><groupId>:labelfails silently

    #<groupId>:label; :prepend / :append are unchanged.

  • arrowPaddingremovedfails silently
  • item fielditems[].keyitems[].valuefails silently

    A row's identity: its v-model value (any type, compared by hash) and its #<value> slots; check --fix renames it.

  • item fielditems[].textitems[].labelfails silently

    A row's text; check --fix renames it.

  • item fielditems[group].keyitems[group].idfails silently

    A group's identity, the same word as <BbDropdownBinding id>; check --fix renames it.

  • methodloadingremovedfails silently

    Read loading from the activator slot scope (#activator="{ loading }") instead of a template ref.

  • slotno-dataemptyfails silently
  • noDataTextemptyTextfails silently
  • optionoffCanvasProps.hideCloseremovedfails silently

    An offCanvasProps key, not a prop: the phone sheet never shows a ✕ (Escape, backdrop and swipe close it) — delete hideClose: false from offCanvasProps.