Component reference
Popover
Edit local filters in a compact anchored panel.
Preview
Live previewOptional six-digit hex. Clear to restore the preset. Check contrast with your brand color.
Changes apply to this preview only.
Width adapts to the available space
"use client";
import { useState } from "react";
import { Popover, Checkbox, Button, Badge } from "@pimolu/react";
const filterOptions = [
"Design tokens",
"Components",
"Playground",
];
function FilterPopover() {
const [isOpen, setIsOpen] = useState(false);
const [selected, setSelected] = useState<string[]>([
"Components",
]);
function toggle(option: string, checked: boolean) {
setSelected((current) => checked
? [...current, option]
: current.filter((item) => item !== option));
}
return (
<Popover
label="Filter the component list"
open={isOpen}
onOpenChange={setIsOpen}
content={<div
className="grid gap-5 min-w-0"
>
<div>
<p className="mb-2 font-medium">Filter</p>
<p className="text-sm text-muted">
The panel stays open while you choose, because the open state is
controlled by the page.
</p>
</div>
<div className="grid gap-5 min-w-0">
{
filterOptions.map((option) => (<Checkbox
key={option}
label={option}
checked={selected.includes(option)}
onCheckedChange={(checked) => toggle(
option,
checked
)}
/>))
}
</div>
<div className="flex flex-wrap items-center gap-3 min-w-0 justify-between">
<Button size="sm" appearance="ghost" onClick={() => setSelected([])}>Reset</Button>
<Button size="sm" onClick={() => setIsOpen(false)}>Apply</Button>
</div>
</div>}
>
<Button appearance="outline">
<span className="flex flex-wrap items-center gap-3 min-w-0">
Filter
<Badge size="sm" variant="primary">
{selected.length}
</Badge>
</span>
</Button>
</Popover>
);
}
export function DemoExample() {
return (<FilterPopover />);
}More examples
Different configurations and compositions using the real Pimolu API. Each preview runs independently and follows the site appearance.
Placement
Four sides, with an automatic flip when the preferred side has no room. offset controls the distance from the trigger.
Padding
Enumerated from popoverVariantMap: none for an edge-to-edge list, sm to lg for panels with content.
Width
matchWidth aligns the panel with the trigger instead of centring it; useful for a field and its suggestions.
Usage
Use a titled panel for interactive content and apply changes through application-owned state.
API reference
Generated from the public TypeScript declarations. Native HTML attributes are inherited where the component extends them; this reference includes Pimolu props and selected common native attributes.
PimoluPopoverProps
Type source| Name | Type | Default | Description |
|---|---|---|---|
contentRequired | ReactNode | — | Content of the panel. It may contain interactive elements. |
childrenRequired | ReactElement<unknown, string | JSXElementConstructor<any>> | — | The single element that toggles the panel: any element, or a component that passes down the props it receives. It gets the ARIA state, the click handler and the ref, and the handlers it already had keep working. |
placement | PimoluPopoverPlacement | undefined | "bottom"; the panel flips to the opposite side when there is not enough room | Preferred side. Defaults to "bottom"; the panel flips to the opposite side when there is not enough room. |
offset | number | undefined | 8 | Distance between the trigger and the panel, in pixels. Defaults to 8. |
matchWidth | boolean | undefined | false | Match the trigger width when the panel sits above or below it. Useful for form panels; a menu usually keeps its natural width. Defaults to false. |
open | boolean | undefined | — | Controlled open state. Omit to let the component own it. |
defaultOpen | boolean | undefined | false | Initial open state when uncontrolled. Defaults to false. |
onOpenChange | ((open: boolean) => void) | undefined | — | Called whenever the component asks to open or close. |
disabled | boolean | undefined | false | Never open. The trigger keeps its own disabled state. |
closeOnSelect | boolean | undefined | false | Close when a click bubbles from inside the panel, after the clicked element has handled it. Handy for action lists. Defaults to false. |
padding | "sm" | "md" | "lg" | "none" | undefined | "md" | Padding inside the panel. Defaults to "md". |
className | string | undefined | — | Class applied to the panel. |
label | string | undefined | — | Visible label associated with the control. |
labelledBy | string | undefined | — | Public Pimolu prop; see the source declaration for details. |
contentRequiredReactNodeNo default extracted.
Content of the panel. It may contain interactive elements.
childrenRequiredReactElement<unknown, string | JSXElementConstructor<any>>No default extracted.
The single element that toggles the panel: any element, or a component that passes down the props it receives. It gets the ARIA state, the click handler and the ref, and the handlers it already had keep working.
placementPimoluPopoverPlacement | undefinedDefault: "bottom"; the panel flips to the opposite side when there is not enough room
Preferred side. Defaults to "bottom"; the panel flips to the opposite side when there is not enough room.
offsetnumber | undefinedDefault: 8
Distance between the trigger and the panel, in pixels. Defaults to 8.
matchWidthboolean | undefinedDefault: false
Match the trigger width when the panel sits above or below it. Useful for form panels; a menu usually keeps its natural width. Defaults to false.
openboolean | undefinedNo default extracted.
Controlled open state. Omit to let the component own it.
defaultOpenboolean | undefinedDefault: false
Initial open state when uncontrolled. Defaults to false.
onOpenChange((open: boolean) => void) | undefinedNo default extracted.
Called whenever the component asks to open or close.
disabledboolean | undefinedDefault: false
Never open. The trigger keeps its own disabled state.
closeOnSelectboolean | undefinedDefault: false
Close when a click bubbles from inside the panel, after the clicked element has handled it. Handy for action lists. Defaults to false.
padding"sm" | "md" | "lg" | "none" | undefinedDefault: "md"
Padding inside the panel. Defaults to "md".
classNamestring | undefinedNo default extracted.
Class applied to the panel.
labelstring | undefinedNo default extracted.
Visible label associated with the control.
labelledBystring | undefinedNo default extracted.
Public Pimolu prop; see the source declaration for details.
Accessibility
- Verify keyboard opening, Escape and focus return; avoid treating it as a tooltip.