Hoppa till huvudinnehåll

Dropdown

Meny, menylist, kontextmeny

Dropdown är under utfasning och kommer helt tas bort i version 14, vänligen använd vår komponent Menu istället.

En dropdown kan användas för att samla ihop funktioner som sällan används eller som kompletterar nuvarande funktion.

import { Dropdown, DropdownItem, Button } from '@midas-ds/components'
<Dropdown title='Meny'>
<DropdownItem>
<Button variant='tertiary'>Skriv ut</Button>
</DropdownItem>
<DropdownItem>
<Button variant='tertiary'>Avbryt</Button>
</DropdownItem>
<DropdownItem>
<Button variant='tertiary'>Dela</Button>
</DropdownItem>
</Dropdown>

Beskrivning

Dropdown bygger på React Aria Menu.

Riktlinjer

  • Använd endast till sekundära handlingar som inte är högt prioriterade.
  • Knappen ska helst ha en titel, annars bör en aria-label användas.

API

NameTypeDefaultDescription
labelstring-
titlestring-
iconLucideIconEllipsisVertical

The icon to use for the menu button

renderEmptyState() => ReactNode-

Provides content to display when there are no items in the list.

itemsIterable<T>-

Item objects in the collection.

disabledKeysIterable<Key>-

The item keys that are disabled. These items cannot be selected, focused, or otherwise interacted with.

idstring-

The element's unique identifier. See MDN.

autoFocus-

Where the focus should be set.

selectionMode-

The type of selection that is allowed in the collection.

disallowEmptySelection-

Whether the collection allows empty selection.

selectedKeys-

The currently selected keys in the collection (controlled).

defaultSelectedKeys-

The initial selected keys in the collection (uncontrolled).

escapeKeyBehavior'clearSelection'

Whether pressing the escape key should clear selection in the menu or not.

Most experiences should not modify this option as it eliminates a keyboard user's ability to easily clear selection. Only use if the escape key is being handled externally or should not trigger selection clearing contextually.

shouldFocusWrap-

Whether keyboard navigation is circular.

children-

The contents of the collection.

dependenciesreadonly any[]-

Values that should invalidate the item cache when using dynamic collections.

className-

The CSS className for the element. A function may be provided to compute the class based on component state.

style-

The inline style for the element. A function may be provided to compute the style based on component state.

slotstring-

A slot name for the component. Slots allow the component to receive props from a parent component. An explicit null value indicates that the local props completely override all props received from a parent.

dirstring-
langstring-
hidden-
inert-
translate-
defaultOpen-

Whether the overlay is open by default (uncontrolled).

isOpen-

Whether the overlay is open by default (controlled).

trigger'press'

How the menu is triggered.