sterling-svelte  2.0.0
A modern, accessible, lightweight UI component library for Svelte.

Dropdown

A value and associated button to open/close a floating content box.

Code
<script lang="ts">
  import { Dropdown } from '@geoffcox/sterling-svelte';
</script>

<Dropdown bind:open>
  {#snippet value()}
    <!-- TODO: value display -->
  {/snippet}
  {#snippet content()}
    <!-- TODO: dropdown content -->
  {/snippet}
</Dropdown>

Members

Property NameTypeDefaultComment
buttonstring | Snippet | undefinedundefinedThe button to open/close the dropdown.
buttonIconstring | Snippet | undefinedundefinedThe icon within the button. When undefined, displays a chevron.
disabledboolean | null | undefinedfalseWhen true, the dropdown is disabled and closed
onOpen(open: boolean | null | undefined) => voidundefinedCalled when the dropdown opens or closes
openboolean | null | undefinedfalseWhen true, the dropdown is open
stayOpenOnClickAwayboolean | null | undefinedfalseWhen true and the user clicks away from the dropdown, it remains open
valuestring | Snippet | undefinedundefinedThe value to display.

Considerations

  • Includes HTMLDivElement props, events, and methods.

Anatomy

dropdown (<div>)
  value container (<div>)
    value (<string | Snippet>)
  button (<Snippet>)
    button container <div>
      buttonIcon <Snippet>
        chevron (<div>)
  dropdown content (<Popover>)
    content (<div>)
      children (<Snippet>)