Skip to content
Components

Popover

Popover with thoughtful defaults, semantic styling, and editable source.

Open ↗

Make it yours.

Install the editable source and its dependencies into your React + Tailwind project.

Scroll horizontally for long lines
pnpm dlx shadcn@4.0.8 add http://localhost:3000/r/popover.json

Use it

Scroll horizontally for long lines
"use client";
import {Popover} from '@/components/jez-ui/ui/popover';
import {Button} from '@/components/jez-ui/ui/button';

export default function Example(){

return <><Popover trigger={<Button variant="outline">Project notes</Button>}><h3 className="font-medium">A small reminder</h3><p className="mt-2 text-sm">Leave room for the unexpected.</p></Popover></>;
}

Props & types

Scroll horizontally for long lines
React.ComponentProps<typeof Primitive.Root> & {
  trigger: React.ReactNode;
  children: React.ReactNode;
  className?: string;
}

Source

View 2 source files

registry/ui/popover.tsx

Scroll horizontally for long lines
"use client";
import * as React from "react";
import { cn } from "./utils";
import { Popover as Primitive } from "radix-ui";
export function Popover({
  trigger,
  children,
  className,
  ...props
}: React.ComponentProps<typeof Primitive.Root> & {
  trigger: React.ReactNode;
  children: React.ReactNode;
  className?: string;
}) {
  return (
    <Primitive.Root {...props}>
      <Primitive.Trigger asChild>{trigger}</Primitive.Trigger>
      <Primitive.Portal>
        <Primitive.Content
          sideOffset={8}
          align="start"
          collisionPadding={16}
          className={cn(
            "jez-popover z-50 max-w-[calc(100vw-32px)] w-72 rounded-xl border border-border bg-background p-5 text-foreground shadow-lg",
            className,
          )}
        >
          {children}
          <Primitive.Arrow className="fill-background" />
        </Primitive.Content>
      </Primitive.Portal>
    </Primitive.Root>
  );
}

registry/ui/utils.ts

Scroll horizontally for long lines
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...values: ClassValue[]) {
  return twMerge(clsx(values));
}

Dependencies

radix-ui@1.6.7 · clsx@2.1.1 · tailwind-merge@3.5.0

Accessibility & behaviour

Provide meaningful labels and preserve keyboard focus styles. Check contrast when customising theme colours.

Read the accessibility and performance guide →