Dimensions
Set the dimensions for the layer.
Component
popover-demo
not found in registry.
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
import {
Popover,
PopoverContent,
PopoverDescription,
PopoverTitle,
PopoverTrigger,
} from "@/components/ui/popover"
export default function PopoverDemo() {
return (
<Popover>
<PopoverTrigger asChild>
<Button variant="outline">Open popover</Button>
</PopoverTrigger>
<PopoverContent>
<div className="grid gap-4">
<div className="space-y-2">
<PopoverTitle>Dimensions</PopoverTitle>
<PopoverDescription>
Set the dimensions for the layer.
</PopoverDescription>
</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="maxWidth">Max. width</Label>
<Input
id="maxWidth"
defaultValue="300px"
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 className="grid grid-cols-3 items-center gap-4">
<Label htmlFor="maxHeight">Max. height</Label>
<Input
id="maxHeight"
defaultValue="none"
className="col-span-2 h-8"
/>
</div>
</div>
</div>
</PopoverContent>
</Popover>
)
}
Not found
Installation
Copy and paste the following code into your project.
"use client"
import * as React from "react"
import { Popover as PopoverPrimitive } from "@ark-ui/react/popover"
import { Portal } from "@ark-ui/react/portal"
import { X } from "lucide-react"
import { cn } from "@/lib/utils"
const Popover = PopoverPrimitive.Root
const PopoverTrigger = PopoverPrimitive.Trigger
const PopoverContent = React.forwardRef<
React.ElementRef<typeof PopoverPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
>(({ className, ...props }, ref) => (
<Portal>
<PopoverPrimitive.Positioner>
<PopoverPrimitive.Content
ref={ref}
className={cn(
"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 z-50 w-80 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",
className
)}
{...props}
/>
</PopoverPrimitive.Positioner>
</Portal>
))
PopoverContent.displayName = PopoverPrimitive.Content.displayName
const PopoverArrow = React.forwardRef<
React.ElementRef<typeof PopoverPrimitive.Arrow>,
React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Arrow>
>(({ className, ...props }, ref) => (
<PopoverPrimitive.Arrow>
<PopoverPrimitive.ArrowTip
ref={ref}
className={cn("border-t-[1px] border-l-[1px]", className)}
{...props}
/>
</PopoverPrimitive.Arrow>
))
PopoverArrow.displayName = PopoverPrimitive.Arrow.displayName
const PopoverCloseTrigger = React.forwardRef<
React.ElementRef<typeof PopoverPrimitive.CloseTrigger>,
React.ComponentPropsWithoutRef<typeof PopoverPrimitive.CloseTrigger>
>(({ className, ...props }, ref) => (
<PopoverPrimitive.CloseTrigger
ref={ref}
className={cn(
"absolute top-4 right-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",
className
)}
{...props}
>
<X className="h-4 w-4" />
<span className="sr-only">Close</span>
</PopoverPrimitive.CloseTrigger>
))
PopoverCloseTrigger.displayName = PopoverPrimitive.CloseTrigger.displayName
const PopoverTitle = React.forwardRef<
React.ElementRef<typeof PopoverPrimitive.Title>,
React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Title>
>(({ className, ...props }, ref) => (
<PopoverPrimitive.Title
ref={ref}
className={cn(
"font-semibold text-lg leading-none tracking-tight",
className
)}
{...props}
/>
))
PopoverTitle.displayName = PopoverPrimitive.Title.displayName
const PopoverDescription = React.forwardRef<
React.ElementRef<typeof PopoverPrimitive.Description>,
React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Description>
>(({ className, ...props }, ref) => (
<PopoverPrimitive.Description
ref={ref}
className={cn("text-muted-foreground text-sm", className)}
{...props}
/>
))
PopoverDescription.displayName = PopoverPrimitive.Description.displayName
export {
Popover,
PopoverArrow,
PopoverCloseTrigger,
PopoverContent,
PopoverDescription,
PopoverTitle,
PopoverTrigger,
}
Not Found
Update the import paths to match your project setup.
Usage
import {
Popover,
PopoverContent,
PopoverDescription,
PopoverTitle,
PopoverTrigger,
} from "@/components/ui/popover"
<Popover>
<PopoverTrigger>Open</PopoverTrigger>
<PopoverContent>
<PopoverTitle>Title</PopoverTitle>
<PopoverDescription>Description</PopoverDescription>
Place content for the popover here.
</PopoverContent>
</Popover>