<cs-dropdown>
StableActionsSince 0.1

Dropdowns display a list of options triggered by a button or other element. They support keyboard navigation, submenus, and checkable items for building menus and context actions.

Options Edit Duplicate Delete

A dropdown pairs a trigger with a panel: activating the trigger opens the panel, and interacting outside it closes the panel. Most dropdowns hold dropdown items, but the API also gives you direct control over showing, hiding, and positioning the panel for lower-level uses.

Examples

Showing Icons

Use the icon slot to add an icon before a dropdown item’s label. This works best with icon elements.

Edit Cut Copy Paste Delete

Showing Labels & Dividers

Use any heading (<h1><h6>) to label a group of items, and the <cs-divider> element to separate them.

Device

Type

Phone Tablet Desktop More options…

Showing Details

Use the details slot to show secondary content after the label, such as a keyboard shortcut.

Message Reply ⌘R Forward ⌘F Move ⌘M Archive ⌘A Delete Del

Checkable Items

Set type="checkbox" to turn a dropdown item into a toggle, and add checked to start it on. Selecting a checkable item flips its checked state and closes the dropdown; cancel the cs-select event to keep it open instead.

When any item is checkable, every item in the dropdown gains matching padding so labels stay aligned.

Destructive Items

Set variant="danger" on a dropdown item to flag a destructive action like deleting.

Project Share Preferences

Danger zone

Archive Delete

To nest a menu, place dropdown items inside another item with slot="submenu". Add dividers between groups as needed.

An item that opens a submenu won’t emit cs-select itself. Items inside the submenu do, unless they open a submenu of their own.

Avoid nesting more than one level of submenu.
Deeply nested menus are hard to navigate, especially with a pointer. Flatten the structure or move secondary choices into a separate view when you can.

Disabled

Add disabled to any dropdown item to make it unselectable.

Payment method Cash Personal check Credit card Gift card

Placement

Set the placement attribute to control where the panel opens relative to the trigger. The panel shifts to a more optimal spot when the preferred placement doesn’t have room.

PlacementOpens
bottom-start defaultBelow the trigger, aligned to its start edge
bottom, bottom-endBelow the trigger, centered or aligned to the end edge
top, top-start, top-endAbove the trigger
right, right-start, right-endTo the right of the trigger
left, left-start, left-endTo the left of the trigger
File formats PDF document Word document Excel spreadsheet PowerPoint presentation Plain text JSON file

Distance

Set the distance attribute to change the gap between the panel and the trigger, in pixels.

Edit Cut Copy Paste Find Replace

Offset

Set the skidding attribute to slide the panel along the trigger, in pixels.

Edit Cut Copy Paste Find Replace

Reacting to Selections

When an item is selected, the dropdown emits the cs-select event. Inspect event.detail.item for the selected dropdown item; if you set a value on each item, read it from event.detail.item.value.

To keep the dropdown open after a selection, call event.preventDefault() in the cs-select handler.

API

Importing

If you're using the autoloader or a hosted project, components load on demand — no manual import needed. To cherry-pick this component, use one of the following snippets.

npm Self-Hosted React
import '@cruglobal/cornerstone-components/components/dropdown/dropdown.js';
import './cornerstone/components/dropdown/dropdown.js';
import CsDropdown from '@cruglobal/cornerstone-components/react/dropdown/index.js';

Slots

Learn more about using slots.

NameDescription
(default)The dropdown's items, typically <cs-dropdown-item> elements.
triggerThe element that triggers the dropdown, such as a <cs-button> or <button>.

Attributes & Properties

Learn more about attributes and properties.

PropertyAttributeDescriptionTypeDefaultReflects
distancedistanceThe distance of the dropdown menu from its trigger.number0
openopenOpens or closes the dropdown.booleanfalseYes
placementplacementThe placement of the dropdown menu in reference to the trigger. The menu will shift to a more optimal location if the preferred placement doesn't have enough room.'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'right' | 'right-start' | 'right-end' | 'left' | 'left-start' | 'left-end''bottom-start'Yes
sizesizeThe dropdown's size.'xs' | 's' | 'm' | 'l' | 'xl''m'Yes
skiddingskiddingThe offset of the dropdown menu along its trigger.number0

Events

Learn more about events.

NameDescription
cs-after-hideEmitted after the dropdown has been hidden.
cs-after-showEmitted after the dropdown has been shown.
cs-hideEmitted when the dropdown is about to hide.
cs-selectEmitted when an item in the dropdown is selected.
cs-showEmitted when the dropdown is about to show.

CSS Custom Properties

Learn more about CSS custom properties.

NameDescriptionDefault
--hide-durationThe duration of the hide animation.
--show-durationThe duration of the show animation.

CSS Parts

Learn more about CSS parts.

NameDescriptionCSS selector
menuThe dropdown menu container.::part(menu)

Dependencies

This component automatically imports the following elements. Sub-dependencies, if any exist, are included in this list.