Dropdown

Dropdowns expose additional content that “drops down” in a panel. Dropdowns consist of a trigger and a panel. Activating the trigger will expose the panel and interacting outside of the panel will close it.

When dropdowns are used with menus , you can listen for the sense-select event to determine which menu item was selected. The menu item element will be exposed in event.detail.item. You can set value props to make it easier to identify commands.

Dropdowns are designed to work well with menus to provide a list of options the user can select from. However, dropdowns can also be used in lower-level applications (e.g. color picker). The API gives you complete control over showing, hiding, and positioning the panel.

The preferred placement of the dropdown can be set with the placement attribute. Note that the actual position may vary to ensure the panel remains in the viewport.

Edit Cut Copy Paste Find Replace

The distance from the panel to the trigger can be customized using the distance attribute. This value is specified in pixels.

Edit Cut Copy Paste Find Replace

The offset of the panel along the trigger can be customized using the skidding attribute. This value is specified in pixels.

Edit Cut Copy Paste Find Replace

When dropdowns are used with menus, you can listen for the ods-select event to determine which menu item was selected. The menu item element will be exposed in event.detail.item. If you need to trigger an event on the dropdown itself, you can see dropdown specific events here .

Edit Cut Copy Paste Find Replace
import '@ods/components/web.dropdown';

Note: You only need to import a web component once in your code, as it registers itself globally when defined, allowing you to use it anywhere within your application without needing to re-import it each time you want to use the component.

Slots

NameDescription
(default)The dropdown's main content.
triggerThe dropdown's trigger, usually a `<ods-button>` element.

Properties

Please note, both DOM properties and HTML attributes are shown in the table below. Unless otherwise specified, the property and attribute names are identical.

Property/AttributeReflectsTypeDefault
open
booleanfalse
placement
| 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'right' | 'right-start' | 'right-end' | 'left' | 'left-start' | 'left-end''bottom-start'
disabled
booleanfalse
stayOpenOnSelect
stay-open-on-select
booleanfalse
distance
number0
skidding
number0
hoist
booleanfalse
sync
'width' | 'height' | 'both' | undefinedundefined

Events

React EventDescriptionEvent Detail
ods-showEmitted when the dropdown opens.--
ods-after-showEmitted after the dropdown opens and all animations are complete.--
ods-hideEmitted when the dropdown closes.--
ods-after-hideEmitted after the dropdown closes and all animations are complete.--

Methods

NameDescriptionArguments
show()Shows the dropdown panel.--
hide()Hides the dropdown panel--
reposition()Instructs the dropdown menu to reposition. Useful when the position or size of the trigger changes when the menu is activated.--

Parts

NameDescription
baseThe component's base wrapper.
triggerThe container that wraps the trigger.
panelThe panel that gets shown when the dropdown is open.

Dependencies

This component automatically imports the following dependencies.

  • ods-popup

Usage

This section includes guidelines for designers and developers about the usage of this component in different contexts.

Do

  • Use Dropdowns when you have more than 2 additional actions for the given ui element
  • Organize Dropdown content logically, with descedning hierarchy of items
  • Use for More Menus, triggered by a 3-dot menu icon button
  • Use in Application Bar for User Menu and Application Switcher

Dont

  • Use Dropdowns in Forms - use a Select instead
  • Put primary actions under a Dropdown menu - use Buttons for primary actions, and Dropdown for overflow actions
  • Nest mutliple additional components under a Dropdown
  • Use prefix icons unless absolutely necessary - they conflict with the included down chevron suffix icon

Content Guidelines

GuidelineGood ExampleBad Example
Use action-led terms in the button triggerCreate, Save, Edit, ChooseUser, More
Brevity is ideal - eliminate unnecessary wordsChoose LanguageChoose Your Language
Use Sentence caseSelect userSelect User

Search