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

Dropdown2

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

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

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

Members

Property NameTypeBindableDefaultComment
allowFlipPopover2FlipAxis | undefinednoundefinedWhich axis/axes allow the dropdown content to flip to the other side when there is not enough space.
disabledboolean | null | undefinednofalseWhen true, the dropdown is disabled and closed
lightDismissboolean | null | undefinednotrueWhen true, the dropdown content closes when another element is clicked or focused. Also closes when another dropdown opens.
iconSnippet | undefinednoundefinedThe icon after the value. When undefined, displays a chevron.
onOpen(open: boolean | null | undefined) => voidnoundefinedCalled when the dropdown opens or closes
openboolean | null | undefinedyesfalseWhen true, the dropdown is open
valuestring | Snippet | undefinednoundefinedThe value to display.

Considerations

  • Dropdown2 uses Popover2.
  • Includes HTMLDivElement props, events, and methods.

Anatomy

<div class="sterling-dropdown-2">
  <div class="value">
    {@render value()}>
  </div>
  <div class="icon">
    {@render icon()}
  </div>
</div>
<Popover2>
  <div class="sterling-dropdown-2-content">
    {@render children()}
  </div>
</Popover>