Popover
A dynamic and flexible popover component used for dropdowns, tooltips, and contextual menus.
Props
Prop | Type | Default | Description |
|---|---|---|---|
trigger | Snippet | required | Snippet for the element that triggers the popover. |
content | Snippet | required | Snippet for the content displayed inside the popover. |
isOpen | boolean | false | Controls the visibility of the popover. Supports $bindable. |
position | 'top' | 'bottom' | 'left' | 'right' | 'bottom' | The preferred position of the popover relative to the trigger. |
variant | string | '' | Custom variant class for theming. |
componentId | string | crypto.randomUUID() | The unique identifier for the component wrapper. |
transitionFn | function | fade | Svelte transition function for the popover content. |
transitionParams | object | { duration: 150 } | Parameters for the transition function. |
Samples
Popover Samples
A flexible popover component for tooltips, dropdowns, and more.
1. Basic Popover
Standard popover that toggles on click.
0
<script>1
import { Popover } from 'fluid-ui-svelte/components';2
import { Text } from 'fluid-ui-svelte/base';3
</script>4
5
<Popover>6
{#snippet trigger()}7
<Text class="bg-primary-500 text-white p-2 rounded-md">Click Me</Text>8
{/snippet}9
{#snippet content()}10
<Text>This is a popover content!</Text>11
{/snippet}12
</Popover>2. Positions
Popovers can be positioned in four different directions.
0
<script>1
import { Popover } from 'fluid-ui-svelte/components';2
import { Text } from 'fluid-ui-svelte/base';3
</script>4
5
<Popover position="top">6
{#snippet trigger()}7
<Text class="border border-primary-500 text-primary-500 p-2 rounded-md">Top Popover</Text>8
{/snippet}9
{#snippet content()}10
<Text>Content on top</Text>11
{/snippet}12
</Popover>13
14
<Popover position="right">15
{#snippet trigger()}16
<Text class="border border-primary-500 text-primary-500 p-2 rounded-md">Right Popover</Text>17
{/snippet}18
{#snippet content()}19
<Text>Content on right</Text>20
{/snippet}21
</Popover>