# Get started
Starting a new project [#starting-a-new-project]
If you are starting a new project, you can use the dashboard example right away with the following command:
```bash
npx gitpick https://github.com/ailab-core/uilab/tree/main/examples/template-vite-tanstack-router [your_project_name]
cd [your_project_name]
npm install
npm run dev
```
Every example here uses Tanstack Router so make sure to follow the [guide](https://tanstack.com/start/latest/docs/framework/react/guide/routing).
Examples [#examples]
* [Vite Template - Tanstack Router App](https://github.com/ailab-core/uilab/tree/main/examples/template-vite-tanstack-router)
* [Vite Template - Tanstack Start App](https://github.com/ailab-core/uilab/tree/main/examples/template-vite-tanstack-start)
Tanstack Start Template not fully complete yet. Tanstack Start is in RC stage, not fully stable yet so expect frequent changes
Manual Setup [#manual-setup]
Install these packages for your project.
```bash
npm install uilab-core tw-animate-css lucide-react
```
Import the component styles in your application entry point:
```css title='app/global.css'
@import "tailwindcss";
@import "tw-animate-css";
@import "uilab-core/styles.css";
@import "uilab-core/theme.css";
/* Make sure to add this too for themes */
@custom-variant dark (&:is(.dark *));
```
**Note that tailwindcss needs to be installed in your project! [See how](https://tailwindcss.com/docs/installation/using-vite)**
Registry setup [#registry-setup]
Our custom shadcn registry is deployed through GitLab pages and due to it's privacy, you will need your personal access token to add our custom components to your project
```bash title='.env.local'
PAT_TOKEN={YOUR_GITLAB_PAT_TOKEN}
```
```json
{
"$schema": "https://ui.shadcn.com/schema.json",
...
"registries": {
"@uilab": {
"url": "https://ailabmn.gitlab.io/frontend/uilab/r/{name}.json",
"headers": {
"Authorization": "Bearer ${PAT_TOKEN}"
}
}
}
}
```
TypeScript Support [#typescript-support]
All components are written in TypeScript and include complete type definitions. You'll get full IntelliSense support in your IDE:
```tsx
import { Button, type ButtonProps } from "uilab-core"
// Full type support for props
function MyButton(props: ButtonProps) {
return
}
```
Framework Compatibility [#framework-compatibility]
`uilab-core` works with anything that's on client component.
Server component however, is on experimental. There is a known issue of when using the function `cn` on server component. It errors out on console that `cn` function needs to be called in client component. A separate development will be done in near future.
# Introduction
uilab is a react component library. Built on top of [Base UI](https://base-ui.com/), styled with [Tailwind CSS](https://tailwindcss.com/) and bundled with [rolldown](https://rolldownjs.org/).
This is a component library we'll be adopting for our projects at [ailab.mn](https://ailab.mn). We're building it in the open for anyone who wants to create quick, easy and reliable user interfaces.
uilab-core is currently in early development. Things may change quickly so we recomment using this in projects where you're comfortable adapting to changes.
How it works [#how-it-works]
The reason for making it a separate library instead of using shadcn directly is to have our own internal company design system and an ability to change and control certain components without interacting with the project. We currently have and soon will be having many projects under our company and to change a component style and functionality is a massive work.
We separated it into 2 parts.
* **Components** - Base atom components such as Button, Alert, Input, Card etc will be separate installable package.
* **Blocks** - More complex molecule components. This needs more customization based on the project requirements so we decided to go with shadcn/ui registry distribution.
Get Involved [#get-involved]
We're always looking for contributors. Whether it's a bug report, a new feature, or a documentation update, we appreciate your help.
To get started, check out our contribution guidelines on GitHub. You can find open issues and submit pull requests in our repository.
# Styling
Extended Color Variables [#extended-color-variables]
* `--destructive-foreground`: Foreground color for destructive actions
* `--info`: Information state color
* `--info-foreground`: Foreground color for information states
* `--success`: Success state color
* `--success-foreground`: Foreground color for success states
* `--warning`: Warning state color
* `--warning-foreground`: Foreground color for warning states
These additional variables ensure consistent styling across components that need to communicate different states or levels of importance.
# Confirmation Dialog
Preview [#preview]
Installation [#installation]
npm
pnpm
yarn
bun
```bash
npx shadcn add @uilab-core/confirmation
```
```bash
pnpm dlx shadcn add @uilab-core/confirmation
```
```bash
yarn dlx shadcn add @uilab-core/confirmation
```
```bash
bun x shadcn add @uilab-core/confirmation
```
Usage [#usage]
Wrap your app with the provider
```tsx
import { ConfirmationProvider } from '@/components/confirmation';
function App() {
return (
);
}
```
```tsx
import { useConfirmation } from '@/components/confirmation';
```
```tsx
showDialog({
title: 'Delete Item',
description: 'Are you sure you want to delete this item?',
variant: 'destructive'
confirmText: 'Delete',
cancelText: 'Cancel',
onConfirm: () => {
// Handle confirmation
},
})
```
API References [#api-references]
ConfirmationOptions [#confirmationoptions]
# Data Grid
Things may change quickly
# Data Table
Things may change quickly
Introduction [#introduction]
Every data table is unique and it depends on your use case and business logic. It's hard to have one data table that fits every single data display. Some needs to be simple and some needs to have complex filters and paginations (e.g. fintech stuff).
We have made 2 types of data tables using [Tanstack Table](https://tanstack.com/table/latest) which is a headless UI. Capability of this package is endless so you can change certain code to fit your use case.
[Tanstack Router](https://tanstack.com/router/latest)'s type-safe routing feature is super useful for filters and pagination, so we will be using it for demonstrations below.
Installation [#installation]
npm
pnpm
yarn
bun
```bash
npx shadcn add @uilab-core/data-table
```
```bash
pnpm dlx shadcn add @uilab-core/data-table
```
```bash
yarn dlx shadcn add @uilab-core/data-table
```
```bash
bun x shadcn add @uilab-core/data-table
```
Basic Table [#basic-table]
Pretty basic and simple table. Made this for smaller data that does not need pagination or any other feature.
File structure [#file-structure]
Start by creating the following file structure:
```
products
├── index.tsx
└── -components
└── products-table
├── columns.tsx
└── index.tsx
```
Column definitions [#column-definitions]
```tsx title='-components/products-table/columns.tsx'
export default [
{
accessorKey: "name",
header: "Name"
},
{
accessorKey: "email",
header: "Email"
},
{
accessorKey: "status",
header: "Status",
cell: ({ row }: CellContext) => (
{row.getValue('status')}
)
},
{
accessorKey: "createdAt",
header: "Created At"
}
] as Array>
```
Render the table [#render-the-table]
Prepare our table component to render on page
```tsx title='-components/products-table/index.tsx'
import columns from "./columns"
import BasicDataTable from "@/components/data-table"
export function Table() {
const { data, isFetching } = useQuery(dataQuery())
return (
);
}
```
Advanced Table [#advanced-table]
File structure [#file-structure-1]
Start by creating the following file structure:
```
products
├── index.tsx
└── -components
├── index.tsx
└── table
├── columns.tsx
├── filter.tsx
└── index.tsx
```
Validate search params [#validate-search-params]
Page needs to validate if given search params is valid or not. We are using `zod` library for validation.
```tsx title='products/index.tsx'
import { createFileRoute } from "@tanstack/react-router"
import * as z from "zod"
import { DEFAULT_PAGE_INDEX, DEFAULT_PAGE_SIZE } from "@/lib/constants"
import { Table } from "./-components/table"
export const productsSearchSchema = z.object({
pageIndex: z.number().catch(DEFAULT_PAGE_INDEX).optional(),
pageSize: z.number().catch(DEFAULT_PAGE_SIZE).optional(),
})
export const Route = createFileRoute("/products/")({
component: ProductsPage,
validateSearch: productsSearchSchema.parse,
})
function ProductsPage() {
return
}
```
Filter component [#filter-component]
Filter form components should be controlled components, so when sharing the url, the values are instantly filled into the form components. Ease of use.
```tsx title='products/-components/table/filter.tsx'
import { FormProvider, useForm } from "react-hook-form"
import { zodResolver } from "@hookform/resolvers/zod"
import { productsSearchSchema } from "../../"
export default function Filter() {
const { filters, setFilters, resetFilters } = useFilters(PATH)
const form = useForm({
resolver: zodResolver(productsSearchSchema),
values: filters,
})
const handleSubmit = form.handleSubmit((items: SearchSchema) => {
setFilters(items)
})
const handleReset = () => {
resetFilters().then(() => {
form.reset()
form.clearErrors()
})
}
return (
)
}
```
Column definition [#column-definition]
```tsx title='products/-components/table/columns.tsx'
export default [
{
accessorKey: "name",
header: "Name"
},
{
accessorKey: "email",
header: "Email"
},
{
accessorKey: "status",
header: "Status",
cell: ({ row }: CellContext) => (
{row.getValue('status')}
)
},
{
accessorKey: "createdAt",
header: "Created At"
}
] as Array>
```
Render the table [#render-the-table-1]
```tsx title='products/-components/table/index.tsx'
import { AdvancedDataTable } from "@/components/data-table"
import { useFilters } from "@/hooks/use-filter"
import { DEFAULT_PAGE_INDEX, DEFAULT_PAGE_SIZE } from "@/lib/constants"
import Filter from "./filter"
import columns from "./columns"
export function Table() {
// This filter will be using `/products` page's validated search params.
const { filters, setFilters } = useFilters("/products/")
const paginationState = {
pageIndex: filters.pageIndex ?? DEFAULT_PAGE_INDEX,
pageSize: filters.pageSize ?? DEFAULT_PAGE_SIZE,
}
const { data, isFetching, refetch } = useQuery(
dataQuery({
...filters,
page: paginationState.pageIndex.toString(),
size: paginationState.pageSize.toString(),
}),
)
return (
}
// For example: You can add sheet components with trigger
rightHeader={}
pagination={paginationState}
/>
);
}
```
# Date Picker
Coming soon...
# Form Fields
Coming soon...
# Blocks
Roadmap and status [#roadmap-and-status]
| # | Name | Status | Description |
| :- | ------------------------------------- | :----: | -------------------------------------------------------------------------------------- |
| 1 | [Data Grid](/docs/blocks/data-grid) | ⚠️ | For now, It is built for CBS web only, need better solution for global customizability |
| 2 | [Data Table](/docs/blocks/data-table) | ⚠️ | For now, It is built for CBS web only, need better solution for global customizability |
| 3 | [Layout](/docs/blocks/layout) | ✅ | No issues |
| 4 | [Sonner](/docs/blocks/sonner) | ✅ | No issues |
# Layout
Installation [#installation]
npm
pnpm
yarn
bun
```bash
npx shadcn add @uilab-core/layout
```
```bash
pnpm dlx shadcn add @uilab-core/layout
```
```bash
yarn dlx shadcn add @uilab-core/layout
```
```bash
bun x shadcn add @uilab-core/layout
```
API References [#api-references]
# Sonner
Installation [#installation]
Install via following command:
Following CLI command will install `next-themes` and `sonner` libraries to your project.
npm
pnpm
yarn
bun
```bash
npx shadcn add @uilab-core/sonner
```
```bash
pnpm dlx shadcn add @uilab-core/sonner
```
```bash
yarn dlx shadcn add @uilab-core/sonner
```
```bash
bun x shadcn add @uilab-core/sonner
```
Add the Toaster component
```tsx title='app/layout.tsx'
import { Toaster } from "uilab-core"
export default function RootLayout({ children }) {
return (
{children}
)
}
```
Usage [#usage]
```tsx
import { toast } from "sonner"
```
```tsx
toast("Event has been created.")
```
Examples [#examples]
Types [#types]
Description [#description]
Position [#position]
Use the `position` prop to change the position of the toast.
# Accordion
Usage [#usage]
```tsx
import {
Accordion,
AccordionContent,
AccordionItem,
AccordionTrigger,
} from "uilab-core"
```
```tsx
Example Item 1
Example accordion content
```
Examples [#examples]
Basic [#basic]
Multiple [#multiple]
Disabled [#disabled]
# Alert Dialog
Usage [#usage]
```tsx
import {
Button,
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "uilab-core"
```
```tsx
Show Dialog}
/>
Are you absolutely sure?
This action cannot be undone. This will permanently delete your
account and remove your data from our servers.
CancelContinue
```
Examples [#examples]
Basic [#basic]
A basic alert dialog with a title, description, and cancel and continue buttons.
Small [#small]
Use the `size="sm"` prop to make the alert dialog smaller.
Media [#media]
Use the `AlertDialogMedia` component to add a media element such as an icon or image to the alert dialog.
Small with Media [#small-with-media]
Use the `size="sm"` prop to make the alert dialog smaller and the `AlertDialogMedia` component to add a media element such as an icon or image to the alert dialog.
Destructive [#destructive]
Use the `AlertDialogAction` component to add a destructive action button to the alert dialog.
# Alert
Usage [#usage]
```tsx
import {
Alert,
AlertDescription,
AlertTitle
} from "uilab-core"
```
```tsx
Heads up!
You can add components and dependencies to your app using the cli.
```
Examples [#examples]
Basic [#basic]
A basic alert with an icon, title and description.
Destructive [#destructive]
Use `variant="destructive"` to create a destructive alert.
Action [#action]
Use `AlertAction` to add a button or other action element to the alert.
Custom color [#custom-color]
You can customize the alert colors by adding custom classes such as `bg-amber-50 dark:bg-amber-950` to the `Alert` component.
# Aspect Ratio
Usage [#usage]
```tsx
import { AspectRatio } from "uilab-core"
```
```tsx
```
Examples [#examples]
Square [#square]
A square aspect ratio component using the `ratio={1 / 1}` prop. This is useful for displaying images in a square format.
Portrait [#portrait]
A portrait aspect ratio component using the `ratio={9 / 16}` prop. This is useful for displaying images in a portrait format.
# Avatar
Usage [#usage]
```tsx
import {
Avatar,
AvatarFallback,
AvatarImage
} from "uilab-core"
```
```tsx
CN
```
# Badge
Usage [#usage]
```tsx
import { Badge } from "uilab-core"
```
```tsx
Badge
```
Examples [#examples]
Basic [#basic]
Use the `variant` prop to change the variant of the badge.
Icon [#icon]
You can render an icon inside the badge. Use `data-icon="inline-start"` to render the icon on the left and `data-icon="inline-end"` to render the icon on the right.
Spinner [#spinner]
You can render a spinner inside the badge. Remember to add the `data-icon="inline-start"` or `data-icon="inline-end"` prop to the spinner.
Link [#link]
Use the `render` prop to render a link as a badge.
Custom colors [#custom-colors]
You can customize the colors of a badge by adding custom classes such as `bg-green-50 dark:bg-green-800` to the Badge component.
# Breadcrumb
Usage [#usage]
```tsx
import {
Breadcrumb,
BreadcrumbItem,
BreadcrumbLink,
BreadcrumbList,
BreadcrumbPage,
BreadcrumbSeparator,
} from "uilab-core"
```
```tsx
}>Home
}>
Components
Breadcrumb
```
# Button Group
Usage [#usage]
```tsx
import {
ButtonGroup,
ButtonGroupSeparator,
ButtonGroupText,
} from "uilab-core"
```
```tsx
```
# Button
Usage [#usage]
```tsx
import { Button } from "uilab-core"
```
```tsx
```
Examples [#examples]
Sizes [#sizes]
Use the `size` prop to change the size of the button.
Icon [#icon]
With Icon [#with-icon]
Remember to add the `data-icon="inline-start"` or `data-icon="inline-end"` attribute to the icon for the correct spacing.
Rounded [#rounded]
Use the `rounded-full` class to make the button rounded.
# Calendar
Usage [#usage]
```tsx
import { Calendar } from "uilab-core"
```
```tsx
const [date, setDate] = React.useState(new Date())
return (
)
```
# Card
Usage [#usage]
```tsx
import {
Card,
CardAction,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "uilab-core"
```
```tsx
Card TitleCard DescriptionCard Action
Card Content
Card Footer
```
Examples [#examples]
Sizes [#sizes]
Use the `size="sm"` prop to set the size of the card to small. The small size variant uses smaller spacing.
Image [#image]
Add an image before the card header to create a card with an image.
# Checkbox
Usage [#usage]
```tsx
import { Checkbox } from "@/components/ui/checkbox"
```
```tsx
```
Examples [#examples]
Basic [#basic]
Pair the checkbox with `Field` and `FieldLabel` for proper layout and labeling.
Description [#description]
Use `FieldContent` and `FieldDescription` for helper text.
Disabled [#disabled]
Use the disabled prop to prevent interaction and add the `data-disabled` attribute to the `` component for disabled styles.
Group [#group]
Use multiple fields to create a checkbox list.
# Collapsible
Usage [#usage]
```tsx
import {
Collapsible,
CollapsibleContent,
CollapsibleTrigger,
} from "uilab-core"
```
```tsx
Can I use this in my project?
Yes. Free to use for personal and commercial projects. No attribution
required.
```
Examples [#examples]
Settings Panel [#settings-panel]
Use a trigger button to reveal additional settings.
File Tree [#file-tree]
Use nested collapsibles to build a file tree.
# Command
Usage [#usage]
```tsx
import {
Command,
CommandDialog,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
CommandSeparator,
CommandShortcut,
} from "uilab-core"
```
```tsx
No results found.CalendarSearch EmojiCalculatorProfileBillingSettings
```
# Context Menu
Usage [#usage]
```tsx
import {
ContextMenu,
ContextMenuContent,
ContextMenuItem,
ContextMenuTrigger,
} from "uilab-core"
```
```tsx
Right click hereProfileBillingTeamSubscription
```
Examples [#examples]
Submenu [#submenu]
Use `ContextMenuSub` to nest secondary actions.
Icons [#icons]
Combine icons with labels for quick scanning.
Groups [#groups]
Group related actions and separate them with dividers.
Checkboxes [#checkboxes]
Use `ContextMenuCheckboxItem` for toggles.
Radios [#radios]
Use `ContextMenuRadioItem` for exclusive choices.
# Dialog
Usage [#usage]
```tsx
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog"
```
```tsx
```
# Drawer
Usage [#usage]
```tsx
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "uilab-core"
```
```tsx
```
Examples [#examples]
Scrollable content [#scrollable-content]
Keep actions visible while the content scrolls.
Sides [#sides]
Use the `direction` prop to set the side of the drawer. Available options are top, right, bottom, and left.
# Dropdown Menu
Usage [#usage]
```tsx
import {
Button,
DropdownMenu,
DropdownMenuContent,
DropdownMenuGroup,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "uilab-core"
```
```tsx
}>
Open
My AccountProfileBillingTeamSubscription
```
Examples [#examples]
Basic [#basic]
A basic dropdown menu with labels and separators.
Submenu [#submenu]
Use `DropdownMenuSub` to nest secondary actions.
Shortcuts [#shortcuts]
Add `DropdownMenuShortcut` to show keyboard hints.
Checkboxes [#checkboxes]
Use `DropdownMenuCheckboxItem` for toggles.
Radios [#radios]
Use `DropdownMenuRadioGroup` for exclusive choices.
Complex [#complex]
A richer example combining groups, icons, and submenus.
# Empty
Usage [#usage]
```tsx
import {
Empty,
EmptyContent,
EmptyDescription,
EmptyHeader,
EmptyMedia,
EmptyTitle,
} from "uilab-core"
```
```tsx
No dataNo data found
```
Examples [#examples]
Outline [#outline]
Use the `border` utility class to create an outline empty state.
Avatar [#avatar]
Use the `EmptyMedia` component to display an avatar in the empty state.
Input Group [#input-group]
You can add an `InputGroup` component to the `EmptyContent` component.
# Field
Usage [#usage]
```tsx
import {
Field,
FieldContent,
FieldDescription,
FieldError,
FieldGroup,
FieldLabel,
FieldLegend,
FieldSeparator,
FieldSet,
FieldTitle,
} from "uilab-core"
```
```tsx
```
Examples [#examples]
Input [#input]
Textarea [#textarea]
Select [#select]
Slider [#slider]
Checkbox [#checkbox]
Radio [#radio]
Switch [#switch]
Choice Card [#choice-card]
Field Group [#field-group]
# Hover Card
Usage [#usage]
```tsx
import {
HoverCard,
HoverCardContent,
HoverCardTrigger,
} from "uilab-core"
```
```tsx
Hover
The React Framework – created and maintained by @vercel.
```
Trigger delays [#trigger-delays]
Use delay and closeDelay on the trigger to control when the card opens and closes.
```tsx
Hover
Content
```
Positioning [#positioning]
Use the `side` and `align` props on `HoverCardContent` to control placement.
```tsx
Hover
Content
```
Examples [#examples]
Basic [#basic]
Sides [#sides]
# Components
These components are for client component only! We are actively working to make it compatible on server component
Most base components are direct export of [shadcn components](https://ui.shadcn.com/docs/components) with our custom styling except the complex ones.
It should function exactly the same except the import destination is different.
Basic usage [#basic-usage]
```tsx
import { Button } from "uilab-core" // instead of '@/components/ui'
export function Example() {
return
}
```
Components that are not included from shadcn in the base components are listed below.
* Carousel *(Should be optional, depending on the project)*
* Chart *(Should be optional, depending on the project)*
* [Data Table](/docs/blocks/data-table)
* [Date Picker](/docs/blocks/date-picker)
* [Sonner](/docs/blocks/sonner)
Don't worry, Most complex components are available in our [shadcn registry](/docs/blocks) with our solutions
# Input Group
Usage [#usage]
```tsx
import {
InputGroup,
InputGroupAddon,
InputGroupButton,
InputGroupInput,
InputGroupText,
InputGroupTextarea,
} from "uilab-core"
```
```tsx
```
Examples [#examples]
Icon [#icon]
Text [#text]
Button [#button]
Kbd [#kbd]
Dropdown [#dropdown]
Spinner [#spinner]
Textarea [#textarea]
# Input OTP
Usage [#usage]
```tsx
import {
InputOTP,
InputOTPGroup,
InputOTPSeparator,
InputOTPSlot,
} from "@/components/ui/input-otp"
```
```tsx
```
Examples [#examples]
Separator [#separator]
Use the `` component to add a separator between input groups.
Disabled [#disabled]
Use the `disabled` prop to disable the input.
Controlled [#controlled]
Use the `value` and `onChange` props to control the input value.
Invalid [#invalid]
Use `aria-invalid` on the slots to show an error state.
Form [#form]
# Input
Usage [#usage]
```tsx
import { Input } from "@/components/ui/input"
```
```tsx
```
Examples [#examples]
Basic [#basic]
Field [#field]
Use `Field`, `FieldLabel`, and `FieldDescription` to create an input with a label and description.
Field Group [#field-group]
Use `FieldGroup` to show multiple `Field` blocks and to build forms.
Disabled [#disabled]
Use the `disabled` prop to disable the input. To style the disabled state, add the `data-disabled` attribute to the `Field` component.
Invalid [#invalid]
Use the `aria-invalid` prop to mark the input as invalid. To style the invalid state, add the `data-invalid` attribute to the `Field` component.
File [#file]
Use the `type="file"` prop to create a file input.
Inline [#inline]
Use `Field` with `orientation="horizontal"` to create an inline input. Pair with `Button` to create a search input with a button.
Grid [#grid]
Use a grid layout to place multiple inputs side by side.
Required [#required]
Use the `required` attribute to indicate required inputs.
Badge [#badge]
Use `Badge` in the label to highlight a recommended field.
Input Group [#input-group]
To add icons, text, or buttons inside an input, use the `InputGroup` component. See the [Input Group](/docs/components/input-group) component for more examples.
Button Group [#button-group]
To add buttons to an input, use the `ButtonGroup` component. See the [Button Group](/docs/components/button-group) component for more examples.
Form [#form]
A full form example with multiple inputs, a select, and a button.
# Item
Usage [#usage]
```tsx
import {
Item,
ItemActions,
ItemContent,
ItemDescription,
ItemMedia,
ItemTitle,
} from "uilab-core"
```
```tsx
TitleDescription
```
Item vs Field [#item-vs-field]
Use Field if you need to display a form input such as a checkbox, input, radio, or select.
If you only need to display content such as a title, description, and actions, use Item.
Examples [#examples]
Variants [#variants]
Use the `variant` prop to change the visual style of the item.
Sizes [#sizes]
Use the `size` prop to change the size of the item. Available sizes are `default`, `sm`, and `xs`.
Icon [#icon]
Use `ItemMedia` with `variant="icon"` to display an icon.
Avatar [#avatar]
You can use `ItemMedia` with `variant="avatar"` to display an avatar.
Image [#image]
Use `ItemMedia` with `variant="image"` to display an image.
Group [#group]
Use `ItemGroup` to group related items together.
Header [#header]
Use `ItemHeader` to add a header above the item content.
Link [#link]
Use the `render` prop to render the item as a link. The hover and focus states will be applied to the anchor element.
Dropdown [#dropdown]
# Kbd
Usage [#usage]
```tsx
import { Kbd } from "@/components/ui/kbd"
```
```tsx
Ctrl
```
Examples [#examples]
Group [#group]
Use the `KbdGroup` component to group keyboard keys together.
Button [#button]
Use the `Kbd` component inside a `Button` component to display a keyboard key inside a button.
Tooltip [#tooltip]
You can use the `Kbd` component inside a `Tooltip` component to display a tooltip with a keyboard key.
Input Group [#input-group]
You can use the `Kbd` component inside a `InputGroupAddon` component to display a keyboard key inside an input group.
# Label
Usage [#usage]
```tsx
import { Label } from "uilab-core"
```
```tsx
```
Label in Field [#label-in-field]
For form fields, use the [Field](/docs/components/field) component which includes built-in `FieldLabel`, `FieldDescription`, and `FieldError` components.
```tsx
Your email address
```
# Menubar
Usage [#usage]
```tsx
import {
Menubar,
MenubarContent,
MenubarGroup,
MenubarItem,
MenubarMenu,
MenubarSeparator,
MenubarShortcut,
MenubarTrigger,
} from "@/components/ui/menubar"
```
```tsx
File
New Tab ⌘TNew WindowSharePrint
```
Examples [#examples]
Checkboxes [#checkboxes]
Use `MenubarCheckboxItem` for toggleable options.
Radios [#radios]
Use `MenubarRadioGroup` and `MenubarRadioItem` for single-select options.
Submenus [#submenus]
Use `MenubarSub`, `MenubarSubTrigger`, and `MenubarSubContent` for nested menus.
With Icons [#with-icons]
# Navigation Menu
Usage [#usage]
```tsx
import {
NavigationMenu,
NavigationMenuContent,
NavigationMenuItem,
NavigationMenuLink,
NavigationMenuList,
NavigationMenuTrigger,
} from "uilab-core"
```
```tsx
Item OneLink
```
Link Component (experimental) [#link-component-experimental]
Use the render prop to compose a custom link component such as Next.js Link.
Copy
```tsx
import Link from "next/link"
import {
NavigationMenuItem,
NavigationMenuLink,
navigationMenuTriggerStyle,
} from "uilab-core"
export function NavigationMenuDemo() {
return (
}
className={navigationMenuTriggerStyle()}
>
Documentation
)
}
```
# Pagination
Usage [#usage]
```tsx
import {
Pagination,
PaginationContent,
PaginationEllipsis,
PaginationItem,
PaginationLink,
PaginationNext,
PaginationPrevious,
} from "uilab-core"
```
```tsx
1
2
3
```
Examples [#examples]
Simple [#simple]
A simple pagination with only page numbers.
Icons only [#icons-only]
Use just the previous and next buttons without page numbers. This is useful for data tables with a rows per page selector.
Next.js [#nextjs]
By default the `` component will render an `` tag.
To use the Next.js `` component, make the following updates to `pagination.tsx`.
```diff
+ import Link from "next/link"
- type PaginationLinkProps = ... & React.ComponentProps<"a">
+ type PaginationLinkProps = ... & React.ComponentProps
const PaginationLink = ({...props }: ) => (
-
+
// ...
-
+
)
```
# Popover
Usage [#usage]
```tsx
import {
Popover,
PopoverContent,
PopoverDescription,
PopoverHeader,
PopoverTitle,
PopoverTrigger,
} from "uilab-core"
```
```tsx
}>
Open Popover
TitleDescription text here.
```
Examples [#examples]
Basic [#basic]
A simple popover with a header, title, and description.
Align [#align]
Use the `align` prop on `PopoverContent` to control the horizontal alignment.
With Form [#with-form]
A popover with form fields inside.
# Progress
Usage [#usage]
```tsx
import { Progress } from "@/components/ui/progress"
```
```tsx
```
Examples [#examples]
Label [#label]
Use `ProgressLabel` and `ProgressValue` to add a label and value display.
Controlled [#controlled]
A progress bar that can be controlled by a slider.
# Radio Group
Usage [#usage]
```tsx
import { Label, RadioGroup, RadioGroupItem } from "uilab-core"
```
```tsx
```
Examples [#examples]
Description [#description]
Radio group items with a description using the `Field` component.
Choice Card [#choice-card]
Use `FieldLabel` to wrap the entire `Field` for a clickable card-style selection.
Field set [#field-set]
Use `FieldSet` and `FieldLegend` to group radio items with a label and description.
Disabled [#disabled]
Use the `disabled` prop on `RadioGroup` to disable all items.
Invalid [#invalid]
Use `aria-invalid` on `RadioGroupItem` and `data-invalid` on `Field` to show validation errors.
# Resizable
Usage [#usage]
```tsx
import {
ResizableHandle,
ResizablePanel,
ResizablePanelGroup,
} from "@/components/ui/resizable"
```
```tsx
OneTwo
```
Examples [#examples]
Vertical [#vertical]
Use `orientation="vertical"` for vertical resizing.
Handle [#handle]
Use the `withHandle` prop on `ResizableHandle` to show a visible handle.
# Scroll Area
Usage [#usage]
```tsx
import { ScrollArea } from "uilab-core"
```
```tsx
Your scrollable content here.
```
Examples [#examples]
Horizontal [#horizontal]
Use `ScrollBar` with `orientation="horizontal"` for horizontal scrolling.
# Select
Usage [#usage]
```tsx
import {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectTrigger,
SelectValue,
} from "uilab-core"
```
```tsx
```
Example [#example]
Align Item With Trigger [#align-item-with-trigger]
Use `alignItemWithTrigger` on `SelectContent` to control whether the selected item aligns with the trigger. When `true` (default), the popup positions so the selected item appears over the trigger. When `false`, the popup aligns to the trigger edge.
Groups [#groups]
Use `SelectGroup`, `SelectLabel`, and `SelectSeparator` to organize items.
Scrollable [#scrollable]
A select with many items that scrolls.
Disabled [#disabled]
Invalid [#invalid]
Add the `data-invalid` attribute to the `Field` component and the `aria-invalid` attribute to the `SelectTrigger` component to show an error state.
```tsx
// [!code word:data-invalid]
Fruit
// [!code word:aria-invalid]
```
# Separator
Usage [#usage]
```tsx
import { Separator } from "uilab-core"
```
```tsx
```
Examples [#examples]
Vertical [#vertical]
Use `orientation="vertical"` for a vertical separator.
Menu [#menu]
Vertical separators between menu items with descriptions.
List [#list]
Horizontal separators between list items.
# Sheet
Usage [#usage]
```tsx
import {
Sheet,
SheetClose,
SheetContent,
SheetDescription,
SheetFooter,
SheetHeader,
SheetTitle,
SheetTrigger,
} from "uilab-core"
```
```tsx
OpenAre you absolutely sure?This action cannot be undone.
```
Examples [#examples]
Sides [#sides]
Use the `side` prop on `SheetContent` to set the edge of the screen where the sheet appears. Values are `top`, `right`, `bottom`, or `left`.
No Close Button [#no-close-button]
Use `showCloseButton={false}` on `SheetContent` to hide the close button.
# Sidebar
Usage [#usage]
```tsx title='app/layout.tsx'
import { SidebarProvider, SidebarTrigger } from "@/components/ui/sidebar"
import { AppSidebar } from "@/components/app-sidebar"
export default function Layout({ children }: { children: React.ReactNode }) {
return (
{children}
)
}
```
```tsx title='components/app-sidebar.tsx'
import {
Sidebar,
SidebarContent,
SidebarFooter,
SidebarGroup,
SidebarHeader,
} from "@/components/ui/sidebar"
export function AppSidebar() {
return (
)
}
```
# Skeleton
Usage [#usage]
```tsx
import { Skeleton } from "uilab-core"
```
```tsx
```
Examples [#examples]
Avatar [#avatar]
Card [#card]
Text [#text]
Form [#form]
Table [#table]
# Slider
Usage [#usage]
```tsx
import { Slider } from "@/components/ui/slider"
```
```tsx
```
Examples [#examples]
Range [#range]
Use an array with two values for a range slider.
Multiple Thumbs [#multiple-thumbs]
Use an array with multiple values for multiple thumbs.
Vertical [#vertical]
Use `orientation="vertical"` for a vertical slider.
Controlled [#controlled]
Disabled [#disabled]
Use the `disabled` prop to disable the slider.
# Spinner
Usage [#usage]
```tsx
import { Spinner } from "uilab-core"
```
```tsx
```
Examples [#examples]
Sizes [#sizes]
Use the size-\* utility class to change the size of the spinner.
Button [#button]
Add a spinner to a button to indicate a loading state. Remember to use the `data-icon="inline-start"` prop to add the spinner to the start of the button and the `data-icon="inline-end"` prop to add the spinner to the end of the button.
Badge [#badge]
Add a spinner to a badge to indicate a loading state. Remember to use the `data-icon="inline-start"` prop to add the spinner to the start of the badge and the `data-icon="inline-end"` prop to add the spinner to the end of the badge.
Input Group [#input-group]
Empty [#empty]
# Switch
Usage [#usage]
```tsx
import { Switch } from "@/components/ui/switch"
```
```tsx
```
Examples [#examples]
Description [#description]
Choice Card [#choice-card]
Card-style selection where `FieldLabel` wraps the entire `Field` for a clickable card pattern.
Sizes [#sizes]
Use the size prop to change the size of the switch.
Disabled [#disabled]
Add the `disabled` prop to the `Switch` component to disable the switch. Add the `data-disabled` prop to the `Field` component for styling.
Invalid [#invalid]
Add the `aria-invalid` prop to the `Switch` component to indicate an invalid state. Add the `data-invalid` prop to the `Field` component for styling.
# Tabs
Usage [#usage]
```tsx
import { Tabs, TabsContent, TabsList, TabsTrigger } from "uilab-core"
```
```tsx
AccountPasswordMake changes to your account here.Change your password here.
```
Examples [#examples]
Line [#line]
Use the `variant="line"` prop on `TabsList` for a line style.
Vertical [#vertical]
Use `orientation="vertical"` for vertical tabs.
Disabled [#disabled]
Icons [#icons]
# Textarea
Usage [#usage]
```tsx
import { Textarea } from "@/components/ui/textarea"
```
```tsx
```
Examples [#examples]
Field [#field]
Use `Field`, `FieldLabel`, and `FieldDescription` to create a textarea with a label and description.
Disabled [#disabled]
Use the `disabled` prop to disable the textarea. To style the disabled state, add the `data-disabled` attribute to the `Field` component.
Invalid [#invalid]
Use the `aria-invalid` prop to mark the textarea as invalid. To style the invalid state, add the `data-invalid` attribute to the `Field` component.
Button [#button]
Pair with `Button` to create a textarea with a submit button.
# Toggle Group
Usage [#usage]
```tsx
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"
```
```tsx
ABC
```
Examples [#examples]
Outline [#outline]
Use `variant="outline"` for an outline style.
Sizes [#sizes]
Use the `size` prop to change the size of the toggle group.
Spacing [#spacing]
Use `spacing` to add spacing between toggle group items.
Vertical [#vertical]
Use `orientation="vertical"` for vertical toggle groups.
Disabled [#disabled]
# Toggle
Usage [#usage]
```tsx
import { Toggle } from "uilab-core"
```
```tsx
Toggle
```
Examples [#examples]
Outline [#outline]
Use `variant="outline"` for an outline style.
Sizes [#sizes]
Use the `size` prop to change the size of the toggle.
Text [#text]
Disabled [#disabled]
# Tooltip
Usage [#usage]
```tsx
import {
Tooltip,
TooltipContent,
TooltipTrigger,
} from "uilab-core"
```
```tsx
Hover
Add to library
```
Examples [#examples]
Sides [#sides]
Use the `side` prop to change the position of the tooltip.
With Keyboard Shortcut [#with-keyboard-shortcut]
Disabled Button [#disabled-button]
Show a tooltip on a disabled button by wrapping it with a span.