@neynar/ui
Version:
React UI component library built on shadcn/ui and Tailwind CSS
83 lines (69 loc) • 2.31 kB
Markdown
# Overlay Components
Overlay components create layered interfaces and contextual information displays.
## Dialog
Modal dialogs for important actions and forms.
```tsx
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from "@neynar/ui";
// Basic controlled dialog
function UserSettingsDialog() {
const [open, setOpen] = useState(false);
return (
<Dialog open={open} onOpenChange={setOpen}>
<DialogTrigger asChild>
<Button>Settings</Button>
</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>User Settings</DialogTitle>
<DialogDescription>Update your preferences</DialogDescription>
</DialogHeader>
{/* Form content */}
</DialogContent>
</Dialog>
);
}
```
## AlertDialog
Confirmation dialogs for destructive actions.
```tsx
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger } from "@neynar/ui";
function DeleteConfirmation({ onConfirm }: { onConfirm: () => void }) {
return (
<AlertDialog>
<AlertDialogTrigger asChild>
<Button variant="destructive">Delete</Button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Are you sure?</AlertDialogTitle>
<AlertDialogDescription>This action cannot be undone.</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction onClick={onConfirm}>Delete</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
}
```
## Sheet
Side panels for navigation or supplementary content.
```tsx
import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, SheetTrigger } from "@neynar/ui";
function MobileMenu() {
return (
<Sheet>
<SheetTrigger asChild>
<Button variant="ghost" size="sm">Menu</Button>
</SheetTrigger>
<SheetContent side="left">
<SheetHeader>
<SheetTitle>Navigation</SheetTitle>
</SheetHeader>
{/* Navigation items */}
</SheetContent>
</Sheet>
);
}
```