Popover
Updated
Popover opens a non-modal dialog from its button, anchored in the select's dithered popup, for a small form or details. Opening it moves focus to its first control; Escape closes it and returns focus to the button, and a press outside or tabbing away closes it too. Like the charts, it takes your theme's ink and paper, light or dark, and needs no Tailwind.
Example
import "@/components/dithercharts/controls.css"
import { Button } from "@/components/dithercharts/button"
import { Input } from "@/components/dithercharts/input"
import { Popover } from "@/components/dithercharts/popover"
<Popover
content={
<>
<p>Show revenue between:</p>
<Input label="Min" type="number" value={min} onChange={(e) => setMin(e.target.value)} />
<Input label="Max" type="number" value={max} onChange={(e) => setMax(e.target.value)} />
</>
}
>
<Button variant="outline">Filters</Button>
</Popover>Install
Controls install with DitherCharts Pro. See Installation to log in, then import controls.css once, e.g. in your root layout.
npx dithercharts add popover
Props
It renders a native element, so every other attribute that element takes passes through.
| Prop | Type | Default | Description |
|---|---|---|---|
| childrenrequired | Type ReactElement<TriggerProps> | Default – | One button that opens and closes the popover, e.g. a Button. It gets aria-haspopup, aria-expanded and aria-controls. |
| contentrequired | Type ReactNode | Default – | What the popover holds: text, a small form, anything interactive. |
| label | Type string | Default – | Names the popover for screen readers. Default: the trigger's name. |
| open | Type boolean | Default – | Whether it's open, for a controlled popover; pair it with onOpenChange. |
| defaultOpen | Type boolean | Default false | Whether it's open at first, for an uncontrolled popover. |
| onOpenChange | Type (open: boolean) => void | Default – | |
| collisionPadding | Type { top?: number; bottom?: number } | Default 8 each | Space in px the popover keeps clear at the window's top and bottom, e.g. a sticky header's height. |
| className | Type string | Default – |

