Popover
A floating panel anchored to a trigger for date pickers, filters, and inline forms — with the neobrutalist borders-and-shadows treatment.
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"The popover displays rich content in a floating panel anchored to its trigger — opened on click, dismissed by clicking outside or pressing Esc. Built on the Base UI Popover component and styled to the neobrutalist recipe: thick borders, hard shadows, and bold type.
Reach for it when:
- Inline forms — rename an item, set dimensions, or tweak one setting without opening a full dialog.
- Date and color pickers — anchor a calendar or swatch grid directly to its input.
- Toolbar and table filters — stack checkboxes and ranges behind a compact trigger.
Installation#
pnpm dlx shadcn@latest add https://neobrutalism.com/r/base/popover.jsonnpx shadcn@latest add https://neobrutalism.com/r/base/popover.jsonyarn dlx shadcn@latest add https://neobrutalism.com/r/base/popover.jsonbunx --bun shadcn@latest add https://neobrutalism.com/r/base/popover.json
Install the following dependencies:
pnpm add @base-ui/reactnpm install @base-ui/reactyarn add @base-ui/reactbun add @base-ui/react
Copy and paste the following code into your project.
"use client"
import * as React from "react"
import { Popover as PopoverPrimitive } from "radix-ui"
import { cn } from "@/lib/utils"
function Popover({
...props
}: React.ComponentProps<typeof PopoverPrimitive.Root>) {
return <PopoverPrimitive.Root data-slot="popover" {...props} />
}
function PopoverTrigger({
...props
}: React.ComponentProps<typeof PopoverPrimitive.Trigger>) {
return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />
}
function PopoverContent({
className,
align = "center",
sideOffset = 4,
...props
}: React.ComponentProps<typeof PopoverPrimitive.Content>) {
return (
<PopoverPrimitive.Portal>
<PopoverPrimitive.Content
data-slot="popover-content"
align={align}
sideOffset={sideOffset}
className={cn(
"z-50 flex w-72 origin-(--radix-popover-content-transform-origin) flex-col gap-2.5 rounded border-2 bg-popover p-2.5 text-sm text-popover-foreground shadow-md outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
className
)}
{...props}
/>
</PopoverPrimitive.Portal>
)
}
function PopoverAnchor({
...props
}: React.ComponentProps<typeof PopoverPrimitive.Anchor>) {
return <PopoverPrimitive.Anchor data-slot="popover-anchor" {...props} />
}
function PopoverHeader({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="popover-header"
className={cn("flex flex-col gap-0.5 text-sm", className)}
{...props}
/>
)
}
function PopoverTitle({ className, ...props }: React.ComponentProps<"h2">) {
return (
<div
data-slot="popover-title"
className={cn("font-medium", className)}
{...props}
/>
)
}
function PopoverDescription({
className,
...props
}: React.ComponentProps<"p">) {
return (
<p
data-slot="popover-description"
className={cn("text-muted-foreground", className)}
{...props}
/>
)
}
export {
Popover,
PopoverAnchor,
PopoverContent,
PopoverDescription,
PopoverHeader,
PopoverTitle,
PopoverTrigger,
}
Update the import paths to match your project setup.
Usage#
import {
Popover,
PopoverContent,
PopoverDescription,
PopoverHeader,
PopoverTitle,
PopoverTrigger,
} from "@/components/ui/popover"<Popover>
<PopoverTrigger render={<Button variant="outline" />}>
Open Popover
</PopoverTrigger>
<PopoverContent>
<PopoverHeader>
<PopoverTitle>Title</PopoverTitle>
<PopoverDescription>Description text here.</PopoverDescription>
</PopoverHeader>
</PopoverContent>
</Popover>Composition#
Use the following composition to build a Popover:
Popover
├── PopoverTrigger
└── PopoverContentExamples#
Basic#
A simple popover with a header, title, and description.
import { Button } from "@/components/ui/button"
import {
Popover,Align#
Use the align prop on PopoverContent to control the horizontal alignment.
import { Button } from "@/components/ui/button"
import {
Popover,With Form#
A popover with form fields inside.
import { Button } from "@/components/ui/button"
import { Field, FieldGroup, FieldLabel } from "@/components/ui/field"
import { Input } from "@/components/ui/input"RTL#
To enable RTL support in Neobrutalism.com, see the RTL configuration guide.
"use client"
import {Accessibility#
The popover follows the WAI-ARIA Dialog pattern in its non-modal form: the trigger carries aria-haspopup="dialog", aria-expanded, and aria-controls, and the panel renders as role="dialog" — focus moves into it on open and returns to the trigger on close.
Keyboard interactions:
| Key | Action |
|---|---|
Space / Enter | Open or close the popover from the trigger |
Tab / Shift + Tab | Move focus through the panel's focusable elements |
Esc | Close the popover and return focus to the trigger |
API Reference#
See the Base UI Popover documentation.