Components / Overlays
Popover
Small floating panel anchored to a trigger: quick forms, details, filters. Esc or an outside click closes it.
import { Popover } from "@stylhero/ui";
Example
Code
import { Button, Input, Popover, Stack } from "@stylhero/ui";
function PopoverExample() {
return (
<Popover title="Share this build" trigger={<Button variant="secondary">Share</Button>}>
<Stack gap={3}>
<Input label="Link" defaultValue="https://example.com/b/42" readOnly />
<Button size="sm">Copy link</Button>
</Stack>
</Popover>
);
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
children required |
ReactNode |
- | |
trigger required |
ReactElement |
- | The element that opens it on click, e.g. <Button>. |
className |
string |
- | |
onOpenChange |
(open: boolean) => void |
- | |
open |
boolean |
- | Controlled open state. |
placement |
Placement |
"bottom-start" |
|
title |
ReactNode |
- |
Keyboard
| Key | Does |
|---|---|
| Enter / Space | Opens it from the trigger |
| Esc | Closes it and returns focus to the trigger |
Accessibility
- A non-modal
role="dialog": focus moves into it when it opens, and Tab can leave it.
Generated from src/components/Popover.tsx. Something wrong or missing? Open an issue.