Dropdown menus

An opened dropdown is only the beginning of a menu interaction. People also need to reach its items, understand a selection, dismiss the panel, and continue from a predictable place. Compare the action and sort examples: their rows look related but carry different meanings.

Original catalog components. Changes affect this example only.

Interactive demo. No data is sent.

Separate commands from settings

The Quick actions example changes a local sample draft. Duplicate draft increases a sample count, Pin draft toggles a choice, and archive or restore changes its local description. Try each operation and reopen the menu. Restore is unavailable before archiving, and duplication has a sample limit. None of these commands changes an actual document.

The sort example chooses how three sample tasks are ordered. Date, Name, and Priority are mutually exclusive choices; Descending changes a separate on-or-off preference. This distinction should be visible and available to assistive technology. An action row, a radio choice, and a checkable setting should not all be described as the same anonymous clickable item.

Make opening and closing predictable

Name the trigger by what it opens, such as Quick actions or Sort tasks. Its expanded state should agree with the panel. Test opening with a pointer and with the keyboard, then dismiss without selecting anything. Keep the trigger reachable so a person can return to the page and immediately understand where they are.

A command may close the menu after use, while a settings menu can stay open for several related changes. The samples reflect that distinction: quick actions close after selection, while sort choices can be adjusted together. Choose a closing rule for your task deliberately and preserve it when changing the component’s appearance or placement.

Review the route through the items

In these controllers, arrow keys open or move through the menu, Home and End reach its ends, and Escape dismisses it with focus returned to the trigger. Character typing can find matching item text. Try the sequence using the actual item labels, then test it again after an action becomes unavailable.

Check focus separately from selection. Moving to a row must make its position clear, while a radio or checked marker communicates a persistent choice. The custom menu needs its interaction pattern implemented consistently. Adding menu roles to arbitrary markup without matching focus behavior can make a simple list harder to use.

html
<button type="button" aria-haspopup="menu"
  aria-expanded="false" aria-controls="actions">
  Quick actions
</button>
<!-- Opening, focus, items, and dismissal need matching behavior. -->

Leave room for the opened menu

Review the menu inside its real card or toolbar, not only on an empty canvas. Long labels, narrow viewports, and an enclosing scroll area can expose clipping or an awkward panel position. Open the last visible trigger near a viewport edge and check that the items and focus indicator remain usable.

Use clear wording for unavailable commands and preserve their disabled behavior. Keep destructive actions understandable from their labels and surrounding context. The archive in this sample is a reversible local demonstration; it does not establish a deletion or recovery policy for your product. Real permission and failure handling belong to the application.

Connect commands without losing the menu behavior

When integrating SL UI Library, inspect the complete source package and connect each command to its actual application operation. A local sorted list does not sort a server dataset, and a sample duplicate count does not create a file. If the operation can fail, decide how the application communicates that result outside or alongside the menu.

Keep the controller and adjacent styles with React or Next.js entry files. Ask an AI agent to preserve keyboard navigation, focus return, selected markers, and dismissal while adapting visual tokens. Before handoff, test rapid open and close, repeated selection, a disabled row, Escape, narrow widths, and reduced motion in the target layout.

Reference documentation

Technical documentation behind these examples. You can use the article without opening these links.

More practical guides

Button states: hover, focus, loading, success, and errorDesign clear button states with an interactive example, keyboard focus, loading feedback, and practical HTML, CSS, and JavaScript guidance.Animated buttons with HTML, CSS, and JavaScriptBuild purposeful button animation with CSS transitions, clear interaction states, reversible motion, and a reduced-motion alternative.