{"slug":"popover","name":"Popover","category":"Overlays","summary":"A floating panel anchored to an element.","status":"stable","since":"0.2.0","import":"import { Popover } from '@elluzion/iv-ui';","usage":["`anchor` takes an element or a selector; the panel is positioned against it.","`showOn` and `hideOn` choose the trigger events; combine `hover` with `interactive` to keep the panel open while hovered.","Bind `open` to control the panel from your own state."],"props":[{"name":"open","type":"boolean","default":"false","description":"Whether the popover is open. Bind with `bind:open`.","required":false,"bindable":true},{"name":"anchor","type":"string | HTMLElement | null","default":"null","description":"Element or selector the popover is positioned against.","required":false,"bindable":false},{"name":"placement","type":"PopoverPlacement","default":"'bottom'","description":"Preferred side of the anchor.","required":false,"bindable":false},{"name":"align","type":"PopoverAlign","default":"'center'","description":"Alignment along the chosen side.","required":false,"bindable":false},{"name":"gap","type":"number","default":"8","description":"Distance from the anchor in pixels.","required":false,"bindable":false},{"name":"closeOnOutside","type":"boolean","default":"true","description":"Closes when a click lands outside the popover.","required":false,"bindable":false},{"name":"closeOnEscape","type":"boolean","default":"true","description":"Closes on Escape.","required":false,"bindable":false},{"name":"interactive","type":"boolean","default":"true","description":"Keeps the popover open while it is hovered or focused.","required":false,"bindable":false},{"name":"showOn","type":"PopoverShowEvent[]","default":"['click']","description":"Events that open the popover.","required":false,"bindable":false},{"name":"hideOn","type":"PopoverHideEvent[]","default":"['click']","description":"Events that close the popover.","required":false,"bindable":false},{"name":"className","type":"string","default":"''","description":"Extra classes merged onto the root element.","required":false,"bindable":false}],"events":[{"name":"open","type":"() => void","default":null,"description":"Called after the popover opens.","required":false,"bindable":false},{"name":"close","type":"() => void","default":null,"description":"Called after the popover closes.","required":false,"bindable":false},{"name":"click","type":"(e: MouseEvent) => void","default":null,"description":"Called when the element is activated.","required":false,"bindable":false}],"snippets":[{"name":"children","type":"Snippet","default":null,"description":"Content rendered inside the component.","required":true,"bindable":false}],"types":[{"name":"PopoverPlacement","kind":"type","code":"type PopoverPlacement = 'top' | 'bottom' | 'left' | 'right';","description":"Side of the anchor the popover prefers."},{"name":"PopoverAlign","kind":"type","code":"type PopoverAlign = 'start' | 'center' | 'end';","description":"Alignment along the popover edge."},{"name":"PopoverShowEvent","kind":"type","code":"type PopoverShowEvent = 'click' | 'hover' | 'focus';","description":"Events that can open a popover."},{"name":"PopoverHideEvent","kind":"type","code":"type PopoverHideEvent = 'click' | 'hover' | 'blur';","description":"Events that can close a popover."}],"manual":[],"tokens":["--iv_border","--iv_font-mono","--iv_popover-max-w","--iv_popover-min-w","--iv_radius-sm","--iv_shadow-md","--iv_surface-raised","--iv_z-dropdown"],"cssHooks":["iv-panel","iv-root"],"accessibility":{"keyboard":[["Enter / Space","Toggles a click-triggered popover."],["Escape","Closes the popover."]],"notes":["The anchor receives `aria-haspopup`, `aria-expanded`, and `aria-controls` while the panel is open.","An interactive panel uses `role=\"dialog\"` with `aria-modal=\"false\"`.","The panel is clamped to the viewport and repositioned on scroll and resize."]},"related":[{"title":"Tooltip","summary":"A short label shown on hover or focus.","url":"/components/tooltip","kind":"Component"},{"title":"Menu","summary":"A vertical list of commands, options, or links.","url":"/components/menu","kind":"Component"},{"title":"Dialog","summary":"A modal surface for focused tasks and confirmations.","url":"/components/dialog","kind":"Component"},{"title":"ContextMenu","summary":"Opens a menu at the pointer or from the keyboard Menu key.","url":"/components/context-menu","kind":"Component"}],"examples":[{"id":"click","title":"Click","description":"Click the trigger to toggle the panel; Escape or an outside click closes it.","code":"<script lang=\"ts\">\n\timport { Button, Popover } from '@elluzion/iv-ui';\n\n\tlet open = $state(false);\n</script>\n\n<div class=\"stack\">\n\t<div>\n\t\t<Button id=\"popover-click-trigger\" variant=\"outline\">Filters</Button>\n\t</div>\n\t<Popover bind:open anchor=\"#popover-click-trigger\" placement=\"bottom\" align=\"start\">\n\t\t<div class=\"panel\">\n\t\t\t<p class=\"title\">Active filters</p>\n\t\t\t<p class=\"body\">Branch: main · Status: failed · Author: any</p>\n\t\t</div>\n\t</Popover>\n</div>\n\n<style>\n\t.stack {\n\t\tdisplay: flex;\n\t\tjustify-content: center;\n\t}\n\n\t.panel {\n\t\tpadding: var(--iv_spacing-md);\n\t\tmax-width: 260px;\n\t}\n\n\t.title {\n\t\tmargin: 0 0 var(--iv_spacing-xs);\n\t\tfont-family: var(--iv_font-mono);\n\t\tfont-size: var(--iv_text-sm);\n\t\tcolor: var(--iv_foreground);\n\t}\n\n\t.body {\n\t\tmargin: 0;\n\t\tfont-family: var(--iv_font-mono);\n\t\tfont-size: var(--iv_text-sm);\n\t\tcolor: var(--iv_foreground-dim);\n\t}\n</style>"},{"id":"hover","title":"Hover","description":"Open on hover or focus and keep the panel interactive.","code":"<script lang=\"ts\">\n\timport { Button, Popover } from '@elluzion/iv-ui';\n</script>\n\n<div class=\"stack\">\n\t<div>\n\t\t<Button id=\"popover-hover-trigger\" variant=\"ghost\">Hover or focus me</Button>\n\t</div>\n\t<Popover\n\t\tanchor=\"#popover-hover-trigger\"\n\t\tplacement=\"top\"\n\t\tshowOn={['hover', 'focus']}\n\t\thideOn={['hover', 'blur']}\n\t\tinteractive\n\t>\n\t\t<p class=\"body\">The panel stays open while the pointer is inside it.</p>\n\t</Popover>\n</div>\n\n<style>\n\t.stack {\n\t\tdisplay: flex;\n\t\tjustify-content: center;\n\t}\n\n\t.body {\n\t\tmargin: 0;\n\t\tpadding: var(--iv_spacing-sm) var(--iv_spacing-md);\n\t\tmax-width: 240px;\n\t\tfont-family: var(--iv_font-mono);\n\t\tfont-size: var(--iv_text-sm);\n\t\tcolor: var(--iv_foreground-dim);\n\t}\n</style>"},{"id":"placement","title":"Placement","description":"Change the preferred side; the panel flips when space runs out.","code":"<script lang=\"ts\">\n\timport type { PopoverPlacement } from '@elluzion/iv-ui';\n\timport { Button, Popover } from '@elluzion/iv-ui';\n\n\tlet open = $state(false);\n\tlet placement = $state<PopoverPlacement>('bottom');\n</script>\n\n<div class=\"stack\">\n\t<div class=\"row\">\n\t\t{#each ['top', 'bottom', 'left', 'right'] as side (side)}\n\t\t\t<Button\n\t\t\t\tsize=\"sm\"\n\t\t\t\tvariant={placement === side ? 'primary' : 'outline'}\n\t\t\t\tonclick={() => (placement = side as PopoverPlacement)}\n\t\t\t>\n\t\t\t\t{side}\n\t\t\t</Button>\n\t\t{/each}\n\t</div>\n\t<div>\n\t\t<Button id=\"popover-placement-trigger\" variant=\"ghost\">Toggle panel</Button>\n\t</div>\n\t<Popover bind:open anchor=\"#popover-placement-trigger\" {placement} closeOnOutside={false}>\n\t\t<p class=\"body\">Preferred side: {placement}. The panel flips when space runs out.</p>\n\t</Popover>\n</div>\n\n<style>\n\t.stack {\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t\talign-items: center;\n\t\tgap: var(--iv_spacing-md);\n\t}\n\n\t.row {\n\t\tdisplay: flex;\n\t\tflex-wrap: wrap;\n\t\tjustify-content: center;\n\t\tgap: var(--iv_spacing-xs);\n\t}\n\n\t.body {\n\t\tmargin: 0;\n\t\tpadding: var(--iv_spacing-sm) var(--iv_spacing-md);\n\t\tmax-width: 220px;\n\t\tfont-family: var(--iv_font-mono);\n\t\tfont-size: var(--iv_text-sm);\n\t\tcolor: var(--iv_foreground-dim);\n\t}\n</style>"}],"markdown":"/components/popover.md","page":"/components/popover"}