Skip to content

Dropdown

A Bootstrap dropdown: a toggle and a menu of items. It needs tabler.js.

label, icon and variant set the toggle, a Dropdown:Toggle. items sets the menu, a Dropdown:Menu: an array of links {label, href?, icon?, active?, disabled?, badge?}, separators {divider: true} and labels {header: '…'}. A link without href points to #; badge adds a Badge at the end of the item. Labels are text, escaped like any prop: for markup, compose the menu.

Each part has a block: toggle renders the Dropdown:Toggle, menu the Dropdown:Menu. Override one to keep the other, for example to align the menu to the end of the toggle, with the same items set on Dropdown:Menu:

To build the dropdown from its parts, pass Dropdown:Toggle and Dropdown:Menu as children: they replace the content block.

The toggle is a <button type="button">, so it never submits an enclosing form. Without variant, it is a plain .btn. noCaret hides the caret, for an icon-only toggle:

split makes the toggle the caret-only half of a split button: put it after a Button in a ButtonGroup, followed by the menu. Give it an aria-label:

end aligns the menu with the end of the toggle, for a toggle on the right of the page:

direction sets where the menu opens: up (dropup), end (dropend) or start (dropstart). The menu flips to the other side when there is no room:

Dropdowns do not nest into submenus: Dropdown:Toggle is a button (.btn), not the .dropdown-item a submenu trigger needs.

arrow adds a small arrow pointing at the toggle, dark a dark menu on a light page, and scrollable caps the menu height and scrolls the rest:

card turns the menu into a panel for rich content: put a Card in it.

Dropdown:Columns splits a long menu into Dropdown:Columns. Dropdown:Text is plain text that is not an action:

active highlights an item, disabled makes it non-interactive. icon puts a Tabler icon before the label, with the dropdown-item-icon class:

Dropdown:Indicator is a leading slot in an item for a small marker, such as an avatar, a checkbox or a flag (dropdown-item-indicator):

An item holding a checkbox or a radio cannot be a link: set tag="label" on it, so a click anywhere on the item toggles the input. tag also takes button, for an action that is not a navigation. Add data-bs-auto-close="outside" to the toggle to keep the menu open while the user ticks several options:

Component Renders
Dropdown <div class="dropdown"> around the toggle and the menu
Dropdown:Toggle <button type="button" class="btn dropdown-toggle" data-bs-toggle="dropdown">
Dropdown:Menu <div class="dropdown-menu">
Dropdown:Item <a class="dropdown-item">, or the element set by tag
Dropdown:Header <div class="dropdown-header">: a non-interactive label above a group of items
Dropdown:Text <span class="dropdown-item-text">: plain text that is not an action
Dropdown:Indicator <span class="dropdown-item-indicator">: a leading avatar, checkbox or flag in an item
Dropdown:Divider <div class="dropdown-divider">: a separator between groups of items
Dropdown:Columns <div class="dropdown-menu-columns">: splits the menu into columns
Dropdown:Column <div class="dropdown-menu-column">: one column of Dropdown:Columns

Attributes of each component go to its root element.

Dropdown:Header, Dropdown:Text, Dropdown:Indicator, Dropdown:Divider, Dropdown:Columns and Dropdown:Column take no props.

Prop Type Default Description
label string? null Toggle label, rendered with Dropdown:Toggle
icon string? null Tabler icon or UX Icons name before the toggle label
variant string? null Toggle color, forwarded to Dropdown:Toggle; null for a plain .btn
items array? null Menu entries, rendered with Dropdown:Menu (see its items)
direction string 'down' down up end start: where the menu opens (dropup dropend dropstart)

The toggle renders when label or icon is set, the menu when items is.

Prop Type Default Description
variant string? null primary secondary success danger warning info dark light; null for a plain .btn
noCaret bool false Hides the caret (no dropdown-toggle class)
split bool false Caret-only half of a split button (dropdown-toggle-split)
Prop Type Default Description
items array? null {label, href?, icon?, active?, disabled?, badge?}, {divider: true} or {header} entries
end bool false Aligns the menu to the end (dropdown-menu-end)
arrow bool false Arrow pointing at the toggle (dropdown-menu-arrow)
dark bool false Dark menu (dropdown-menu-dark)
scrollable bool false Caps the height and scrolls (dropdown-menu-scrollable)
card bool false Panel for rich content (dropdown-menu-card)
Prop Type Default Description
tag string 'a' a button label… Only an <a> gets the href; a button gets type="button"
href string? null Link target, # when null
active bool false Highlighted item (active)
disabled bool false Non-interactive item (disabled, aria-disabled, or the disabled attribute on a button)
icon string? null Leading Tabler icon or UX Icons name (dropdown-item-icon)

Dropdown:

Block Default
toggle Dropdown:Toggle with the icon and the label, when one of them is set
menu Dropdown:Menu with the items, when set
content toggle, then menu: replace it to compose freely

Dropdown:Menu:

Block Default
content A Dropdown:Item, Dropdown:Divider or Dropdown:Header for each entry of the items

The content of Dropdown:Toggle is its label, the content of Dropdown:Item its label, after the icon.