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

Popover

An element that floats abover other content.

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

  let reference: HTMLElement;

</script>

<div bind:this={reference}>Anchor for the popover position.</div>

<Popover bind:open {reference}>
  sterling-svelte
</Popover>

Members

Property NameTypeBindableDefaultComment
conditionalRenderboolean | null | undefinednotrueWhen true, content is rendered only when the popover is open.
crossAxisOffsetnumberno0The offset along the side of the reference element.
mainAxisOffsetnumberno0The offset towards or away from the side of the reference element.
openboolean | null | undefinednofalseWhen true, the popover is open and visible.
placementPopoverPlacement | undefinedno'top-start'How the popover should be positioned relative to the reference element.
portalHostHTMLElement | undefinednoundefinedThe host container for the callout.
referenceHTMLElement | undefinednoundefinedThe reference to the element anchoring the position of the popover.

Types

Type NameDefinitionComment
PopoverPlacement'top-start' | 'top' | 'top-end' | 'right-start' | 'right' | 'right-end' | 'bottom-end' | 'bottom' | 'bottom-start' | 'left-end' | 'left' | 'left-start'

Considerations

  • Floats content above the page via use:portal. Elements are moved to the end of the `body` element so they appear above them in the z-order.
  • Popover does not provide any styling (background, border, etc.) around the floating content.

Anatomy

<div class="sterling-popover-portal">
  <div class="sterling-popover">
    {@render children()}
  </div>
</div>