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 Name | Type | Default | Comment |
---|
| conditionalRender | boolean | null | undefined | true |
| crossAxisOffset | number | 0 |
| mainAxisOffset | number | 0 |
| open | boolean | null | undefined | false |
| placement | PopoverPlacement | undefined | 'top-start' |
| portalHost | HTMLElement | undefined | undefined |
| reference | HTMLElement | undefined | undefined |
Types
| Type Name | Definition | Comment |
---|
| 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)