Kinetic Dropdown

A menu button that opens a list of actions with dividers and a destructive item, fully driven by the keyboard.

  • <kt-kinetic-dropdown>
  • Overlays
  • No framework

Kinetic Dropdown

The code

Copy the Kinetic Dropdown

Fastest: press Copy on the card above for one complete file. To build it into your own project, use the files below: the markup, the styles, this component’s script and the shared effects script (effects.js) that every component uses.

<kt-kinetic-dropdown label="Project actions" items="Rename,Duplicate,Archive,---,!Delete project"></kt-kinetic-dropdown>

<kt-kinetic-dropdown label="Sort by" align="end" items="Newest first,Oldest first,Most viewed,Alphabetical"></kt-kinetic-dropdown>

Attributes

NameWhat it doesDefault
itemsComma-separated menu entries. "---" draws a divider; a leading "!" marks a destructive entry.Edit,Duplicate,---,!Delete
labelText on the trigger button.Actions
align"start" or "end": which edge of the button the menu lines up with.start
disabledDisables the trigger button.—
sfxSound-effect text on open and choose.カチッ!

Keyboard and screen readers

  • The button has aria-haspopup="menu" and aria-expanded; the list is role="menu" with role="menuitem" entries.
  • Enter, Space or Arrow Down opens the menu on the first item; Arrow Up opens it on the last.
  • Arrow Up and Down move through items and wrap; Home and End jump to the ends.
  • Typing letters jumps to the next item that starts with them.
  • Enter or Space chooses the item and fires a select event with its index and label.
  • Escape closes the menu and returns focus to the button; Tab or a click outside also closes it.

Styling variables

Every look is a CSS variable: --kt-accent, --kt-accent-ink, --kt-radius-btn, --kt-surface-radius, --kt-surface-bg, --kt-border-w, --kt-comp-shadow and --font-sans. The copied file sets them all from your choices.

FAQ

Kinetic Dropdown: questions answered

How do I use the Kinetic Dropdown?

Press Copy on the card to get a complete HTML file, or copy the HTML, CSS and JavaScript tabs into your own page. In your markup the element is written as <kt-kinetic-dropdown>.

Which attributes does <kt-kinetic-dropdown> accept?

items, label, align, disabled, sfx. Each one is described in the attributes table on this page.

Is the Kinetic Dropdown accessible?

The button has aria-haspopup="menu" and aria-expanded; the list is role="menu" with role="menuitem" entries. Enter, Space or Arrow Down opens the menu on the first item; Arrow Up opens it on the last. Arrow Up and Down move through items and wrap; Home and End jump to the ends. Typing letters jumps to the next item that starts with them. Enter or Space chooses the item and fires a select event with its index and label. Escape closes the menu and returns focus to the button; Tab or a click outside also closes it.

Can I change the Kinetic Dropdown colors, corners and font?

Yes. Use the options on this page: accent color, border radius, background, border, shadow and Google font. The copied code already contains your choices, and every one of them is a CSS variable you can edit later.