Documentation

Dropdown menu

A menu of actions opened from a trigger: items with icons, checkbox items, labels, separators, a destructive item.

WebStableSuperpositions

Web uniquement — React, depuis @krizaka/ui/dropdown-menu. Stable : son API ne change qu’à une version majeure.

Quand l’utiliser

  • For the secondary actions of an item or a page: edit, share, download, delete (a “more” button).
  • For a few options toggled from a toolbar (CheckboxItem).

Quand ne pas l’utiliser

  • For the main action of a view: show it as a button.À la place : Button
  • To search among many commands.À la place : Command
  • For content that is not a list of actions (a form, details).À la place : Popover
  • To pick a value in a form: use a select.À la place : Field

Installation

Installer

npm install @krizaka/ui@beta @krizaka/tailwind@beta @krizaka/tokens@beta tailwindcss

Styles

@import "tailwindcss";
@import "@krizaka/tailwind";
@import "@krizaka/ui/tailwind.css";

Importer

import { DropdownMenu } from "@krizaka/ui/dropdown-menu";

Exemples

Actions

A label, items with icons, a checkbox item, a separator and a destructive item.

Props

DropdownMenuContent

PropTypeDéfautDescription
containerHTMLElement | null—The element the portal renders into (default: document.body).

DropdownMenuItem

An action. tone="danger" for a destructive one; onSelect runs it (the menu closes).

PropTypeDéfautDescription
tone"danger" | "default"—danger for a destructive action: the icon and the highlight carry the danger, the label stays legible.

Accessibilité

  • Radix DropdownMenu: role="menu", menuitem, menuitemcheckbox; disabled items are skipped.
  • Icons in items are decorative (aria-hidden).

Clavier

TouchesAction
Enter / Space / Arrow downOpens the menu from its trigger.
Arrow keys / Home / EndMove through the items; typing a letter jumps to an item.
EscCloses the menu and returns the focus to the trigger.

Bonnes pratiques

  • Start each item with a verb; put the destructive one last, after a separator, with tone="danger".
  • Keep the menu short: more than about seven items is a page or a palette.
  • An IconButton trigger needs a label (“More actions”).

Générée depuis le code de @krizaka/ui 2.0.0-beta.6 : son meta.ts, ses exemples et ses types.Modifier cette documentation sur GitHub

Sur cette page