Hoppa till huvudinnehåll

Dropdown

Meny, menylist, kontextmeny

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

Installation

npm install @midas-ds/components
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-
renderEmptyState() => ReactNode-

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

idstring-

The element's unique identifier. See MDN.

autoFocus-

Where the focus should be set.

itemsIterable<T>-

Item objects in the collection.

disallowEmptySelection-

Whether the collection allows empty selection.

shouldFocusWrap-

Whether keyboard navigation is circular.

disabledKeysIterable<Key>-

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

selectionMode-

The type of selection that is allowed in the collection.

selectedKeys-

The currently selected keys in the collection (controlled).

defaultSelectedKeys-

The initial selected keys in the collection (uncontrolled).

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.

isOpen-

Whether the overlay is open by default (controlled).

defaultOpen-

Whether the overlay is open by default (uncontrolled).

trigger'press'

How the menu is triggered.