Skip to content

nve-dropdown

TODO: Beskrivelse mangler

Arvet fra: SlDropdown

TIP

For nedtrekksliste/"rullgardin"/dropdown-list, bruk nve-select

html
<nve-dropdown>
  <nve-button variant="primary" slot="trigger">
    <nve-icon name="expand_more" slot="suffix"></nve-icon>
    Dropdown
  </nve-button>
  <nve-menu>
    <nve-menu-item>Normal tekst</nve-menu-item>
    <nve-menu-item subtext="Dette er en undertekst">Tekst</nve-menu-item>
    <nve-menu-item>
      <nve-checkbox>Checkbox</nve-checkbox>
    </nve-menu-item>
    <nve-divider></nve-divider>
    <nve-menu-item>Normal tekst</nve-menu-item>
    <nve-menu-item indent="">Undertittel</nve-menu-item>
    <nve-label value="Kategori 1"> </nve-label>
    <nve-menu-item -=""
      >Submenu
      <nve-menu slot="submenu">
        <nve-menu-item>Tekst 2</nve-menu-item>
        <nve-menu-item>Tekst 3</nve-menu-item>
        <nve-menu-item>Tekst 4</nve-menu-item>
      </nve-menu>
    </nve-menu-item>
    <nve-menu-item dividertop="">Divider top</nve-menu-item>
    <nve-menu-item disabled="">Disabled</nve-menu-item>
    <nve-label value="Kategori 2" iconleft="" iconcolor="black">
      <div slot="tooltip">Hjelpetekst kan være veldig lang <strong>HTML</strong></div>
    </nve-label>
    <nve-menu-item dividerbottom="">Divider bottom</nve-menu-item>
    <nve-menu-item><nve-icon slot="prefix" name="info"></nve-icon>Ikon</nve-menu-item>
  </nve-menu>
</nve-dropdown>

Spor

NavnBeskrivelse
(standard)The dropdown's main content.
triggerThe dropdown's trigger, usually a `<sl-button>` element.

Hendelser

NavnArvet fraBeskrivelse
sl-showSlDropdownEmitted when the dropdown opens.
sl-after-showSlDropdownEmitted after the dropdown opens and all animations are complete.
sl-hideSlDropdownEmitted when the dropdown closes.
sl-after-hideSlDropdownEmitted after the dropdown closes and all animations are complete.

Egenskaper

NavnAttributt-synkTypeStandardverdiArvet fraBeskrivelse
testIdstring''
handlePanelSelect
popupSlPopupSlDropdown
triggerHTMLSlotElementSlDropdown
panelHTMLSlotElementSlDropdown
openbooleanfalseSlDropdownIndicates whether or not the dropdown is open. You can toggle this attribute to show and hide the dropdown, or you can use the `show()` and `hide()` methods and this attribute will reflect the dropdown's open state.
placement| 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'right' | 'right-start' | 'right-end' | 'left' | 'left-start' | 'left-end''bottom-start'SlDropdownThe preferred placement of the dropdown panel. Note that the actual placement may vary as needed to keep the panel inside of the viewport.
disabledbooleanfalseSlDropdownDisables the dropdown so the panel will not open.
stayOpenOnSelectbooleanfalseSlDropdownBy default, the dropdown is closed when an item is selected. This attribute will keep it open instead. Useful for dropdowns that allow for multiple interactions.
containingElementHTMLElement | undefinedSlDropdownThe dropdown will close when the user interacts outside of this element (e.g. clicking). Useful for composing other components that use a dropdown internally.
distancenumber0SlDropdownThe distance in pixels from which to offset the panel away from its trigger.
skiddingnumber0SlDropdownThe distance in pixels from which to offset the panel along its trigger.
hoistbooleanfalseSlDropdownEnable this option to prevent the panel from being clipped when the component is placed inside a container with `overflow: auto|scroll`. Hoisting uses a fixed positioning strategy that works in many, but not all, scenarios.

Metoder

NavnParametreReturtypeArvet fraBeskrivelse
getMenu
updateAccessibleTrigger
focusOnTriggerSlDropdown
handleTriggerClickSlDropdown
handleTriggerKeyDown
event: KeyboardEvent
SlDropdown
handleTriggerKeyUp
event: KeyboardEvent
SlDropdown
handleTriggerSlotChangeSlDropdown
showSlDropdownShows the dropdown panel.
hideSlDropdownHides the dropdown panel
repositionSlDropdownInstructs the dropdown menu to reposition. Useful when the position or size of the trigger changes when the menu is activated.
addOpenListenersSlDropdown
removeOpenListenersSlDropdown
handleOpenChangeSlDropdown

Deler

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