Overlays

Popover

A small panel beside a button, for extra detail or a quick edit, without leaving the page.

Installation

npx sinaui add popover

Examples

Detail on demand

Focus moves into the panel when it opens; Escape closes it and returns focus to the trigger.

<script lang="ts">
	import Button from '#lib/ui/Button.svelte';
	import Popover from '#lib/ui/Popover.svelte';
</script>

<Popover title="Muhammad ibn Musa al-Khwarizmi">
	{#snippet trigger(props)}
		<Button variant="link" {...props}>al-Khwarizmi</Button>
	{/snippet}
	<p class="bio">
		Mathematician and astronomer at the House of Wisdom, Baghdad, around 820. His book on restoring
		and balancing gave algebra its name.
	</p>
	<Button href="#profile" variant="secondary" size="sm">Read more</Button>
</Popover>

<style>
	.bio {
		margin: 0 0 0.75rem;
		color: var(--ui-muted);
	}
</style>

Quick edit

Tab or click away to close it; Save closes it too, through bind:open.

<script lang="ts">
	import Button from '#lib/ui/Button.svelte';
	import Input from '#lib/ui/Input.svelte';
	import Popover from '#lib/ui/Popover.svelte';

	let open = $state(false);
	let days = $state('40');
</script>

<Popover bind:open title="Extend the loan">
	{#snippet trigger(props)}
		<Button variant="secondary" {...props}>Loan: {days} days</Button>
	{/snippet}
	<form
		class="form"
		onsubmit={(e) => {
			e.preventDefault();
			open = false;
		}}
	>
		<Input label="Days" type="number" min="1" max="90" bind:value={days} />
		<Button type="submit" size="sm">Save</Button>
	</form>
</Popover>

<style>
	.form {
		display: grid;
		gap: 0.75rem;
		inline-size: 14rem;
	}
	.form > :global(button) {
		justify-self: end;
	}
</style>

Props

PropTypeDefault
openboolean, bindablefalse
titlestring (required)
hideTitleboolean: screen readers onlyfalse
side'top' | 'right' | 'bottom' | 'left''bottom'
align'start' | 'center''start'
triggerSnippet receiving trigger props (required)

Accessibility

  • A non-modal role="dialog" labeled by its title; the trigger has aria-haspopup="dialog" and aria-expanded.
  • It sits right after its trigger in the page, so Tab flows from the trigger into it and out again.
  • Opens in the top layer, positions itself around the viewport and follows its trigger on scroll.
  • For something people must act on before continuing, use a Dialog instead.
KeyAction
Enter / SpaceOn the trigger: opens or closes it.
EscapeCloses it and returns focus to the trigger.
TabMoves through its content; leaving it closes it.
Introduction
Theming
Changelog
Button
Action button
Confirm button
Copy button
Hold to confirm
Split button
Calendar
Checkbox
Color picker
Combobox
Date picker
Date range picker
File drop
Form
Input
Mention input
Multi select
Number field
OTP input
Password input
Phone input
Radio cards
Radio group
Rich text editor
Search field
Segmented control
Select
Signature pad
Slider
Switch
Tag input
Upload
Wheel picker
Textarea
Time field
Toggle group
Toolbar
Alert dialog
Command palette
Context menu
Dialog
Drawer
Dropdown
Hover card
Popover
Tooltip
Announcement bar
Alert
Empty state
Meter
Progress
Rolling number
Skeleton
Spinner
Toast
Avatar
Avatar group
Badge
Card
Carousel
Chart
Chat
Code block
Data table
Folder
Kbd
Mind map
Resizable panels
Scroll area
Separator
Sortable
Table
Tag group
Virtual list
Audio player
Image
Image compare
Video
Visualizer
Breadcrumb
File tree
Menubar
Navigation menu
Pagination
Sidebar layout
Stepper
Tabs
Alarm clock
Clock
Dynamic island
Fluid orb
Hourglass
Stopwatch
Timer
AI chat
AI media
Auth
Board
Booking
Dashboard
File explorer
Messaging
Notifications
Settings
Team
Overview
Pricing
Agent chat
Calendar
Voice agent
Mail inbox
CMS
Blog
Marketing site
E-commerce
AI agents
SaaS landing page
SaaS app
Accordion
Dark theme
Light theme