--- status: "published" label: "Shadcn UI" title: "Use the Shadcn UI components in the Next.js Supabase SaaS kit" description: "Learn how to use the Shadcn UI components in the Next.js Supabase SaaS kit for building custom UIs" order: -1 --- Makerkit uses [Shadcn UI](https://ui.shadcn.com) for its UI components. You can use the components in your Next.js Supabase SaaS kit. In this page, we showcase the components available in Makerkit and how to use them in your Next.js Supabase SaaS kit. Most of these examples were taken from the Shadcn UI docs, however, we've updated the paths to reflect the path in the kit. The components are located at `packages/ui/src/shadcn`. They are exported as named exports, so you can import them directly from the package `@kit/ui`. ## Accordion The `Accordion` component is a collapsible container that allows users to expand and collapse content. It is a great way to organize and present information in a clear and concise manner. {% component path="shadcn/accordion" /%} ```tsx import { Accordion, AccordionItem } from '@kit/ui/accordion'; function MyAccordion() { return (

Content for Section 1

Content for Section 2

); } ``` ## Alert The `Alert` component is a visually distinctive and informative message that alerts users of important information or actions. ### Default Alert The default alert component is a versatile and customizable way to display messages to users. It can be used for success, warning, error, or informational purposes. {% component path="shadcn/alert/default-alert" /%} ```tsx import { InfoIcon } from 'lucide-react'; import { Alert, AlertDescription, AlertTitle } from '@kit/ui/alert'; export default function DefaultAlertDemo() { return ( This is a default alert This is the description of the alert. ); } ``` ### Info Alert For more informative alerts, you can use the `info` variant. {% component path="shadcn/alert/info-alert" /%} ```tsx import { InfoIcon } from 'lucide-react'; import { Alert, AlertDescription, AlertTitle } from '@kit/ui/alert'; export default function InfoAlertDemo() { return ( This is an info alert This is the description of the alert. ); } ``` ### Success Alert For success alerts, use the `success` variant. {% component path="shadcn/alert/success-alert" /%} ```tsx import { CheckCircleIcon } from 'lucide-react'; import { Alert, AlertDescription, AlertTitle } from '@kit/ui/alert'; export default function SuccessAlertDemo() { return ( This is a success alert This is the description of the alert. ); } ``` ### Warning Alert For warning alerts, use the `warning` variant. {% component path="shadcn/alert/warning-alert" /%} ```tsx import { TriangleAlertIcon } from 'lucide-react'; import { Alert, AlertDescription, AlertTitle } from '@kit/ui/alert'; export default function WarningAlertDemo() { return ( This is a warning alert This is the description of the alert. ); } ``` ### Destructive Alert For error alerts, use the `error` variant. {% component path="shadcn/alert/destructive-alert" /%} ```tsx import { XCircleIcon } from 'lucide-react'; import { Alert, AlertDescription, AlertTitle } from '@kit/ui/alert'; export default function ErrorAlertDemo() { return ( This is an error alert This is the description of the alert. ); } ``` ## AlertDialog The `AlertDialog` component is a modal dialog that displays an alert message and provides an action to the user. It is a versatile and customizable way to display messages to users. {% component path="shadcn/alert-dialog" /%} ```tsx import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from '@kit/ui/alert-dialog'; import { Button } from '@kit/ui/button'; import WrapperComponent from '~/components/content/wrapper'; export default function AlertDialogDemo() { return ( Are you absolutely sure? This action cannot be undone. This will permanently delete your account and remove your data from our servers. Cancel Continue ); } ``` For more information on the `AlertDialog` component, please refer to the [AlertDialog](https://ui.shadcn.com/docs/components/alert-dialog) documentation. ## Badge The `Badge` component is a small label or tag that is displayed inline with other content. It is used to highlight important information or to indicate the status of an item. {% component path="shadcn/badge" /%} ```tsx import { Badge } from '@kit/ui/badge'; function BadgeDemo() { return ( <>
Profile Settings Messages
Info Success Warning Error
); } ``` For more information on the `Badge` component, please refer to the [Badge](https://ui.shadcn.com/docs/components/badge) documentation. ## Breadcrumbs The Breadcrumbs component is a navigational component that displays a list of links that represent the user's current location within a website or application. It is commonly used in multi-level navigation menus to provide a clear path for users to navigate back to previous pages. {% component path="shadcn/breadcrumbs" /%} ```tsx import { Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, } from '@kit/ui/breadcrumb'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from '@kit/ui/dropdown-menu'; export default function BreadcrumbDemo() { return ( Home Toggle menu Documentation Themes GitHub Components Breadcrumb ); } ``` For more information on the `Breadcrumbs` component, please refer to the [Breadcrumbs](https://ui.shadcn.com/docs/components/breadcrumbs) documentation. ## Button The `Button` component is a basic button component that can be used to trigger an action or event. ```tsx import { Button } from '@kit/ui/button'; export default function ButtonDemo() { return ( ); } ``` {% component path="shadcn/button" /%} ### Button Variants The `Button` component comes with several variants that you can use to style your buttons. You can use the `variant` prop to change the appearance of the button. {% component path="shadcn/button-variants" /%} ```tsx import { Button } from '@kit/ui/button'; export default function ButtonDemo() { return ( ); } ``` For more information on the `Button` component, please refer to the [Button](https://ui.shadcn.com/docs/components/button) documentation. ## Calendar The `Calendar` component is a calendar component that allows users to select a date. {% component path="shadcn/calendar" /%} ```tsx import { Calendar } from '@kit/ui/calendar'; export default function CalendarDemo() { return ( ); } ``` For more information on the `Calendar` component, please refer to the [Calendar](https://ui.shadcn.com/docs/components/calendar) documentation. ## Card The `Card` component is a flexible and customizable card component that can be used to display content in a visually appealing way. {% component path="shadcn/card" /%} ```tsx import * as React from 'react'; import { Button } from '@kit/ui/button'; import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from '@kit/ui/card'; import { Input } from '@kit/ui/input'; import { Label } from '@kit/ui/label'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '@kit/ui/select'; export default function CardWithForm() { return ( Create project Deploy your new project in one-click.
); } ``` For more information on the `Card` component, please refer to the [Card](https://ui.shadcn.com/docs/components/card) documentation. ## Chart Charts are built using Recharts, a powerful charting library that provides a wide range of customization options. {% component path="shadcn/chart" /%} For more information, please refer to the ShadcnUI documentation for the [Chart component](https://ui.shadcn.com/docs/components/chart). ## Checkbox The `Checkbox` component is a simple and customizable checkbox component that allows users to select one or more options. {% component path="shadcn/checkbox" /%} ```tsx import { Checkbox } from '@kit/ui/checkbox'; export default function CheckboxDemo() { return (
); } ``` For more information on the `Checkbox` component, please refer to the [Checkbox](https://ui.shadcn.com/docs/components/checkbox) documentation. ## Command The `Command` component is a powerful and customizable command palette component that allows users to access a wide range of commands and actions. {% component path="shadcn/command" lazy="true" /%} ```tsx import { Calculator, Calendar, CreditCard, Settings, Smile, User, } from 'lucide-react'; import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, } from '@kit/ui/command'; import WrapperComponent from '~/components/content/wrapper'; export default function CommandDemo() { return ( <> No results found. Calendar Search Emoji Calculator Profile ⌘P Billing ⌘B Settings ⌘S ); } ``` For more information on the `Command` component, please refer to the [Command](https://ui.shadcn.com/docs/components/command) documentation. ## Collapsible The `Collapsible` component is a powerful and customizable collapsible component that allows users to expand and collapse content. {% component path="shadcn/collapsible" /%} ```tsx 'use client'; import * as React from 'react'; import { ChevronsUpDown } from 'lucide-react'; import { Button } from '@kit/ui/button'; import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from '@kit/ui/collapsible'; export default function CollapsibleDemo() { const [isOpen, setIsOpen] = React.useState(false); return ( <>

@peduarte starred 3 repositories

@base-ui/primitives
@base-ui/colors
@stitches/react
); } ``` For more information on how to use the Collapsible component, refer to the [Collapsible documentation](https://ui.shadcn.com/docs/components/collapsible). ## Data Table The Data Table component uses TanStack React Table to display a table of data. It provides a flexible and customizable way to display data in a tabular format. {% component path="shadcn/data-table" /%} ```tsx 'use client'; import * as React from 'react'; import { ColumnDef, ColumnFiltersState, SortingState, VisibilityState, flexRender, getCoreRowModel, getFilteredRowModel, getPaginationRowModel, getSortedRowModel, useReactTable, } from '@tanstack/react-table'; import { ArrowUpDown, ChevronDown, MoreHorizontal } from 'lucide-react'; import { Button } from '@kit/ui/button'; import { Checkbox } from '@kit/ui/checkbox'; import { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from '@kit/ui/dropdown-menu'; import { Input } from '@kit/ui/input'; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from '@kit/ui/table'; const data: Payment[] = [ { id: 'm5gr84i9', amount: 316, status: 'success', email: 'ken99@yahoo.com', }, { id: '3u1reuv4', amount: 242, status: 'success', email: 'Abe45@gmail.com', }, { id: 'derv1ws0', amount: 837, status: 'processing', email: 'Monserrat44@gmail.com', }, { id: '5kma53ae', amount: 874, status: 'success', email: 'Silas22@gmail.com', }, { id: 'bhqecj4p', amount: 721, status: 'failed', email: 'carmella@hotmail.com', }, ]; export type Payment = { id: string; amount: number; status: 'pending' | 'processing' | 'success' | 'failed'; email: string; }; export const columns: ColumnDef[] = [ { id: 'select', header: ({ table }) => ( table.toggleAllPageRowsSelected(!!value)} aria-label="Select all" /> ), cell: ({ row }) => ( row.toggleSelected(!!value)} aria-label="Select row" /> ), enableSorting: false, enableHiding: false, }, { accessorKey: 'status', header: 'Status', cell: ({ row }) => (
{row.getValue('status')}
), }, { accessorKey: 'email', header: ({ column }) => { return ( ); }, cell: ({ row }) =>
{row.getValue('email')}
, }, { accessorKey: 'amount', header: () =>
Amount
, cell: ({ row }) => { const amount = parseFloat(row.getValue('amount')); // Format the amount as a dollar amount const formatted = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', }).format(amount); return
{formatted}
; }, }, { id: 'actions', enableHiding: false, cell: ({ row }) => { const payment = row.original; return ( Actions navigator.clipboard.writeText(payment.id)} > Copy payment ID View customer View payment details ); }, }, ]; export default function DataTableDemo() { const [sorting, setSorting] = React.useState([]); const [columnFilters, setColumnFilters] = React.useState( [], ); const [columnVisibility, setColumnVisibility] = React.useState({}); const [rowSelection, setRowSelection] = React.useState({}); const table = useReactTable({ data, columns, onSortingChange: setSorting, onColumnFiltersChange: setColumnFilters, getCoreRowModel: getCoreRowModel(), getPaginationRowModel: getPaginationRowModel(), getSortedRowModel: getSortedRowModel(), getFilteredRowModel: getFilteredRowModel(), onColumnVisibilityChange: setColumnVisibility, onRowSelectionChange: setRowSelection, state: { sorting, columnFilters, columnVisibility, rowSelection, }, }); return ( <>
table.getColumn('email')?.setFilterValue(event.target.value) } className="max-w-sm" /> {table .getAllColumns() .filter((column) => column.getCanHide()) .map((column) => { return ( column.toggleVisibility(!!value) } > {column.id} ); })}
{table.getHeaderGroups().map((headerGroup) => ( {headerGroup.headers.map((header) => { return ( {header.isPlaceholder ? null : flexRender( header.column.columnDef.header, header.getContext(), )} ); })} ))} {table.getRowModel().rows?.length ? ( table.getRowModel().rows.map((row) => ( {row.getVisibleCells().map((cell) => ( {flexRender( cell.column.columnDef.cell, cell.getContext(), )} ))} )) ) : ( No results. )}
{table.getFilteredSelectedRowModel().rows.length} of{' '} {table.getFilteredRowModel().rows.length} row(s) selected.
); } ``` For more information on how to use the Data Table component, refer to the [Data Table documentation](/docs/next-supabase-turbo/components/data-table). For more information about Tanstack Table, refer to the [Tanstack Table documentation](https://tanstack.com/table/v8/docs/api/core/table). ## Dropdown Menu The Dropdown Menu component is a customizable dropdown menu that can be used to display a list of options when a user interacts with a dropdown button. It is a versatile component that can be used in various contexts, such as navigation menus, dropdown menus, and more. {% component path="shadcn/dropdown-menu" /%} ```tsx import { Button } from '@kit/ui/button'; import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, } from '@kit/ui/dropdown-menu'; export default function DropdownMenuDemo() { return ( <> My Account Profile ⇧⌘P Billing ⌘B Settings ⌘S Keyboard shortcuts ⌘K Team Invite users Email Message More... New Team ⌘+T GitHub Support API Log out ⇧⌘Q ); } ``` For more information on how to use the Dropdown Menu component, refer to the [Dropdown Menu documentation](https://ui.shadcn.com/docs/components/dropdown-menu). ## Form The `Form` component wraps `react-hook-form` and provides a simple and customizable form component. {% component path="shadcn/form" /%} ```tsx 'use client'; import { useForm } from 'react-hook-form'; import { Button } from '@kit/ui/button'; import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, } from '@kit/ui/form'; import { Input } from '@kit/ui/input'; import { Textarea } from '@kit/ui/textarea'; export default function FormDemo() { const form = useForm({ defaultValues: { name: 'John Doe', email: 'john@doe.com', message: 'Hello, world!', }, }); return ( <>
{ console.log(data); })} > ( Name Please enter your name. )} /> ( Email Please enter your email. )} /> ( Message