Bottom sheet
Mobile sheet. 2 types.
import * as React from "react";
import { Button } from "@/components/ui/button";
import { Copy, Star, Zap } from "@/components/ui/icons";
import { Sheet } from "@/components/ui/sheet";
export default function Example() {
const [open, setOpen] = React.useState(false);
return (
<>
<Button variant="outline" onClick={() => setOpen(true)}>More actions</Button>
<Sheet
open={open}
onClose={() => setOpen(false)}
title="Order #1042"
actions={[
{ label: "Copy order number", icon: <Copy /> },
{ label: "Save for later", icon: <Star /> },
{ label: "Cancel order", icon: <Zap />, destructive: true },
]}
/>
</>
);
}
Installation
$ npx uix-ui@latest add sheetThis copies the file into components/ui/sheet.tsx in your project. npx shadcn@latest add @uix/sheet works too.
Usage
import { Sheet } from "@/components/ui/sheet";
<>
<Button variant="outline" onClick={() => setOpen(true)}>More actions</Button>
<Sheet
open={open}
onClose={() => setOpen(false)}
title="Order #1042"
actions={[
{ label: "Copy order number", icon: <Copy /> },
{ label: "Save for later", icon: <Star /> },
{ label: "Cancel order", icon: <Zap />, destructive: true },
]}
/>
</>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
open | boolean | – | |
onClose | () => void | – | |
title | React.ReactNode | – | |
actions | SheetAction[] | – | Rows of icon + label; pressing one calls its onSelect and closes the sheet. |
footer | React.ReactNode | – | Buttons under the content (a full-width Button works well). |
Everything else is passed to the root element, so className, aria-* and event handlers work as usual.
Dependencies
Installed for you by the CLI.
class-variance-authorityclsxtailwind-merge
lib/utils.ts