Popover
Installation
npx shadcn@latest add https://uibrik.com/r/popover.jsonInstall the packages
npm install motionAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/popover/popover.tsx"use client"; // A panel anchored to a button, for small forms and pickers. It grows out of // the button, flips to the other side when there's no room, and its arrow // keeps pointing at the button even when the panel is nudged to stay on // screen. Focus moves inside on open and returns to the button on close. import { AnimatePresence, motion } from "motion/react"; import { useEffect, useRef, useState, type ReactNode } from "react"; import { cn } from "@/lib/utils"; import { EASE_OUT, Portal, SURFACE, originFor, triggerBox, useAnchoredPosition, useDismiss, useFocusTrap, useLayer, type Align, type Side, } from "../_overlay/overlay";
Adds the files to
components/uibrik/popover and installs motion. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/popover.Props
Popover- side
- Type "bottom" | "top" | "right" | "left"
- "bottom"
- Preferred side. Flips when there isn't room.
- align
- Type "start" | "center" | "end"
- "center"
- Which part of the button the panel lines up with.
- arrow
- Type boolean
- true
- A small arrow pointing at the button.
- offset
- Type number
- 10
- Gap between button and panel.
- childrenrequired
- Type ReactNode
- –
- The button that opens the popover.
- contentrequired
- Type ReactNode | (close) => ReactNode
- –
- What's inside.
- label
- Type string
- –
- Accessible name for the panel.
- open / onOpenChange
- Type boolean / (open) => void
- –
- Controlled open state.
- className
- Type string
- –
- Classes for the panel's content box (padded by default).