# Prototyper UI — Component Reference > Each component below includes documentation, full TypeScript source, and usage examples. > Install: bunx @prototyperco/cli add {component} (or: pnpm dlx shadcn@latest add https://prototyper-ui.com/r/{component}.json) # Accordion > vertically stacked collapsible content panels URL: https://prototyper-ui.com/docs/components/accordion Base UI reference: https://base-ui.com/react/components/accordion ```tsx import { Accordion, AccordionItem, AccordionTrigger, AccordionContent, } from "@/components/ui/accordion"; export default function AccordionDemo() { return ( What is Prototyper UI? A composable, design-first React component library built on Base UI primitives. It features shadcn-compatible distribution with copy-paste components. How do I install components? Use the shadcn CLI to add components to your project. Each component is a standalone file you can customize freely. Can I customize the styling? Yes. All components use Tailwind CSS and expose data-slot attributes for targeted styling. You own the source code and can modify anything. ); } ``` ## Installation ```bash pnpm dlx shadcn@latest add https://prototyper-ui.com/r/accordion.json ``` This will add the following files to your project: - `components/ui/accordion.tsx` ## Usage ```tsx import { Accordion, AccordionItem, AccordionTrigger, AccordionContent, } from "@/components/ui/accordion"; Is it accessible? Yes. It adheres to the WAI-ARIA Accordion pattern. ; ``` ## Anatomy ```tsx ``` | Sub-component | `data-slot` | Purpose | Required | | ------------------ | ------------------- | ----------------------------------------- | -------- | | `Accordion` | `accordion` | Root provider, manages expanded state | Yes | | `AccordionItem` | `accordion-item` | Wrapper for a single collapsible section | Yes | | `AccordionTrigger` | `accordion-trigger` | Button that toggles the panel open/closed | Yes | | `AccordionContent` | `accordion-content` | Collapsible content panel | Yes | ## Examples ### Disabled ```tsx import { Accordion, AccordionItem, AccordionTrigger, AccordionContent, } from "@/components/ui/accordion"; export default function AccordionDisabled() { return ( What is Prototyper UI? A composable, design-first React component library built on Base UI primitives. How do I install components? Use the shadcn CLI to add components to your project. Can I customize the styling? Yes. All components use Tailwind CSS and expose data-slot attributes for targeted styling. ); } ``` ## Styling ### Data Slots Use `data-slot` attributes to target specific parts of the accordion: | Slot name | Element | | ------------------------ | -------------------------------- | | `accordion` | Root wrapper | | `accordion-item` | Individual collapsible section | | `accordion-trigger` | Toggle button (includes chevron) | | `accordion-trigger-icon` | Chevron icon inside the trigger | | `accordion-content` | Collapsible content panel | ### Customization Examples ```css /* Remove border between items */ [data-slot="accordion-item"] { @apply border-b-0; } /* Custom trigger icon color */ [data-slot="accordion-trigger-icon"] { @apply text-primary; } ``` ```tsx { /* Override content padding via className */ } {/* ... */}; ``` ## API Reference ### Accordion Root component that manages the expanded/collapsed state of all items. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `multiple` | `boolean` | `false` | Whether multiple items can be open at the same time | | `loopFocus` | `boolean` | `true` | Whether to loop keyboard focus back to the first item when the end is reached | | `keepMounted` | `boolean` | `false` | Whether panels should remain in the DOM when closed | | `hiddenUntilFound` | `boolean` | `false` | Enables browser search to find and expand panel contents | | `orientation` | `"horizontal" \| "vertical"` | `"vertical"` | Direction of roving focus navigation | | `defaultValue` | `number[]` | - | Initially open item indices for uncontrolled usage | | `value` | `number[]` | - | Controlled open item indices | | `onValueChange` | `(value: number[]) => void` | - | Callback when the set of open items changes | | `disabled` | `boolean` | `false` | Whether all items are disabled | | `className` | `string` | - | Additional CSS classes | | `children` | `React.ReactNode` | - | Accordion items | All [Base UI Accordion.Root props](https://base-ui.com/react/components/accordion) are forwarded via `...props`. ### AccordionItem Wrapper for a single collapsible section containing a trigger and content panel. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `className` | `string` | - | Additional CSS classes | | `children` | `React.ReactNode` | - | Trigger and content elements | All [Base UI Accordion.Item props](https://base-ui.com/react/components/accordion) are forwarded via `...props`. ### AccordionTrigger Button that toggles the visibility of the associated content panel. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `disabled` | `boolean` | `false` | Whether the trigger is disabled | | `className` | `string` | - | Additional CSS classes | | `children` | `React.ReactNode` | - | Trigger label content | All [Base UI Accordion.Trigger props](https://base-ui.com/react/components/accordion) are forwarded via `...props`. ### AccordionContent Collapsible content panel that animates open and closed. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `className` | `string` | - | Additional CSS classes | | `children` | `React.ReactNode` | - | Panel content | All [Base UI Accordion.Panel props](https://base-ui.com/react/components/accordion) are forwarded via `...props`. ## Accessibility ### Keyboard Interactions | Key | Action | | ----------- | ---------------------------------------------- | | `Space` | Toggles the focused accordion item open/closed | | `Enter` | Toggles the focused accordion item open/closed | | `ArrowDown` | Moves focus to the next accordion trigger | | `ArrowUp` | Moves focus to the previous accordion trigger | | `Home` | Moves focus to the first accordion trigger | | `End` | Moves focus to the last accordion trigger | | `Tab` | Moves focus to the next focusable element | ### ARIA Attributes - Each trigger renders with `role="button"` inside a heading element. - `aria-expanded` indicates whether the associated panel is open. - `aria-controls` on each trigger links to its corresponding content panel. - `aria-disabled` is set on disabled triggers. - Each content panel renders with `role="region"`. - `aria-labelledby` on each panel links back to its corresponding trigger. ## Compose This component is available in [`@prototyperco/compose`](/docs/compose). ### Catalog Definition ```typescript title="accordion.catalog.ts" import { z } from "zod"; import { defineComponent } from "@prototyperco/compose/catalog"; export default defineComponent({ description: "A collapsible accordion with expandable sections", props: z.object({ items: z .array( z.object({ title: z.string().describe("Header text for the accordion item"), value: z.string().describe("Unique identifier for the item"), }), ) .describe("Accordion items"), type: z .enum(["single", "multiple"]) .optional() .describe("Whether one or multiple items can be open at once"), collapsible: z .boolean() .optional() .describe("Whether an open item can be collapsed"), }), example: { items: [ { title: "What is your refund policy?", value: "refund" }, { title: "How do I contact support?", value: "support" }, { title: "Can I change my plan?", value: "plan" }, ], type: "single", collapsible: true, }, }); ``` ### Example Spec ```json { "root": "faq", "elements": { "faq": { "type": "Accordion", "props": { "items": [ { "title": "What is your refund policy?", "value": "refund" }, { "title": "How do I contact support?", "value": "support" }, { "title": "Can I change my plan?", "value": "plan" } ], "type": "single", "collapsible": true }, "children": ["refund_content", "support_content", "plan_content"] }, "refund_content": { "type": "Text", "props": { "content": "We offer a 30-day money-back guarantee." } }, "support_content": { "type": "Text", "props": { "content": "Email us at support@example.com." } }, "plan_content": { "type": "Text", "props": { "content": "Yes, you can upgrade or downgrade at any time." } } } } ``` Learn more in the [Compose documentation](/docs/compose). ## Full Component Source ```tsx "use client"; export { Accordion, AccordionItem, AccordionTrigger, AccordionContent, } from "@prototyperco/ui/components/accordion"; ``` # Alert > A callout for important messages with status variants URL: https://prototyper-ui.com/docs/components/alert ```tsx import { Info } from "lucide-react"; import { Alert, AlertTitle, AlertDescription } from "@/components/ui/alert"; export default function AlertDemo() { return (
Heads up! You can add components to your app using the CLI.
); } ``` ## Installation ```bash pnpm dlx shadcn@latest add https://prototyper-ui.com/r/alert.json ``` This will add the following files to your project: - `components/ui/alert.tsx` ## Usage ```tsx import { Alert, AlertTitle, AlertDescription } from "@/components/ui/alert"; Heads up! You can add components to your app using the CLI. ; ``` ## Anatomy ```tsx
``` | Sub-component | `data-slot` | Purpose | Required | | ------------------ | ------------------- | -------------------------------- | -------- | | `Alert` | `alert` | Root container with role="alert" | Yes | | `AlertTitle` | `alert-title` | Heading for the alert | No | | `AlertDescription` | `alert-description` | Supporting message text | No | ## Examples ### Destructive ```tsx import { AlertCircle } from "lucide-react"; import { Alert, AlertTitle, AlertDescription } from "@/components/ui/alert"; export default function AlertDestructive() { return (
Error Your session has expired. Please log in again.
); } ``` ### Success ```tsx import { CheckCircle2 } from "lucide-react"; import { Alert, AlertTitle, AlertDescription } from "@/components/ui/alert"; export default function AlertSuccess() { return (
Success Your changes have been saved successfully.
); } ``` ### Warning ```tsx import { AlertTriangle } from "lucide-react"; import { Alert, AlertTitle, AlertDescription } from "@/components/ui/alert"; export default function AlertWarning() { return (
Warning Your account is approaching its usage limit.
); } ``` ## Styling ### Data Slots Use `data-slot` attributes to target specific parts of the alert: | Slot name | Element | | ------------------- | -------------------- | | `alert` | Root `
` wrapper | | `alert-title` | Title `
` | | `alert-description` | Description `
` | ### Customization Examples ```css /* Make all alerts have a thicker left border */ [data-slot="alert"] { @apply border-l-4; } ``` ```tsx { /* Override styles via className */ } Note With left accent border. ; ``` ## API Reference ### Alert The root container with variant styles and `role="alert"`. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `variant` | `"default" \| "destructive" \| "success" \| "warning"` | `"default"` | Visual style variant. | | `className` | `string` | - | Additional CSS classes. | | `children` | `React.ReactNode` | - | Alert content (icon, title, description). | Extends `React.ComponentProps<"div">`. All standard div props are forwarded via `...props`. ### AlertTitle Heading for the alert message. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `className` | `string` | - | Additional CSS classes. | | `children` | `React.ReactNode` | - | Title text. | Extends `React.ComponentProps<"h5">`. All standard h5 props are forwarded via `...props`. ### AlertDescription Supporting text rendered below the title. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `className` | `string` | - | Additional CSS classes. | | `children` | `React.ReactNode` | - | Description content. | Extends `React.ComponentProps<"div">`. All standard div props are forwarded via `...props`. ### alertVariants A `cva` helper exported for use outside of the `` component. ## Accessibility ### Keyboard Interactions Alert is a non-interactive presentational element and does not have keyboard interactions. ### ARIA Attributes - Alert renders with `role="alert"`, which causes screen readers to announce the content when it appears. - For non-urgent notifications, consider using `role="status"` instead. ## Full Component Source ```tsx "use client"; export { Alert, AlertTitle, AlertDescription, alertVariants, } from "@prototyperco/ui/components/alert"; ``` # Alert Dialog > A modal dialog for confirmations that requires explicit user action URL: https://prototyper-ui.com/docs/components/alert-dialog Base UI reference: https://base-ui.com/react/components/alert-dialog ```tsx import { Button } from "@/components/ui/button"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from "@/components/ui/alert-dialog"; export default function AlertDialogDemo() { return ( }> Discard draft... Discard draft? Your unsaved changes will be lost. This action cannot be undone. Cancel Discard ); } ``` ## Installation ```bash pnpm dlx shadcn@latest add https://prototyper-ui.com/r/alert-dialog.json ``` This will add the following files to your project: - `components/ui/alert-dialog.tsx` ## Usage ```tsx import { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogTitle, AlertDialogDescription, AlertDialogFooter, AlertDialogAction, AlertDialogCancel, } from "@/components/ui/alert-dialog"; Delete... Are you sure? This action cannot be undone. Cancel Confirm ; ``` ## Anatomy ```tsx ``` | Sub-component | `data-slot` | Purpose | Required | | -------------------------- | -------------------------- | ------------------------------------------------------- | -------- | | `AlertDialog` | `alert-dialog` | Root provider, manages open/close state | Yes | | `AlertDialogTrigger` | `alert-dialog-trigger` | Button that opens the alert dialog | Yes | | `AlertDialogContent` | `alert-dialog-content` | The alert dialog popup panel | Yes | | `AlertDialogHeader` | `alert-dialog-header` | Container for media, title, and description | No | | ↳ `AlertDialogMedia` | `alert-dialog-media` | Icon or illustration container (child of Header) | No | | ↳ `AlertDialogTitle` | `alert-dialog-title` | Accessible title for the alert dialog (child of Header) | Yes | | ↳ `AlertDialogDescription` | `alert-dialog-description` | Accessible description (child of Header) | No | | `AlertDialogFooter` | `alert-dialog-footer` | Container for action buttons | No | | ↳ `AlertDialogCancel` | `alert-dialog-cancel` | Cancel button (closes the dialog) | No | | ↳ `AlertDialogAction` | `alert-dialog-action` | Confirm button (does not auto-close) | No | | `AlertDialogPortal` | `alert-dialog-portal` | Renders children into a portal | No | | `AlertDialogOverlay` | `alert-dialog-overlay` | Backdrop behind the alert dialog | No | ## Examples ### Destructive Use the `variant="destructive"` prop on `AlertDialogAction` to indicate a dangerous action. ```tsx import { Button } from "@/components/ui/button"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from "@/components/ui/alert-dialog"; export default function AlertDialogDestructive() { return ( }> Delete account... Delete account This will permanently delete your account and all associated data. This action cannot be undone. Cancel Delete ); } ``` ## Styling ### Data Slots Use `data-slot` attributes to target specific parts of the alert dialog: | Slot name | Element | | -------------------------- | --------------------------------------- | | `alert-dialog` | Root provider (no DOM element rendered) | | `alert-dialog-trigger` | The trigger button | | `alert-dialog-portal` | Portal wrapper | | `alert-dialog-overlay` | Backdrop overlay | | `alert-dialog-content` | The popup panel | | `alert-dialog-header` | Header container (title + description) | | `alert-dialog-media` | Icon or illustration container | | `alert-dialog-title` | Title heading | | `alert-dialog-description` | Description paragraph | | `alert-dialog-footer` | Footer container (action buttons) | | `alert-dialog-action` | Confirm action button | | `alert-dialog-cancel` | Cancel button | ### Customization Examples ```css /* Custom overlay color */ [data-slot="alert-dialog-overlay"] { @apply bg-black/30; } /* Wider alert dialog */ [data-slot="alert-dialog-content"] { @apply sm:max-w-lg; } ``` ```tsx { /* Use the small size variant */ } {/* ... */}; ``` ## API Reference ### AlertDialog Root component that manages open/close state. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `open` | `boolean` | - | Controlled open state | | `onOpenChange` | `(open: boolean) => void` | - | Callback when open state changes | | `defaultOpen` | `boolean` | `false` | Initial open state for uncontrolled usage | All [Base UI AlertDialog.Root props](https://base-ui.com/react/components/alert-dialog) are forwarded via `...props`. ### AlertDialogTrigger Button that opens the alert dialog when clicked. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `render` | `ReactElement \| function` | - | Allows replacing or composing the trigger element with a different component | | `className` | `string` | - | Additional CSS classes | | `style` | `CSSProperties \| function` | - | Inline styles or a function that returns styles based on component state | All [Base UI AlertDialog.Trigger props](https://base-ui.com/react/components/alert-dialog) are forwarded via `...props`. ### AlertDialogContent The popup panel rendered inside a portal with an overlay backdrop. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `size` | `"default" \| "sm"` | `"default"` | Size variant of the alert dialog | | `className` | `string` | - | Additional CSS classes | | `children` | `React.ReactNode` | - | Alert dialog content | All [Base UI AlertDialog.Popup props](https://base-ui.com/react/components/alert-dialog) are forwarded via `...props`. ### AlertDialogHeader Container for media, title, and description. Layout adjusts based on the `size` prop on `AlertDialogContent`. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `className` | `string` | - | Additional CSS classes | | `children` | `React.ReactNode` | - | Header content | All standard `div` props are forwarded via `...props`. ### AlertDialogMedia Container for an icon or illustration displayed in the header. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `className` | `string` | - | Additional CSS classes | | `children` | `React.ReactNode` | - | Icon or illustration content | All standard `div` props are forwarded via `...props`. ### AlertDialogFooter Container for action buttons. Uses a two-column grid at the `sm` size, and a row layout at `default`. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `className` | `string` | - | Additional CSS classes | | `children` | `React.ReactNode` | - | Footer content | All standard `div` props are forwarded via `...props`. ### AlertDialogTitle Accessible title for the alert dialog, rendered as a heading. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `className` | `string` | - | Additional CSS classes | All [Base UI AlertDialog.Title props](https://base-ui.com/react/components/alert-dialog) are forwarded via `...props`. ### AlertDialogDescription Accessible description rendered below the title. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `className` | `string` | - | Additional CSS classes | All [Base UI AlertDialog.Description props](https://base-ui.com/react/components/alert-dialog) are forwarded via `...props`. ### AlertDialogAction Confirm action button. Accepts all `Button` props including `variant` and `size`. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `variant` | `"default" \| "destructive" \| "outline" \| "secondary" \| "ghost" \| "link"` | `"default"` | Visual style variant | | `size` | `"default" \| "xs" \| "sm" \| "lg" \| "icon" \| "icon-xs" \| "icon-sm" \| "icon-lg"` | `"default"` | Size of the button | | `className` | `string` | - | Additional CSS classes | All `Button` props are forwarded via `...props`. ### AlertDialogCancel Cancel button that closes the alert dialog when clicked. Renders as a `Button` with `variant="outline"` by default. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `variant` | `"default" \| "destructive" \| "outline" \| "secondary" \| "ghost" \| "link"` | `"outline"` | Visual style variant | | `size` | `"default" \| "xs" \| "sm" \| "lg" \| "icon" \| "icon-xs" \| "icon-sm" \| "icon-lg"` | `"default"` | Size of the button | | `className` | `string` | - | Additional CSS classes | All [Base UI AlertDialog.Close props](https://base-ui.com/react/components/alert-dialog) are forwarded via `...props`. ### AlertDialogOverlay Backdrop overlay behind the alert dialog. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `className` | `string` | - | Additional CSS classes | All [Base UI AlertDialog.Backdrop props](https://base-ui.com/react/components/alert-dialog) are forwarded via `...props`. ### AlertDialogPortal Renders children into a React portal. All [Base UI AlertDialog.Portal props](https://base-ui.com/react/components/alert-dialog) are forwarded via `...props`. ## Accessibility Unlike a regular Dialog, an Alert Dialog is intended for confirmations and destructive actions. It does not close when clicking outside or pressing `Escape` by default, ensuring the user must make an explicit choice. ### Keyboard Interactions | Key | Action | | ----------- | --------------------------------------------------------------------- | | `Tab` | Moves focus to the next focusable element within the alert dialog | | `Shift+Tab` | Moves focus to the previous focusable element within the alert dialog | ### ARIA Attributes - `AlertDialogContent` receives `role="alertdialog"`. - `aria-modal="true"` is set automatically. - `aria-labelledby` is automatically linked to `AlertDialogTitle`. - `aria-describedby` is automatically linked to `AlertDialogDescription`. - Focus is trapped inside the alert dialog while it is open. - Focus returns to the trigger element when the alert dialog closes. ## Full Component Source ```tsx "use client"; export { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, } from "@prototyperco/ui/components/alert-dialog"; ``` # Autocomplete > text input with suggestions and free-form input capability URL: https://prototyper-ui.com/docs/components/autocomplete Base UI reference: https://base-ui.com/react/components/autocomplete ```tsx "use client"; import { Autocomplete, AutocompleteContent, AutocompleteEmpty, AutocompleteInput, AutocompleteItem, AutocompleteList, } from "@/components/ui/autocomplete"; const cities = [ "New York", "Los Angeles", "Chicago", "Houston", "Phoenix", "Philadelphia", "San Antonio", "San Diego", "Dallas", "Austin", ]; export default function AutocompleteDemo() { return ( No cities found. {(item) => ( {item} )} ); } ``` ## Installation ```bash pnpm dlx shadcn@latest add https://prototyper-ui.com/r/autocomplete.json ``` This will add the following files to your project: - `components/ui/autocomplete.tsx` ## Usage ```tsx import { Autocomplete, AutocompleteInput, AutocompleteContent, AutocompleteList, AutocompleteItem, AutocompleteEmpty, } from "@/components/ui/autocomplete"; No results found. {(item) => ( {item} )} ; ``` ## Anatomy ```tsx ``` | Sub-component | `data-slot` | Purpose | Required | | ------------------------ | -------------------------- | ------------------------------------------ | -------- | | `Autocomplete` | - | Root provider, manages state and filtering | Yes | | `AutocompleteInput` | `input-group-control` | Text input with optional trigger button | Yes | | `AutocompleteTrigger` | `autocomplete-trigger` | Button that toggles the popup open/closed | No | | `AutocompleteValue` | `autocomplete-value` | Displays the current value | No | | `AutocompleteContent` | `autocomplete-content` | Positioned popup containing the list | Yes | | `AutocompleteList` | `autocomplete-list` | Scrollable list of items | Yes | | `AutocompleteItem` | `autocomplete-item` | Individual suggestion option | Yes | | `AutocompleteEmpty` | `autocomplete-empty` | Shown when no items match the filter | No | | `AutocompleteGroup` | `autocomplete-group` | Groups related items together | No | | `AutocompleteGroupLabel` | `autocomplete-group-label` | Label for a group of items | No | | `AutocompleteSeparator` | `autocomplete-separator` | Visual separator between groups | No | | `AutocompleteIcon` | `autocomplete-icon` | Icon element | No | | `AutocompleteStatus` | `autocomplete-status` | Screen-reader-only status message | No | | `AutocompleteArrow` | `autocomplete-arrow` | Arrow pointing from popup to trigger | No | | `AutocompleteBackdrop` | `autocomplete-backdrop` | Full-screen backdrop behind the popup | No | ## Examples ### Modes ```tsx "use client"; import { Autocomplete, AutocompleteContent, AutocompleteEmpty, AutocompleteInput, AutocompleteItem, AutocompleteList, } from "@/components/ui/autocomplete"; const languages = [ "JavaScript", "TypeScript", "Python", "Rust", "Go", "Java", "C++", "Ruby", ]; export default function AutocompleteModes() { return (
No results. {(item) => ( {item} )} No results. {(item) => ( {item} )}
); } ``` ### Sections ```tsx "use client"; import { Autocomplete, AutocompleteContent, AutocompleteEmpty, AutocompleteGroup, AutocompleteGroupLabel, AutocompleteInput, AutocompleteItem, AutocompleteList, } from "@/components/ui/autocomplete"; const items = [ { value: "frontend", items: ["React", "Vue", "Svelte", "Angular", "Solid"], }, { value: "backend", items: ["Node.js", "Django", "Rails", "Spring", "FastAPI"], }, ]; export default function AutocompleteSections() { return ( No results found. {(group) => ( {group.value === "frontend" ? "Frontend" : "Backend"} {group.items.map((item: string) => ( {item} ))} )} ); } ``` ### Disabled ```tsx import { Autocomplete, AutocompleteContent, AutocompleteInput, AutocompleteItem, AutocompleteList, } from "@/components/ui/autocomplete"; const items = ["React", "Vue", "Svelte"]; export default function AutocompleteDisabled() { return ( {(item) => ( {item} )} ); } ``` ### With Trigger ```tsx "use client"; import { Autocomplete, AutocompleteContent, AutocompleteEmpty, AutocompleteInput, AutocompleteItem, AutocompleteList, } from "@/components/ui/autocomplete"; const colors = ["Red", "Orange", "Yellow", "Green", "Blue", "Indigo", "Violet"]; export default function AutocompleteTrigger() { return ( No colors found. {(item) => ( {item} )} ); } ``` ## Autocomplete vs Combobox | Feature | Autocomplete | Combobox | | -------------------- | -------------------------------------- | ----------------------------- | | Free-form text input | Yes | No (must select an item) | | Selection tracking | No | Yes (`value`/`onValueChange`) | | Multi-select / chips | No | Yes | | Item check indicator | No | Yes | | Trigger button | Optional (`showTrigger`) | Default | | `mode` prop | Yes (`list`, `both`, `inline`, `none`) | No | ## Styling ### Data Slots Use `data-slot` attributes to target specific parts of the autocomplete: | Slot name | Element | | -------------------------- | -------------------------------------- | | `input-group-control` | The text input element | | `autocomplete-trigger` | Dropdown trigger button | | `autocomplete-content` | Positioned popup panel | | `autocomplete-list` | Scrollable list container | | `autocomplete-item` | Individual suggestion | | `autocomplete-empty` | Empty state message | | `autocomplete-group` | Group container | | `autocomplete-group-label` | Group label | | `autocomplete-separator` | Separator line between groups | | `autocomplete-value` | Value display | | `autocomplete-icon` | Icon element | | `autocomplete-status` | Screen-reader status (visually hidden) | | `autocomplete-arrow` | Popup arrow | | `autocomplete-backdrop` | Full-screen backdrop | ### Customization Examples ```css /* Widen the popup */ [data-slot="autocomplete-content"] { @apply min-w-[20rem]; } /* Custom highlighted item style */ [data-slot="autocomplete-item"][data-highlighted] { @apply bg-primary text-primary-foreground; } ``` ```tsx { /* Override popup alignment */ } {/* ... */} ; ``` ## API Reference ### Autocomplete Root component that manages filtering, suggestions, and open/close state. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `items` | `T[]` | - | Array of items to filter through | | `mode` | `"list" \| "both" \| "inline" \| "none"` | `"list"` | How the autocomplete behaves: list (filter only), both (filter + inline), inline (inline only), none (no filtering) | | `value` | `string` | - | Controlled input value | | `defaultValue` | `string` | - | Initial input value for uncontrolled usage | | `onValueChange` | `(value: string, eventDetails: ChangeEventDetails) => void` | - | Callback when the input value changes | | `autoHighlight` | `boolean \| "always"` | `false` | Whether the first matching item is highlighted automatically | | `openOnInputClick` | `boolean` | `false` | Whether the popup opens when clicking the input | | `submitOnItemClick` | `boolean` | `false` | Whether clicking an item should submit the owning form | | `disabled` | `boolean` | `false` | Whether the autocomplete is disabled | All [Base UI Autocomplete.Root props](https://base-ui.com/react/components/autocomplete) are forwarded via `...props`. ### AutocompleteInput Text input with optional trigger button, wrapped in an `InputGroup`. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `showTrigger` | `boolean` | `false` | Show the dropdown trigger button | | `className` | `string` | - | Additional CSS classes | | `children` | `React.ReactNode` | - | Additional content after the input | All [Base UI Autocomplete.Input props](https://base-ui.com/react/components/autocomplete) are forwarded via `...props`. ### AutocompleteTrigger Button that toggles the popup open or closed. Renders a chevron-down icon by default. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `className` | `string` | - | Additional CSS classes | | `children` | `React.ReactNode` | - | Custom icon (replaces default chevron) | All [Base UI Autocomplete.Trigger props](https://base-ui.com/react/components/autocomplete) are forwarded via `...props`. ### AutocompleteValue Displays the current input value. All [Base UI Autocomplete.Value props](https://base-ui.com/react/components/autocomplete) are forwarded via `...props`. ### AutocompleteContent Positioned popup that contains the list. Wraps `Autocomplete.Portal`, `Autocomplete.Positioner`, and `Autocomplete.Popup`. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `side` | `"top" \| "bottom" \| "left" \| "right"` | `"bottom"` | Side of the anchor to position on | | `sideOffset` | `number` | `4` | Distance from the anchor | | `align` | `"start" \| "center" \| "end"` | `"start"` | Alignment along the side axis | | `alignOffset` | `number` | `0` | Offset along the alignment axis | | `anchor` | `AutocompletePrimitive.Positioner.Props["anchor"]` | - | Custom anchor element | | `className` | `string` | - | Additional CSS classes | All [Base UI Autocomplete.Popup props](https://base-ui.com/react/components/autocomplete) are forwarded via `...props`. ### AutocompleteList Scrollable list container for autocomplete items. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `className` | `string` | - | Additional CSS classes | All [Base UI Autocomplete.List props](https://base-ui.com/react/components/autocomplete) are forwarded via `...props`. ### AutocompleteItem Individual suggestion option. Unlike `ComboboxItem`, does not include a check-mark indicator. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `className` | `string` | - | Additional CSS classes | | `children` | `React.ReactNode` | - | Item content | All [Base UI Autocomplete.Item props](https://base-ui.com/react/components/autocomplete) are forwarded via `...props`. ### AutocompleteEmpty Message shown when no items match the current filter. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `className` | `string` | - | Additional CSS classes | All [Base UI Autocomplete.Empty props](https://base-ui.com/react/components/autocomplete) are forwarded via `...props`. ### AutocompleteGroup Groups related autocomplete items together. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `className` | `string` | - | Additional CSS classes | All [Base UI Autocomplete.Group props](https://base-ui.com/react/components/autocomplete) are forwarded via `...props`. ### AutocompleteGroupLabel Label for a group of items. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `className` | `string` | - | Additional CSS classes | All [Base UI Autocomplete.GroupLabel props](https://base-ui.com/react/components/autocomplete) are forwarded via `...props`. ### AutocompleteSeparator Visual separator between groups. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `className` | `string` | - | Additional CSS classes | All [Base UI Autocomplete.Separator props](https://base-ui.com/react/components/autocomplete) are forwarded via `...props`. ### AutocompleteIcon Icon element within the autocomplete. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `className` | `string` | - | Additional CSS classes | All [Base UI Autocomplete.Icon props](https://base-ui.com/react/components/autocomplete) are forwarded via `...props`. ### AutocompleteStatus Screen-reader-only status message that announces changes. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `className` | `string` | - | Additional CSS classes | All [Base UI Autocomplete.Status props](https://base-ui.com/react/components/autocomplete) are forwarded via `...props`. ### AutocompleteArrow Arrow element pointing from the popup to the trigger. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `className` | `string` | - | Additional CSS classes | All [Base UI Autocomplete.Arrow props](https://base-ui.com/react/components/autocomplete) are forwarded via `...props`. ### AutocompleteBackdrop Full-screen backdrop rendered behind the popup. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `className` | `string` | - | Additional CSS classes | All [Base UI Autocomplete.Backdrop props](https://base-ui.com/react/components/autocomplete) are forwarded via `...props`. ### AutocompleteCollection Re-export of `AutocompletePrimitive.Collection` for defining static item collections. ### useAutocompleteFilter Re-export of `AutocompletePrimitive.useFilter` hook for custom filtering logic. ## Accessibility ### Keyboard Interactions | Key | Action | | ----------- | --------------------------------------------------------- | | `ArrowDown` | Opens the popup (if closed) or moves to the next item | | `ArrowUp` | Opens the popup (if closed) or moves to the previous item | | `Enter` | Accepts the highlighted item's value into the input | | `Escape` | Closes the popup | | `Home` | Moves to the first item in the list | | `End` | Moves to the last item in the list | | `Tab` | Closes the popup and moves focus to the next element | ### ARIA Attributes - The input has `role="combobox"` with `aria-expanded` indicating popup state. - `aria-activedescendant` tracks the currently highlighted item. - `aria-autocomplete` reflects the `mode` prop behavior. - `AutocompleteContent` has `role="listbox"` for the list of suggestions. - `AutocompleteItem` has `role="option"` with `aria-disabled` for disabled items. - `AutocompleteGroup` uses `role="group"` with `aria-labelledby` linked to the group label. - `AutocompleteStatus` provides a live region for screen reader announcements. ## Full Component Source ```tsx "use client"; export { Autocomplete, AutocompleteCollection, AutocompleteInput, AutocompleteContent, AutocompleteList, AutocompleteItem, AutocompleteEmpty, AutocompleteGroup, AutocompleteGroupLabel, AutocompleteSeparator, AutocompleteTrigger, AutocompleteValue, AutocompleteIcon, AutocompleteStatus, AutocompleteArrow, AutocompleteBackdrop, useAutocompleteFilter, } from "@prototyperco/ui/components/autocomplete"; ```
# Avatar > visual representation of a user with image and fallback support URL: https://prototyper-ui.com/docs/components/avatar Base UI reference: https://base-ui.com/react/components/avatar ```tsx import { Avatar, AvatarImage, AvatarFallback } from "@/components/ui/avatar"; export default function AvatarDemo() { return ( CN ); } ``` ## Installation ```bash pnpm dlx shadcn@latest add https://prototyper-ui.com/r/avatar.json ``` This will add the following files to your project: - `components/ui/avatar.tsx` ## Usage ```tsx import { Avatar, AvatarImage, AvatarFallback } from "@/components/ui/avatar"; AB ; ``` ## Examples ### Fallback ```tsx import { Avatar, AvatarFallback } from "@/components/ui/avatar"; export default function AvatarFallbackDemo() { return ( AB ); } ``` ## Styling ### Data Slots Use `data-slot` attributes to target specific parts of the avatar: | Slot name | Element | | -------------------- | ----------------------------------- | | `avatar` | Root container | | `avatar-image` | The `` element | | `avatar-fallback` | Fallback content (initials or icon) | | `avatar-badge` | Status badge indicator | | `avatar-group` | Group wrapper for multiple avatars | | `avatar-group-count` | Overflow count element in a group | ### Customization Examples ```css /* Make all avatars larger */ [data-slot="avatar"] { @apply size-12 rounded-lg after:rounded-lg; } /* Custom fallback color */ [data-slot="avatar-fallback"] { @apply bg-primary text-primary-foreground; } ``` ```tsx { /* Override styles via className */ } AB ; ``` ## API Reference ### Avatar Root component that wraps the avatar image and fallback. Supports three sizes via the `size` prop. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `size` | `"default" \| "sm" \| "lg"` | `"default"` | Size of the avatar (sm: 24px, default: 32px, lg: 40px) | | `className` | `string` | - | Additional CSS classes | | `children` | `React.ReactNode` | - | Avatar content (image, fallback, badge) | All [Base UI Avatar.Root props](https://base-ui.com/react/components/avatar) are forwarded via `...props`. ### AvatarImage Displays the user's image. Automatically hidden when the image fails to load. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `src` | `string` | - | Image source URL | | `alt` | `string` | - | Accessible alt text for the image | | `className` | `string` | - | Additional CSS classes | All [Base UI Avatar.Image props](https://base-ui.com/react/components/avatar) are forwarded via `...props`. ### AvatarFallback Displayed when no image is provided or while the image is loading. Typically renders initials or an icon. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `className` | `string` | - | Additional CSS classes | | `children` | `React.ReactNode` | - | Fallback content (initials, icon, etc.) | All [Base UI Avatar.Fallback props](https://base-ui.com/react/components/avatar) are forwarded via `...props`. ### AvatarBadge A small status indicator positioned at the bottom-right corner of the avatar. Size adapts to the parent avatar's size. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `className` | `string` | - | Additional CSS classes | | `children` | `React.ReactNode` | - | Badge content (typically an icon) | All standard `span` props are forwarded via `...props`. ### AvatarGroup Wraps multiple avatars in an overlapping horizontal stack. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `className` | `string` | - | Additional CSS classes | | `children` | `React.ReactNode` | - | Avatar components to stack | All standard `div` props are forwarded via `...props`. ### AvatarGroupCount Displays the count of remaining avatars that are not shown in the group. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `className` | `string` | - | Additional CSS classes | | `children` | `React.ReactNode` | - | Count content (e.g. "+3") | All standard `div` props are forwarded via `...props`. ## Accessibility ### ARIA Attributes - The `AvatarImage` renders a standard `` element. Always provide a descriptive `alt` attribute for screen readers. - When no image is available, `AvatarFallback` content (initials or icon) serves as the visual representation. Ensure the fallback is meaningful. - `AvatarBadge` is decorative by default. Add `aria-label` if the badge conveys important status information. - `AvatarGroup` uses standard `div` semantics. Consider adding `role="group"` and `aria-label` for groups of avatars. ## Compose This component is available in [`@prototyperco/compose`](/docs/compose). ### Catalog Definition ```typescript title="avatar.catalog.ts" import { z } from "zod"; import { defineComponent } from "@prototyperco/compose/catalog"; export default defineComponent({ description: "A circular avatar displaying a user image or fallback initials", props: z.object({ src: z.string().optional().describe("URL of the avatar image"), fallback: z .string() .describe( "Fallback text shown when image is unavailable (typically initials)", ), alt: z.string().optional().describe("Alt text for the avatar image"), size: z.enum(["sm", "default", "lg"]).optional().describe("Avatar size"), }), events: [], example: { fallback: "JD", size: "default" }, }); ``` ### Example Spec ```json { "root": "avatar", "elements": { "avatar": { "type": "Avatar", "props": { "fallback": "JD", "size": "default" } } } } ``` Learn more in the [Compose documentation](/docs/compose). ## Full Component Source ```tsx "use client"; export { Avatar, AvatarImage, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarBadge, } from "@prototyperco/ui/components/avatar"; ``` # Badge > A small status indicator with color variants URL: https://prototyper-ui.com/docs/components/badge ```tsx import { Badge } from "@/components/ui/badge"; export default function BadgeDemo() { return Badge; } ``` ## Installation ```bash pnpm dlx shadcn@latest add https://prototyper-ui.com/r/badge.json ``` This will add the following files to your project: - `components/ui/badge.tsx` ## Usage ```tsx import { Badge } from "@/components/ui/badge"; Badge; ``` ## Examples ### Secondary ```tsx import { Badge } from "@/components/ui/badge"; export default function BadgeSecondary() { return Secondary; } ``` ### Destructive ```tsx import { Badge } from "@/components/ui/badge"; export default function BadgeDestructive() { return Destructive; } ``` ### Outline ```tsx import { Badge } from "@/components/ui/badge"; export default function BadgeOutline() { return Outline; } ``` ### Success ```tsx import { Badge } from "@/components/ui/badge"; export default function BadgeSuccess() { return Success; } ``` ### Warning ```tsx import { Badge } from "@/components/ui/badge"; export default function BadgeWarning() { return Warning; } ``` ## Styling ### Data Slots Use `data-slot` attributes to target the badge in CSS: | Slot name | Element | | --------- | ----------------- | | `badge` | The `` root | ### Customization Examples ```css /* Make all badges square */ [data-slot="badge"] { @apply rounded-md; } ``` ```tsx { /* Use className for one-off overrides */ } Custom; ``` ## API Reference ### Badge A small inline status indicator. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `variant` | `"default" \| "secondary" \| "destructive" \| "outline" \| "success" \| "warning"` | `"default"` | Visual style variant. | | `className` | `string` | - | Additional CSS classes. | | `children` | `React.ReactNode` | - | Badge content. | Extends `React.ComponentProps<"span">`. All standard span props are forwarded via `...props`. ### badgeVariants A `cva` helper exported for use outside of the `` component: ```tsx import { badgeVariants } from "@/components/ui/badge"; Active; ``` ## Accessibility ### Keyboard Interactions Badge is a non-interactive presentational element and does not have keyboard interactions. ### ARIA Attributes - Badge renders as a `` with no implicit ARIA role. - For status indicators, consider adding `role="status"` and an appropriate `aria-label`. ## Full Component Source ```tsx "use client"; export { Badge, badgeVariants } from "@prototyperco/ui/components/badge"; ``` # Breadcrumb > A navigation trail showing the current page location URL: https://prototyper-ui.com/docs/components/breadcrumb ```tsx import { Breadcrumb, BreadcrumbList, BreadcrumbItem, BreadcrumbLink, BreadcrumbSeparator, BreadcrumbPage, } from "@/components/ui/breadcrumb"; export default function BreadcrumbDemo() { return ( Home Docs Breadcrumb ); } ``` ## Installation ```bash pnpm dlx shadcn@latest add https://prototyper-ui.com/r/breadcrumb.json ``` This will add the following files to your project: - `components/ui/breadcrumb.tsx` ## Usage ```tsx import { Breadcrumb, BreadcrumbList, BreadcrumbItem, BreadcrumbLink, BreadcrumbSeparator, BreadcrumbPage, } from "@/components/ui/breadcrumb"; Home Current Page ; ``` ## Anatomy ```tsx ``` | Sub-component | `data-slot` | Purpose | Required | | --------------------- | ---------------------- | ---------------------------------------- | -------- | | `Breadcrumb` | `breadcrumb` | Root `