Reddot UI Library

Docs
Popover

Popover

Displays rich content in a portal, triggered by a button.

Installation

$npx shadcn@latest add https://reddot.dottools.xyz/r/popover.json

Utilisation

import {
  Popover,
  PopoverContent,
  PopoverTrigger,
} from "@/components/ui/popover"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
 
export function PopoverDemo() {
  return (
    <Popover>
      <PopoverTrigger asChild>
        <Button variant="outline">Open popover</Button>
      </PopoverTrigger>
      <PopoverContent className="w-80">
        <div className="grid gap-4">
          <div className="space-y-2">
            <h4 className="font-medium leading-none">Dimensions</h4>
            <p className="text-sm text-muted-foreground">
              Set the dimensions for the layer.
            </p>
          </div>
          <div className="grid gap-2">
            <div className="grid grid-cols-3 items-center gap-4">
              <Label htmlFor="width">Width</Label>
              <Input
                id="width"
                defaultValue="100%"
                className="col-span-2 h-8"
              />
            </div>
            <div className="grid grid-cols-3 items-center gap-4">
              <Label htmlFor="height">Height</Label>
              <Input
                id="height"
                defaultValue="25px"
                className="col-span-2 h-8"
              />
            </div>
          </div>
        </div>
      </PopoverContent>
    </Popover>
  )
}

API Reference

Popover

Contient toutes les parties d'un popover.

PopoverTrigger

Le bouton qui ouvre le popover.

PopoverContent

Le composant qui contient le contenu du popover quand il est ouvert.

PropTypeDefaultDescription
side"top" | "right" | "bottom" | "left""bottom"The preferred side of the trigger to render against
sideOffsetnumber0The distance in pixels from the trigger
align"start" | "center" | "end""center"The preferred alignment against the trigger

Dépendances

Ce composant nécessite les dépendances suivantes :

  • @radix-ui/react-popover

Notes

  • Ce composant UI fait partie du système de design
  • Respecte les conventions de style et d'accessibilité
  • Rendu dans un portail pour éviter les problèmes de z-index
  • Positionnement automatique intelligent
  • Fermeture avec Escape ou clic à l'extérieur
  • Parfait pour les formulaires et contenus riches