sterling-svelte  2.0.0
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 NameTypeDefaultComment
conditionalRenderboolean | null | undefinedtrueWhen true, content is rendered only when the popover is open.
crossAxisOffsetnumber0The offset along the side of the reference element.
mainAxisOffsetnumber0The offset towards or away from the side of the reference element.
openboolean | null | undefinedfalseWhen true, the popover is open and visible.
placementPopoverPlacement | undefined'top-start'How the popover should be positioned relative to the reference element.
portalHostHTMLElement | undefinedundefinedThe host container for the callout.
referenceHTMLElement | undefinedundefinedThe 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

portal (<div>)
  popover (<div>)
    children (Snippet)