# Introduction
URL: /docs/introduction
## Key Features [#key-features]
* **Composable by design** - Build complex interfaces by combining simple, focused components
* **Built on top of shadcn/ui** - Uses the same design principles and styling approach as shadcn/ui
* **Copy-paste ready** - Same installation experience as shadcn/ui components
* **Fully customizable** - Built with Tailwind CSS and designed to match your design system
* **Advanced functionality** - Complex components like data tables, media players, and drag-and-drop interfaces
## Why Dice UI? [#why-dice-ui]
Dice UI is a collection of fully composable components that extend shadcn/ui. These components are accessible and customizable to fit your needs. Dice UI is copy-paste ready, no complex setup or configuration required.
Every component follows WCAG guidelines, includes proper ARIA attributes, and supports keyboard navigation out of the box.
## Credits [#credits]
* [Base UI](https://base-ui.com) - Default component primitives.
* [Radix UI](https://radix-ui.com) - Alternative component primitives.
* [shadcn/ui](https://ui.shadcn.com) - Components design and registry distribution.
* [Fumadocs](https://fumadocs.vercel.app) - Documentation.
# December 2024 - Initial Release
URL: /docs/changelog/2024-12-initial-release
Dice UI launched with a set of accessible components built on Radix UI primitives. Tags Input, Combobox, Checkbox Group, and Mention also ship as `@diceui/*` npm packages.
* **Tags Input**
* **Combobox**
* **Sortable**
* **Kbd**
* **Checkbox Group**
* **Mention**
### Tags Input [#tags-input]
Display a list of tags in an input field with the ability to add, edit, and remove them.
[Read the docs](/docs/components/radix/tags-input)
### Combobox [#combobox]
An input with a popover that helps users filter through a list of options.
[Read the docs](/docs/components/radix/combobox)
### Sortable [#sortable]
A drag and drop sortable component for reordering items.
[Read the docs](/docs/components/sortable)
### Kbd [#kbd]
A keyboard key primitive for displaying keyboard shortcuts and key combinations.
[Read the docs](/docs/components/radix/kbd)
### Checkbox Group [#checkbox-group]
A group of checkboxes that allows multiple selections with support for validation and accessibility.
[Read the docs](/docs/components/radix/checkbox-group)
### Mention [#mention]
A component that allows to mention items in a list by a trigger character.
[Read the docs](/docs/components/radix/mention)
# February 2025 - New Components
URL: /docs/changelog/2025-02-new-components
We've added drag and drop boards, layout components, and the first utilities.
* **Kanban**
* **Masonry**
* **Editable**
* **Scroller**
* **Relative Time Card**
* **Composition**
* **Portal**
### Kanban [#kanban]
A drag and drop kanban board component for organizing items into columns.
[Read the docs](/docs/components/kanban)
### Masonry [#masonry]
A responsive masonry layout component for displaying items in a grid.
[Read the docs](/docs/components/masonry)
### Editable [#editable]
An accessible inline editable component for editing text content in place.
[Read the docs](/docs/components/editable)
### Scroller [#scroller]
A scrollable container with customizable scroll shadows and navigation buttons.
[Read the docs](/docs/components/scroller)
### Relative Time Card [#relative-time-card]
A hover card that displays relative time relative to local time with timezone information.
[Read the docs](/docs/components/relative-time-card)
### Composition [#composition]
A collection of utility functions for composing event handlers and refs in React components.
[Read the docs](/docs/utilities/composition)
### Portal [#portal]
Renders React elements into a different part of the DOM tree.
[Read the docs](/docs/utilities/portal)
# March 2025 - Data Table and Listbox
URL: /docs/changelog/2025-03-data-table
We've added a Data Table and a Listbox.
* **Data Table**
* **Listbox**
### Data Table [#data-table]
A powerful and flexible data table component for displaying, filtering, sorting, and paginating tabular data.
[Read the docs](/docs/components/data-table)
### Listbox [#listbox]
A component for creating keyboard-navigable selection lists and grids.
[Read the docs](/docs/components/radix/listbox)
# April 2025 - File Upload and Media Player
URL: /docs/changelog/2025-04-file-upload-media-player
We've added components for uploading files and playing media.
* **File Upload**
* **Media Player**
* **Presence**
### File Upload [#file-upload]
A file upload component with drag and drop, previewing, and progress tracking.
[Read the docs](/docs/components/file-upload)
### Media Player [#media-player]
A fully featured media player component supporting video and audio playback with custom controls.
[Read the docs](/docs/components/media-player)
### Presence [#presence]
Manages element mounting and unmounting with animation support.
[Read the docs](/docs/utilities/presence)
# August 2025 - Color Picker
URL: /docs/changelog/2025-08-color-picker
We've added components for picking and displaying colors, and grouped inputs.
* **Color Picker**
* **Color Swatch**
* **Segmented Input**
### Color Picker [#color-picker]
A color picker component that allows users to select colors using various input methods.
[Read the docs](/docs/components/color-picker)
### Color Swatch [#color-swatch]
A color swatch component for displaying color values with support for transparency and various sizes.
[Read the docs](/docs/components/color-swatch)
### Segmented Input [#segmented-input]
A group of connected input fields that appear as a single segmented visual unit. It shipped as Input Group and was renamed to Segmented Input in November 2025.
[Read the docs](/docs/components/segmented-input)
# September 2025 - New Components
URL: /docs/changelog/2025-09-new-components
We've added six new components.
* **Stepper**
* **Avatar Group**
* **Mask Input**
* **Cropper**
* **Angle Slider**
* **Circular Progress**
### Stepper [#stepper]
A component that guides users through a multi-step process with clear visual progress indicators.
[Read the docs](/docs/components/stepper)
### Avatar Group [#avatar-group]
A component that arranges avatars with overlapping visual effects for displaying multiple users or items. It shipped as Avatar and was renamed to Avatar Group in November 2025.
[Read the docs](/docs/components/avatar-group)
### Mask Input [#mask-input]
An input component that formats user input with predefined patterns like phone numbers, dates, and credit cards.
[Read the docs](/docs/components/mask-input)
### Cropper [#cropper]
A powerful image and video cropper with zoom, rotation, and customizable crop areas.
[Read the docs](/docs/components/cropper)
### Angle Slider [#angle-slider]
An interactive circular slider for selecting angles with support for single values and ranges.
[Read the docs](/docs/components/angle-slider)
### Circular Progress [#circular-progress]
A circular progress indicator that displays completion progress in a ring format with support for indeterminate states.
[Read the docs](/docs/components/circular-progress)
# October 2025 - Data Grid
URL: /docs/changelog/2025-10-data-grid
We've added a spreadsheet-style Data Grid and a handful of smaller components.
* **Data Grid**
* **Marquee**
* **Rating**
* **QR Code**
* **Hitbox**
### Data Grid [#data-grid]
A high-performance editable data grid component with virtualization, keyboard navigation, and comprehensive cell editing capabilities.
[Read the docs](/docs/components/data-grid)
### Marquee [#marquee]
An animated scrolling component that continuously moves content horizontally or vertically.
[Read the docs](/docs/components/marquee)
### Rating [#rating]
An accessible rating component that allows users to provide star ratings with support for half values, keyboard navigation, and form integration.
[Read the docs](/docs/components/rating)
### QR Code [#qr-code]
A flexible QR code component for generating and displaying QR codes with customization options.
[Read the docs](/docs/components/qr-code)
### Hitbox [#hitbox]
A utility component that extends the clickable area of child elements for improved accessibility and user experience.
[Read the docs](/docs/utilities/hitbox)
# October 2025 - Kbd Deprecated
URL: /docs/changelog/2025-10-kbd
[Kbd](/docs/components/radix/kbd) is deprecated and no longer installs. shadcn/ui now ships a [Kbd](https://ui.shadcn.com/docs/components/kbd) component, so use that instead.
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add kbd
```
```bash
pnpm dlx shadcn@latest add kbd
```
```bash
yarn dlx shadcn@latest add kbd
```
```bash
bun x shadcn@latest add kbd
```
### Migrating [#migrating]
| Dice UI | shadcn/ui |
| ---------------------------------- | ------------------------------------------ |
| `Kbd.Root` / `KbdRoot` | `KbdGroup` |
| `Kbd.Key` / `KbdKey` | `Kbd` |
| `Kbd.Separator` / `KbdSeparator` | Text between keys, such as `+`, or nothing |
| `title` on `Kbd.Key` | Wrap the key in `` |
| `variant` and `size` on `Kbd.Root` | `className` |
See the [Kbd](/docs/components/radix/kbd) page for a before and after example.
# November 2025 - New Components
URL: /docs/changelog/2025-11-new-components
We've added ten new components, renamed two, and improved right-to-left support.
* **Scroll Spy**
* **Compare Slider**
* **FPS**
* **Tour**
* **Badge Overflow**
* **Timeline**
* **Time Picker**
* **Stat**
* **Key Value**
* **Stack**
### Scroll Spy [#scroll-spy]
Automatically updates navigation links based on scroll position with support for nested sections and customizable behavior.
[Read the docs](/docs/components/scroll-spy)
### Compare Slider [#compare-slider]
An interactive before/after comparison slider for comparing two elements side by side.
[Read the docs](/docs/components/compare-slider)
### FPS [#fps]
A real-time frames per second (FPS) counter component for monitoring performance.
[Read the docs](/docs/components/fps)
### Tour [#tour]
A guided tour component that highlights elements and provides step-by-step instructions to help users learn about your application.
[Read the docs](/docs/components/tour)
### Badge Overflow [#badge-overflow]
A component that intelligently manages badge overflow by measuring available space and displaying only what fits with an overflow indicator.
[Read the docs](/docs/components/badge-overflow)
### Timeline [#timeline]
A flexible timeline component for displaying chronological events with support for different orientations, RTL layouts, and visual states.
[Read the docs](/docs/components/timeline)
### Time Picker [#time-picker]
An accessible time picker component with inline editing and dropdown selection. Automatically adapts to 12-hour or 24-hour format based on user locale.
[Read the docs](/docs/components/time-picker)
### Stat [#stat]
A flexible component for displaying key metrics and statistics with support for trends, indicators, and descriptions.
[Read the docs](/docs/components/stat)
### Key Value [#key-value]
A dynamic input component for managing key-value pairs with paste support and validation.
[Read the docs](/docs/components/key-value)
### Stack [#stack]
A component that displays items in a stacked layout with hover expansion effects, similar to Sonner toast stacking.
[Read the docs](/docs/components/stack)
### Renamed components [#renamed-components]
* Input Group is now [Segmented Input](/docs/components/segmented-input).
* Avatar is now [Avatar Group](/docs/components/avatar-group). The name Stack now belongs to the new [Stack](/docs/components/stack) component.
### RTL support [#rtl-support]
Components now read direction from Radix's `DirectionProvider` and `useDirection`, so every component shares one global direction context. Wrap your app in [Direction Provider](/docs/utilities/direction-provider) to switch to right-to-left.
# December 2025 - New Components
URL: /docs/changelog/2025-12-new-components
We've added floating action components, dashboard indicators, and a utility for pending states.
* **Action Bar**
* **Speed Dial**
* **Gauge**
* **Status**
* **Pending**
### Action Bar [#action-bar]
A floating action bar that appears at the bottom or top of the viewport to display contextual actions for selected items.
[Read the docs](/docs/components/action-bar)
### Speed Dial [#speed-dial]
A floating action button that reveals a set of actions when triggered.
[Read the docs](/docs/components/speed-dial)
### Gauge [#gauge]
A customizable gauge component that displays values on circular or partial arcs, perfect for dashboards, metrics, and KPIs.
[Read the docs](/docs/components/gauge)
### Status [#status]
A flexible status indicator component with animated ping effect and color variants for displaying system states, user presence, and service health.
[Read the docs](/docs/components/status)
### Pending [#pending]
A utility component that disables interactions, maintains keyboard focus, and ensures proper accessibility for buttons, forms, links, switches, and any interactive element while they are pending.
[Read the docs](/docs/utilities/pending)
# January 2026 - New Components
URL: /docs/changelog/2026-01-new-components
We've added four new components.
* **Selection Toolbar**
* **Swap**
* **Responsive Dialog**
* **Phone Input**
### Selection Toolbar [#selection-toolbar]
A floating toolbar that appears on text selection with formatting and utility actions.
[Read the docs](/docs/components/selection-toolbar)
### Swap [#swap]
A component that swaps between two states with click or hover activation modes.
[Read the docs](/docs/components/swap)
### Responsive Dialog [#responsive-dialog]
A dialog component that automatically switches between a centered dialog on desktop and a bottom drawer on mobile.
[Read the docs](/docs/components/responsive-dialog)
### Phone Input [#phone-input]
An accessible phone input component with automatic country detection and international phone number formatting.
[Read the docs](/docs/components/phone-input)
# February 2026 - Unified Radix UI and Multi-Base Architecture
URL: /docs/changelog/2026-02-unified-radix-multi-base
We've shipped several major improvements to Dice UI's component infrastructure and documentation.
### Unified Radix UI Package [#unified-radix-ui-package]
All components have been migrated from individual `@radix-ui/react-*` packages to the unified [`radix-ui`](https://www.radix-ui.com/primitives/docs/overview/getting-started) package. This follows Radix UI's official consolidation effort and simplifies dependency management.
```diff
- import * as SelectPrimitive from "@radix-ui/react-select"
+ import { Select } from "radix-ui"
```
### Optimized Utility Components [#optimized-utility-components]
The `ClientOnly` and `Portal` components have been rewritten using `useSyncExternalStore` for better performance and proper SSR/hydration handling.
**Benefits:**
* No `useState` + `useLayoutEffect` pattern needed
* Proper SSR/Hydration with explicit server vs client snapshots
* No hydration mismatches
# March 2026 - Base UI
URL: /docs/changelog/2026-03-base-ui
Dice UI components now ship for [Base UI](https://base-ui.com) as well as Radix UI. Each component has a Base UI page and a Radix page, and the registry serves a variant for each base.
### Base UI variants [#base-ui-variants]
36 components shipped Base UI variants in this release, built on `@base-ui/react` primitives. Pick the base that matches your project and install the component the same way as before.
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/action-bar
```
```bash
pnpm dlx shadcn@latest add @diceui/action-bar
```
```bash
yarn dlx shadcn@latest add @diceui/action-bar
```
```bash
bun x shadcn@latest add @diceui/action-bar
```
These components stayed Radix-only at launch:
* [Data Table](/docs/components/data-table) and [Data Grid](/docs/components/data-grid) gained Base UI variants in September 2026.
* [Sortable](/docs/components/sortable) and [Kanban](/docs/components/kanban) gained Base UI variants in September 2026.
* Tags Input, Combobox, Kbd, Checkbox Group, Mention, and Listbox are Radix primitives and remain Radix-only.
# April 2026 - Banner
URL: /docs/changelog/2026-04-banner
We've added a Banner component.
### Banner [#banner]
A notification banner that appears at the top or bottom of the viewport. Supports queuing, priority, and auto-dismiss.
Stack multiple banners in a queue:
[Read the docs](/docs/components/banner)
# June 2026 - Banner Positioning Strategy
URL: /docs/changelog/2026-06-banner-positioning-strategy
The Banner component now supports multiple positioning strategies, giving you more control over how banners are rendered in your layout.
### Positioning Strategies [#positioning-strategies]
The `Banners` provider accepts a new `strategy` prop with four options:
* **`fixed`** (default): Fixed to the viewport, rendered via portal into `document.body`
* **`absolute`**: Positioned within a container, rendered via portal (container needs `position: relative`)
* **`static`**: Rendered inline, pushes content down
* **`sticky`**: Sticks within a scroll container
```tsx
// Inline banner that pushes content down
// Sticky banner within a scroll container
```
`fixed` and `absolute` strategies portal banners out of the DOM tree. `static` and `sticky` render banners inline, either above or below children depending on `side`.
### Other Improvements [#other-improvements]
* Improved type documentation for `Banners` and `Banner` props
* Aligned stacked banner demo action order (primary → secondary) for consistent dismiss targets
# June 2026 - Nova
URL: /docs/changelog/2026-06-nova
Dice UI components now ship in the nova style alongside vega.
### Nova style [#nova-style]
The registry serves `base-nova` and `radix-nova` variants of every component. Projects set up with the nova style get nova-styled Dice UI components with the same install command.
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/banner
```
```bash
pnpm dlx shadcn@latest add @diceui/banner
```
```bash
yarn dlx shadcn@latest add @diceui/banner
```
```bash
bun x shadcn@latest add @diceui/banner
```
The registry now resolves every official shadcn style. See the [September 2026](/docs/changelog/2026-09-presentation) update.
# September 2026 - Data Table v9
URL: /docs/changelog/2026-09-data-table-v9
[Data Table](/docs/components/data-table) and [Data Grid](/docs/components/data-grid) now ship for both Base UI and Radix, and both run on TanStack Table v9.
Installs no longer include a manual import-path rewrite. The registry writes component, config, and type imports in place.
### Data Table [#data-table]
* **Filtering.** Text, number, range, date, date range, boolean, select, and multi-select, each with its own operators. Compose them as a filter list or a command-style filter menu.
* **Sorting.** Multi-column sorting, persisted in the URL.
* **Pagination.** Manual pagination with a required `pageCount`, plus page size options.
* **URL state.** Page, page size, sort, filters, and join operator stay in the query string through [nuqs](https://nuqs.47ng.com).
* **Columns.** Visibility, ordering, sizing, and pinning. Pin with `start` and `end`.
* **Rows.** Single or multi-row selection, with an action bar for the current selection.
* **Keyboard.** `Ctrl/Cmd + Shift + F` toggles the filter menu, `Ctrl/Cmd + Shift + S` toggles the sort menu, and `Backspace` or `Delete` removes the focused filter or sort.
### Data Grid [#data-grid]
A virtualized, spreadsheet-style grid for large datasets.
* **Editing.** In-place editing across short text, long text, number, URL, checkbox, select, multi-select, date, and file cells.
* **Selection.** Cell and row selection with keyboard and mouse, including shift-range selection.
* **Clipboard.** Copy, cut, and paste, including TSV from Excel or Google Sheets. Paste can add rows when the copied range runs past the grid.
* **Undo and redo.** `useDataGridUndoRedo` tracks cell edits, added rows, and deleted rows. `Ctrl/Cmd + Z` undoes, and `Ctrl/Cmd + Shift + Z` or `Ctrl/Cmd + Y` redoes.
* **Find.** `Ctrl/Cmd + F` searches cells and steps through matches.
* **Filter and sort menus.** Operator-based filters and multi-column sorts, both reorderable.
* **Columns.** Resize, pin (`start` / `end`), hide, and reorder. Double-click a resize handle to fit the column.
* **Rows.** Add and delete through `onRowAdd` and `onRowsDelete`. Row height is short, medium, tall, or extra-tall.
* **Modes.** `readOnly` locks editing. `autoFocus` focuses the first navigable cell, or a specific `{ rowIndex, columnId }`. Direction follows `DirectionProvider`.
### TanStack Table v9 [#tanstack-table-v9]
`useDataTable` and `useDataGrid` are still the public hooks. Under them, tables are created with `useTable` and an explicit feature set: `dataTableFeatures` for the table, `dataGridFeatures` for the grid.
Column definitions, columns, rows, and the table instance take that feature set as the first type argument. Row data must extend `RowData`. Column meta and table meta come from the feature set, so the old `declare module "@tanstack/react-table"` augmentation is gone.
```tsx
import type { ColumnDef } from "@tanstack/react-table";
import type { DataTableFeatures } from "@/lib/data-table-features";
const columns: ColumnDef[] = [
// ...
];
const { table } = useDataTable({
data,
columns,
pageCount,
initialState: {
columnPinning: { start: ["select"], end: ["actions"] },
},
});
```
Pinning state is `{ start, end }`. Column visibility state is `ColumnVisibilityState`. Row models are created with `createSortedRowModel`, `createFilteredRowModel`, `createPaginatedRowModel`, and `createFacetedRowModel`, rather than the v8 `get*RowModel` helpers.
# September 2026 - Presentation
URL: /docs/changelog/2026-09-presentation
### Presentation [#presentation]
[Presentation](/docs/components/presentation) is a set of composable primitives for viewing and editing PowerPoint files in the browser. It is built on [`@diceui/pptx`](https://pptx.diceui.com/docs) and ships for both Base UI and Radix.
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/presentation
```
```bash
pnpm dlx shadcn@latest add @diceui/presentation
```
```bash
yarn dlx shadcn@latest add @diceui/presentation
```
```bash
bun x shadcn@latest add @diceui/presentation
```
```tsx
import {
Presentation,
PresentationContent,
PresentationError,
PresentationLoading,
PresentationSelection,
PresentationSlide,
PresentationThumbnailList,
PresentationViewport,
} from "@/components/ui/presentation";
```
`PresentationSelection` is the editing overlay. It supports drag-to-move, resize, inline text, multi-select, and keyboard shortcuts, and it renders only when the file was loaded with `readOnly={false}`.
A companion zoom control is available as `@diceui/presentation-zoom-select`.
### Base UI is the default [#base-ui-is-the-default]
Docs and new installs now default to Base UI with the nova preset (`base-nova`). Radix pages are still published alongside them.
### Styles [#styles]
The registry resolves every official style id: `base` and `radix`, each with vega, nova, maia, lyra, mira, luma, sera, and rhea. Nova itself landed in June.
### Sortable and Kanban [#sortable-and-kanban]
[Sortable](/docs/components/sortable) and [Kanban](/docs/components/kanban) now have Base UI variants.
# October 2026 - Base UI Parity
URL: /docs/changelog/2026-10-base-ui-parity
Base UI and Radix UI now have the same components. Five components that only had Radix versions now have Base UI versions too:
* **Checkbox Group**
* **Combobox**
* **Listbox**
* **Mention**
* **Tags Input**
They're built on the same headless `@diceui/*` packages as their Radix versions, so they share the API, including `asChild` for composition. A `render` prop will follow once these primitives move into a single `@diceui/react` package.
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/combobox
```
```bash
pnpm dlx shadcn@latest add @diceui/combobox
```
```bash
yarn dlx shadcn@latest add @diceui/combobox
```
```bash
bun x shadcn@latest add @diceui/combobox
```
[Read the docs](/docs/components/combobox)
### Components and Utilities pages [#components-and-utilities-pages]
The new [Components](/docs/components) and [Utilities](/docs/utilities) pages list everything in one place, with new items marked the same way as in the sidebar. The sidebar is also flatter: components and utilities are grouped under section headings instead of collapsible folders.
# October 2026 - Command Stack
URL: /docs/changelog/2026-10-command-stack
[Command Stack](/docs/components/command-stack) is a searchable command list with nested pages. Use it inline, in a popover, or in a dialog as a command palette.
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/command-stack
```
```bash
pnpm dlx shadcn@latest add @diceui/command-stack
```
```bash
yarn dlx shadcn@latest add @diceui/command-stack
```
```bash
bun x shadcn@latest add @diceui/command-stack
```
[Read the docs](/docs/components/command-stack)
# October 2026 - compose-refs Deprecated
URL: /docs/changelog/2026-10-composition
Dice UI components no longer copy `lib/compose-refs.ts` into your project. They now use the ref helpers their primitives already ship:
* **Base UI** components use `useMergedRefs` from `@base-ui/utils`, which they now list as a dependency.
* **Radix** components use `useComposedRefs` from `radix-ui/internal`. They need nothing new.
The `compose-refs` utility is deprecated as a result. The [Composition](/docs/utilities/composition) page now covers how to compose Dice UI components, and how to build your own parts, with each library's own tools.
### Migrating [#migrating]
Existing components keep working, because your copy of `lib/compose-refs.ts` stays in place. To drop it, reinstall the components, or update the imports yourself:
```tsx title="Base UI"
import { useComposedRefs } from "@/lib/compose-refs"; // [!code --]
import { useMergedRefs } from "@base-ui/utils/useMergedRefs"; // [!code ++]
```
```tsx title="Radix"
import { useComposedRefs } from "@/lib/compose-refs"; // [!code --]
import { useComposedRefs } from "radix-ui/internal"; // [!code ++]
```
Then delete `lib/compose-refs.ts`. `@diceui/compose-refs` still installs for now and will be removed in a future release.
# October 2026 - Data Grid Table Features
URL: /docs/changelog/2026-10-data-grid-table-features
[Data Grid](/docs/components/data-grid) now runs editing, navigation, clipboard, search, and selection as TanStack Table features. Components subscribe only to the state they render, so large grids re-render less.
* **Row actions.** `getDataGridActionsColumn` adds a menu of actions to each row, and `getDataTableActionsColumn` does the same for [Data Table](/docs/components/data-table).
* **Action bar.** The `actionBar` prop on `DataGrid` renders while rows or a range of cells are selected.
* **Cell selection.** Select a range of cells with the mouse or keyboard, and resize or move columns with the keyboard.
* **Editing.** `enableCellEditing` turns editing off for the whole grid or for a single column.
### Migrating [#migrating]
This release has breaking changes. Reinstall all Data Grid files together, because the components, hook, and `lib` files depend on each other.
* **Table meta is gone.** Read state and call actions through the table and cell instead, such as `cell.setValue()`, `cell.startEditing()`, `table.stopEditing()`, and `table.scrollToCell()`. Custom cell variants spread their props onto `DataGridCellWrapper`.
* **`useDataGrid` returns less.** Pass its result to `DataGrid` as before. Values like `searchState`, `focusedCell`, and `virtualItems` now live in table state.
* **`onRowAdd` returns a row id.** Return `{ rowId, columnId? }` to focus the new row.
* **Data slots are renamed** from `grid-*` to `data-grid-*`.
```tsx
const { table, ...dataGridProps } = useDataGrid({
data,
columns,
onDataChange: setData,
onRowAdd: () => {
const row = { id: crypto.randomUUID() };
setData((prev) => [...prev, row]);
return { rowId: row.id, columnId: "name" };
},
});
return ;
```
[Read the docs](/docs/components/data-grid)
# October 2026 - Data Table Client Mode
URL: /docs/changelog/2026-10-data-table-client-mode
[Data Table](/docs/components/data-table) and [Data Grid](/docs/components/data-grid) are synced with [tablecn](https://tablecn.com), which is now the source for both components. This release has breaking changes. Read the migration notes before reinstalling.
## Data Table [#data-table]
### Breaking changes [#breaking-changes]
* **Renamed components.** Reinstall under the new registry names. The old names no longer resolve.
| Before | After |
| ------------------------------------------------ | --------------------------------------------------------------- |
| `DataTableSortList` (`data-table-sort-list`) | `DataTableSortMenu` (`data-table-sort-menu`) |
| `DataTableFilterList` (`data-table-filter-list`) | `DataTableFilterMenu` (`data-table-filter-menu`) |
| `DataTableFilterMenu` (`data-table-filter-menu`) | `DataTableCommandFilterMenu` (`data-table-command-filter-menu`) |
The name `DataTableFilterMenu` now refers to the filter list. If you used the command-style menu, switch to `DataTableCommandFilterMenu`.
* **One filter model.** `enableAdvancedFilter` is removed from `useDataTable`. `DataTableToolbar` and `DataTableAdvancedToolbar` now read and write the same filters, so you no longer pick a mode in the hook.
* **Per-column URL filters.** Filters no longer live in a single JSON `filters` param. Each filterable column gets its own param, keyed by column id, with the operator as a prefix: `?title=ilike.report&status=in.todo,done`. Filters that use a column's default operator drop the prefix: `?title=report`. Links saved with the old `filters` param stop applying their filters. Sort links in the old JSON format still parse.
* **`queryKeys.filters` is removed.** `queryKeys` now accepts `page`, `perPage`, `sort`, and `joinOperator`.
* **Menu props.** `DataTableFilterMenu` and `DataTableCommandFilterMenu` no longer take `debounceMs`, `throttleMs`, or `shallow`; set those on `useDataTable`. The filter, sort, and view menus accept `disabled` and forward popover content props such as `align`.
* **Renamed types and files.** `lib/parsers` is replaced by `lib/data-table-parsers`, and `dataTableConfig` is replaced by the `FILTER_VARIANTS`, `FILTER_OPERATORS`, and `JOIN_OPERATORS` constants in `lib/data-table-utils`.
| Before | After |
| ----------------------------- | ----------------------------- |
| `ExtendedColumnFilter` | `ColumnFilterItem` |
| `ExtendedColumnSort` | `ColumnSortItem` |
| `Option` | `FilterOption` |
| `QueryKeys` | `DataTableQueryKeys` |
| `getFiltersStateParser` | `getColumnFilterParser` |
* **Memoized cells.** Rows and cells only re-render when the state they subscribe to changes. A custom checkbox column that reads `row.getIsSelected()` no longer updates when clicked. Use `getDataTableSelectColumn()` from `data-table-select-column`, or wrap selection-dependent cells in `Subscribe`.
* **`Table` props are typed as `ReactTable`.** Components take `table: ReactTable`, the type `useDataTable` already returns. Code that passes the hook's `table` straight through doesn't change.
### New [#new]
* **Client mode.** Pass `mode: "client"` to sort, filter, and paginate `data` in the browser, with no `pageCount`. Server mode stays the default and still requires `pageCount`.
```tsx
const { table } = useDataTable({
mode: "client",
data,
columns,
});
```
* **Server helpers.** `getDataTableSearchParams` builds the nuqs parsers from a column config, and `getDataTableQuery` turns the parsed search params into `{ page, perPage, sorting, filters, joinOperator }` for your database query.
```ts
const columnConfigs = {
title: { variant: "text" },
status: { variant: "multiSelect" },
createdAt: { variant: "dateRange" },
} satisfies DataTableColumnConfigs;
const searchParams = getDataTableSearchParams({ columnConfigs });
```
* **Right-to-left.** Layout, pinning, and menus follow `DirectionProvider`.
* **Accessibility.** Fixes from an accessibility audit, and a `data-slot` on every data table part for styling.
* **Performance.** Cells are memoized, so selection and filter changes skip unchanged cells. A fixed table layout stops columns shifting as data loads.
* **Fixes.** Header menu flicker, multi-sort, row highlights, and action bar actions now scoped to the visible selection.
## Data Grid [#data-grid]
### Breaking changes [#breaking-changes-1]
* **Cells are identified by row id, not row index.** `CellPosition` is now `{ rowId, columnId }`. Pass a stable `getRowId` so ids survive sorting and filtering. This changes:
* `onRowAdd` returns `{ rowId, columnId }` to focus a cell in the new row.
* `onRowsDelete` receives `(rows, rowIds)` instead of `(rows, rowIndices)`.
* `onFilesUpload` and `onFilesDelete` receive `rowId` instead of `rowIndex`.
* `autoFocus` takes `{ rowId, columnId }`.
* Custom cells receive `rowId` and `rowHeight` in `DataGridCellProps`. Import the type from `@/lib/data-grid-types`.
```tsx
const onRowAdd = React.useCallback(() => {
const newRow = { id: generateId() };
setData((prev) => [...prev, newRow]);
return { rowId: newRow.id, columnId: "name" }; // [!code highlight]
}, []);
```
* **Row height is table state.** The `rowHeight` option is removed from `useDataGrid`. Set it with `initialState: { rowHeight: "tall" }`, control it with `state.rowHeight` and `onRowHeightChange`, or call `table.setRowHeight`.
* **`onRowAdd` can't return `undefined`.** Return a cell position, or `null` to skip focusing.
### New [#new-1]
* **Cell editing feature.** Editing is a table feature. Turn it off per grid or per column with `enableCellEditing: false`, and read it with `cell.getCanEdit()`, `cell.getIsEditing()`, and `table.setEditingCell`.
* **`onPaste`.** Called with the applied `{ rowId, columnId, value }` updates after a paste, so you can persist them.
* **`enableSingleCellSelection`.** A single click selects the clicked cell.
* **Grid-style keyboard navigation.** Tab and arrow keys move between cells the way a spreadsheet does.
* **Fixes.** The multi-select cell search input.
## Migrating [#migrating]
1. Reinstall the components you use. Replace `data-table-sort-list` and `data-table-filter-list` with `data-table-sort-menu` and `data-table-filter-menu`.
2. Rename imports and types using the tables above.
3. Remove `enableAdvancedFilter` and `queryKeys.filters`.
4. If you parse filters on the server, switch to `getDataTableSearchParams` and `getDataTableQuery`.
5. For Data Grid, replace row indices with row ids in your callbacks and move `rowHeight` into `initialState`.
# October 2026 - Direction Provider Deprecated
URL: /docs/changelog/2026-10-direction-provider
The [Direction Provider](/docs/utilities/direction-provider) utility is deprecated. shadcn/ui now ships a [Direction](https://ui.shadcn.com/docs/components/direction) component with the same `DirectionProvider` and `useDirection` API, and Dice UI components follow it.
### Migrating [#migrating]
Install shadcn/ui's Direction component:
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add direction
```
```bash
pnpm dlx shadcn@latest add direction
```
```bash
yarn dlx shadcn@latest add direction
```
```bash
bun x shadcn@latest add direction
```
Then update your imports:
```tsx
import { DirectionProvider } from "@/components/direction-provider"; // [!code --]
import { DirectionProvider } from "@/components/ui/direction"; // [!code ++]
```
`@diceui/direction-provider` still installs for now and will be removed in a future release.
# October 2026 - Faceted
URL: /docs/changelog/2026-10-faceted
[Faceted](/docs/components/faceted), the popover behind the [Data Table](/docs/components/data-table) and [Data Grid](/docs/components/data-grid) filters, is now its own component. It supports single or multiple selection, async search, and groups.
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/faceted
```
```bash
pnpm dlx shadcn@latest add @diceui/faceted
```
```bash
yarn dlx shadcn@latest add @diceui/faceted
```
```bash
bun x shadcn@latest add @diceui/faceted
```
[Read the docs](/docs/components/faceted)
# October 2026 - useValueAsRef and useRefWithInit
URL: /docs/changelog/2026-10-ref-hooks
Dice UI components use two small ref hooks. They now share Base UI's names, so call sites read the same in both bases:
| Before | After | Base UI | Radix |
| ------------ | ---------------- | ------------------------------- | --------------------------- |
| `useAsRef` | `useValueAsRef` | `@base-ui/utils/useValueAsRef` | `@diceui/use-value-as-ref` |
| `useLazyRef` | `useRefWithInit` | `@base-ui/utils/useRefWithInit` | `@diceui/use-ref-with-init` |
Base UI components no longer copy either hook into your project. Radix components install the renamed hooks.
### Migrating [#migrating]
Existing components keep working, because your copies of the old hooks stay in place. To move over, reinstall the components, or update the imports yourself:
```tsx title="Base UI"
import { useAsRef } from "@/hooks/use-as-ref"; // [!code --]
import { useLazyRef } from "@/hooks/use-lazy-ref"; // [!code --]
import { useRefWithInit } from "@base-ui/utils/useRefWithInit"; // [!code ++]
import { useValueAsRef } from "@base-ui/utils/useValueAsRef"; // [!code ++]
```
```tsx title="Radix"
import { useAsRef } from "@/hooks/use-as-ref"; // [!code --]
import { useLazyRef } from "@/hooks/use-lazy-ref"; // [!code --]
import { useRefWithInit } from "@/hooks/use-ref-with-init"; // [!code ++]
import { useValueAsRef } from "@/hooks/use-value-as-ref"; // [!code ++]
```
Then rename the calls. `@diceui/use-as-ref` and `@diceui/use-lazy-ref` still install for now and will be removed in a future release.
# October 2026 - Skip Nav
URL: /docs/changelog/2026-10-skip-nav
We've added a Skip Nav utility and fixed Base UI installs for three utilities.
### Skip Nav [#skip-nav]
A link that lets keyboard and screen reader users skip past repeated navigation to the main content ([WCAG 2.4.1](https://www.w3.org/WAI/WCAG22/Understanding/bypass-blocks.html)). It stays hidden until it receives keyboard focus. When focused, it uses `z-index: 100` to stack above sticky headers and other `z-50` layers.
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/skip-nav
```
```bash
pnpm dlx shadcn@latest add @diceui/skip-nav
```
```bash
yarn dlx shadcn@latest add @diceui/skip-nav
```
```bash
bun x shadcn@latest add @diceui/skip-nav
```
Render it as the first focusable element and give your main content the exported `MAIN_CONTENT_ID`:
```tsx
import { MAIN_CONTENT_ID, SkipNav } from "@/components/skip-nav";
{/* Navigation */}{/* Page content */}
```
On activation, focus moves to the target, not just the scroll position, so the next Tab continues from the main content. The URL hash doesn't change, so the skip doesn't add a history entry.
[Read the docs](/docs/utilities/skip-nav)
### Base UI utilities [#base-ui-utilities]
[Hitbox](/docs/utilities/hitbox), [Pending](/docs/utilities/pending), and [Visually Hidden](/docs/utilities/visually-hidden) had Base UI docs but no Base UI registry entries, so installing them in a Base UI project failed. They now install for both bases.
# October 2026 - use-isomorphic-layout-effect Deprecated
URL: /docs/changelog/2026-10-use-isomorphic-layout-effect
Dice UI components no longer copy `hooks/use-isomorphic-layout-effect.ts` into your project. They use the hook their primitives already ship:
* **Base UI** components use `useIsoLayoutEffect` from `@base-ui/utils`.
* **Radix** components use `useLayoutEffect` from `radix-ui/internal`.
### Migrating [#migrating]
Existing components keep working, because your copy of the hook stays in place. To drop it, reinstall the components, or update the imports yourself:
```tsx title="Base UI"
import { useIsomorphicLayoutEffect } from "@/hooks/use-isomorphic-layout-effect"; // [!code --]
import { useIsoLayoutEffect } from "@base-ui/utils/useIsoLayoutEffect"; // [!code ++]
```
```tsx title="Radix"
import { useIsomorphicLayoutEffect } from "@/hooks/use-isomorphic-layout-effect"; // [!code --]
import { useLayoutEffect } from "radix-ui/internal"; // [!code ++]
```
Then delete `hooks/use-isomorphic-layout-effect.ts`. `@diceui/use-isomorphic-layout-effect` still installs for now and will be removed in a future release.
# Changelog
URL: /docs/changelog
# Components
URL: /docs/components
# Utilities
URL: /docs/utilities
# Action Bar
URL: /docs/components/base/action-bar
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add "@diceui/action-bar"
```
```bash
pnpm dlx shadcn@latest add "@diceui/action-bar"
```
```bash
yarn dlx shadcn@latest add "@diceui/action-bar"
```
```bash
bun x shadcn@latest add "@diceui/action-bar"
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/react @base-ui/utils
```
```bash
pnpm add @base-ui/react @base-ui/utils
```
```bash
yarn add @base-ui/react @base-ui/utils
```
```bash
bun add @base-ui/react @base-ui/utils
```
Copy and paste the portal component into your
`components/portal.tsx`
file.
Copy and paste the following code into your project.
Update the import paths to match your project setup.
## Layout [#layout]
```tsx
import {
ActionBar,
ActionBarSelection,
ActionBarSeparator,
ActionBarGroup,
ActionBarItem,
ActionBarClose,
} from "@/components/ui/action-bar";
return (
);
```
## Examples [#examples]
### Position [#position]
Use the `side` and `align` props to control where the action bar appears.
## API Reference [#api-reference]
### ActionBar [#actionbar]
The root component that controls the visibility and position of the action bar. Has `role="toolbar"` for accessibility.
### ActionBarSelection [#actionbarselection]
Displays selection information, typically used to show how many items are selected.
### ActionBarGroup [#actionbargroup]
A container for action items that implements roving focus management. Items within a group can be navigated using arrow keys, forming a single tab stop. See [Keyboard Interactions](#keyboard-interactions) for full details.
### ActionBarItem [#actionbaritem]
An interactive button item within the action bar. When used inside a `Group`, participates in roving focus navigation.
### ActionBarClose [#actionbarclose]
A button that closes the action bar by calling the `onOpenChange` callback with `false`. The close button has its own tab stop, separate from the group's roving focus.
### ActionBarSeparator [#actionbarseparator]
A visual separator between action bar items.
## Accessibility [#accessibility]
### Keyboard Interactions [#keyboard-interactions]
The action bar follows the [WAI-ARIA Toolbar pattern](https://www.w3.org/WAI/ARIA/apg/patterns/toolbar/) for keyboard navigation.
# Angle Slider
URL: /docs/components/base/angle-slider
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/angle-slider
```
```bash
pnpm dlx shadcn@latest add @diceui/angle-slider
```
```bash
yarn dlx shadcn@latest add @diceui/angle-slider
```
```bash
bun x shadcn@latest add @diceui/angle-slider
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/react @base-ui/utils
```
```bash
pnpm add @base-ui/react @base-ui/utils
```
```bash
yarn add @base-ui/react @base-ui/utils
```
```bash
bun add @base-ui/react @base-ui/utils
```
Install the direction component from shadcn/ui.
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add direction
```
```bash
pnpm dlx shadcn@latest add direction
```
```bash
yarn dlx shadcn@latest add direction
```
```bash
bun x shadcn@latest add direction
```
Copy and paste the visually hidden input component into your
`components/visually-hidden-input.tsx`
file.
Copy and paste the following code into your project.
Update the import paths to match your project setup.
## Layout [#layout]
Import the parts and compose them together.
```tsx
import {
AngleSlider,
AngleSliderRange,
AngleSliderThumb,
AngleSliderTrack,
AngleSliderValue,
} from "@/components/ui/angle-slider";
return (
)
```
## Examples [#examples]
### **Controlled** State [#controlled-state]
A slider with controlled state management and custom actions.
### Range Selection [#range-selection]
Use multiple thumbs to create angle ranges with minimum step constraints.
### Themes [#themes]
Slider variants with different themes.
### With Form [#with-form]
Integrate the angle slider with form validation and submission.
## Theming [#theming]
You can customize the appearance by targeting specific components:
### Track Theming [#track-theming]
Use `[&>[data-slot='angle-slider-track-rail']]` to style the background track:
```tsx
```
### Range Theming [#range-theming]
```tsx
```
### Thumb Theming [#thumb-theming]
```tsx
```
### Value Theming [#value-theming]
```tsx
```
## API Reference [#api-reference]
### AngleSlider [#angleslider]
The main container component for the angle slider.
### AngleSliderTrack [#angleslidertrack]
The circular track that represents the full range of possible values.
### AngleSliderRange [#anglesliderrange]
The portion of the track that represents the selected range.
### AngleSliderThumb [#anglesliderthumb]
The draggable handle for selecting values.
### AngleSliderValue [#angleslidervalue]
Displays the current value(s) with customizable formatting.
## Accessibility [#accessibility]
The angle slider component includes comprehensive accessibility features:
### Keyboard Interactions [#keyboard-interactions]
## Features [#features]
* Optimized for touch interactions on mobile devices
* Smooth dragging experience with proper pointer handling
* Full right-to-left language support
* Comprehensive keyboard navigation and screen reader support
* Angle ranges with minimum step constraints with multiple thumbs
* Controlled and uncontrolled state management
# Avatar Group
URL: /docs/components/base/avatar-group
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/avatar-group
```
```bash
pnpm dlx shadcn@latest add @diceui/avatar-group
```
```bash
yarn dlx shadcn@latest add @diceui/avatar-group
```
```bash
bun x shadcn@latest add @diceui/avatar-group
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/react
```
```bash
pnpm add @base-ui/react
```
```bash
yarn add @base-ui/react
```
```bash
bun add @base-ui/react
```
Copy and paste the following code into your project.
## Layout [#layout]
```tsx
import { AvatarGroup } from "@/components/ui/avatar-group";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
THRM
```
## Examples [#examples]
### With Truncation [#with-truncation]
Automatically truncate long lists and show overflow indicators with the `max` prop.
### With RTL [#with-rtl]
Support for right-to-left layouts and vertical RTL stacking.
### With Icons [#with-icons]
Use the Avatar Group component with icons or other elements beyond avatars.
### Custom Overflow [#custom-overflow]
Customize the overflow indicator with the `renderOverflow` prop.
## API Reference [#api-reference]
### AvatarGroup [#avatargroup]
The main avatar group container that handles layout and masking of child elements.
# Badge Overflow
URL: /docs/components/base/badge-overflow
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/badge-overflow
```
```bash
pnpm dlx shadcn@latest add @diceui/badge-overflow
```
```bash
yarn dlx shadcn@latest add @diceui/badge-overflow
```
```bash
bun x shadcn@latest add @diceui/badge-overflow
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/react @base-ui/utils
```
```bash
pnpm add @base-ui/react @base-ui/utils
```
```bash
yarn add @base-ui/react @base-ui/utils
```
```bash
bun add @base-ui/react @base-ui/utils
```
Copy and paste the following code into your project.
## Layout [#layout]
```tsx
import { Badge } from "@/components/ui/badge";
import { BadgeOverflow } from "@/components/ui/badge-overflow";
{label}} />
```
## Usage [#usage]
### With Primitive Arrays [#with-primitive-arrays]
When using primitive arrays (strings, numbers), the `getBadgeLabel` prop is optional. The component will automatically use the item itself as the label.
```tsx
{label}}
/>
```
### With Object Arrays [#with-object-arrays]
When using object arrays, the `getBadgeLabel` prop is required to extract the label from each item.
```tsx
item.name}
renderBadge={(item, label) => {label}}
/>
```
## Examples [#examples]
### Multi-line Overflow [#multi-line-overflow]
Display badges across multiple lines using the `lineCount` prop.
### Interactive Tags [#interactive-tags]
Interactive demo showing how to add and remove tags with overflow handling.
## API Reference [#api-reference]
### BadgeOverflow [#badgeoverflow]
The component that measures available space and displays badges with overflow indicators.
## Features [#features]
### Automatic Width Measurement [#automatic-width-measurement]
The component automatically measures badge widths using DOM measurement and caches results for performance. This ensures accurate overflow calculations without manual configuration.
### Computed Container Styles [#computed-container-styles]
The component automatically extracts container padding, gap, badge height, and overflow badge width from computed styles. This means it adapts seamlessly to your CSS without requiring manual prop configuration.
### Multi-line Support [#multi-line-support]
Control how many lines of badges to display using the `lineCount` prop. The component will intelligently wrap badges across lines while respecting the overflow constraints.
### Custom Rendering [#custom-rendering]
Use `renderBadge` and `renderOverflow` props to fully customize how badges and overflow indicators are rendered, allowing complete control over styling and behavior.
### Performance Optimization [#performance-optimization]
The component renders all badges invisibly to measure their actual widths, then uses those measurements to determine which badges fit within the specified line count. ResizeObserver efficiently responds to container size changes.
## Notes [#notes]
* The component measures actual rendered badges to calculate widths accurately (including icons, custom styling, etc.)
* Container styles (padding, gap, badge height, overflow width) are automatically computed from CSS
* Measurements update automatically when items change or container is resized
* Container must have a defined width for overflow calculations to work
# Banner
URL: /docs/components/base/banner
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add "@diceui/banner"
```
```bash
pnpm dlx shadcn@latest add "@diceui/banner"
```
```bash
yarn dlx shadcn@latest add "@diceui/banner"
```
```bash
bun x shadcn@latest add "@diceui/banner"
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/react @base-ui/utils
```
```bash
pnpm add @base-ui/react @base-ui/utils
```
```bash
yarn add @base-ui/react @base-ui/utils
```
```bash
bun add @base-ui/react @base-ui/utils
```
Copy and paste the following code into your project.
Update the import paths to match your project setup.
## Layout [#layout]
```tsx
import {
Banner,
BannerIcon,
BannerContent,
BannerTitle,
BannerDescription,
BannerActions,
BannerClose,
} from "@/components/ui/banner";
return (
);
```
## Examples [#examples]
### Stacked Banners [#stacked-banners]
Use the `Banners` provider to manage multiple banners with a queue system. Banners can be added imperatively using the `useBanners` hook.
## API Reference [#api-reference]
### Banners [#banners]
The root provider for managing a queue of banners. Wrap your application or a section to enable banner queuing.
### Banner [#banner]
An individual banner component. Can be used standalone or within the `Banners` provider.
### BannerIcon [#bannericon]
Container for the banner's icon.
### BannerContent [#bannercontent]
Container for the banner's text content (title and description).
### BannerTitle [#bannertitle]
The banner's title text.
### BannerDescription [#bannerdescription]
The banner's description text.
### BannerActions [#banneractions]
Container for action buttons.
### BannerClose [#bannerclose]
A button that dismisses the banner. Uses the shadcn Button component internally.
### useBanners [#usebanners]
Hook to access banner queue management within a `Banners` provider.
### useBanner [#usebanner]
Hook to access the current banner's context (id, variant, dismissible state, and close handler).
## Accessibility [#accessibility]
### Keyboard Interactions [#keyboard-interactions]
# Checkbox Group
URL: /docs/components/base/checkbox-group
## Installation [#installation]
npm
pnpm
yarn
bun
```bash
npm install @diceui/checkbox-group
```
```bash
pnpm add @diceui/checkbox-group
```
```bash
yarn add @diceui/checkbox-group
```
```bash
bun add @diceui/checkbox-group
```
## Installation with shadcn/ui [#installation-with-shadcnui]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/checkbox-group
```
```bash
pnpm dlx shadcn@latest add @diceui/checkbox-group
```
```bash
yarn dlx shadcn@latest add @diceui/checkbox-group
```
```bash
bun x shadcn@latest add @diceui/checkbox-group
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @diceui/checkbox-group
```
```bash
pnpm add @diceui/checkbox-group
```
```bash
yarn add @diceui/checkbox-group
```
```bash
bun add @diceui/checkbox-group
```
Copy and paste the following code into your project.
## Layout [#layout]
Import the parts, and compose them together.
```tsx
import {
CheckboxGroup,
CheckboxGroupLabel,
CheckboxGroupList,
CheckboxGroupItem,
CheckboxGroupIndicator,
CheckboxGroupDescription,
} from "@diceui/checkbox-group";
return (
)
```
## Animated Checkbox [#animated-checkbox]
Update `tailwind.config.ts` to include the following animation:
```ts
export default {
theme: {
extend: {
keyframes: {
"stroke-dashoffset": {
"0%": { strokeDashoffset: "100%" },
"100%": { strokeDashoffset: "0" },
},
},
animation: {
"stroke-dashoffset": "stroke-dashoffset 0.2s linear forwards",
},
},
},
}
```
Copy and paste the `CheckboxGroupIndicator` block from the following example into your project.
## Examples [#examples]
### Horizontal Orientation [#horizontal-orientation]
### With Validation [#with-validation]
Validate the group with `onValidate` or `required` prop. Can be used for native form validation.
### Multi Selection [#multi-selection]
Hold down the `Shift` key to select and deselect multiple checkboxes at once.
## API Reference [#api-reference]
### CheckboxGroup [#checkboxgroup]
Container for the checkbox group.
### CheckboxGroupLabel [#checkboxgrouplabel]
Label for the checkbox group.
### CheckboxGroupList [#checkboxgrouplist]
Container for checkbox items.
### CheckboxGroupItem [#checkboxgroupitem]
Individual checkbox item.
### CheckboxGroupIndicator [#checkboxgroupindicator]
Visual indicator for the checkbox state.
### CheckboxGroupDescription [#checkboxgroupdescription]
Optional description text for the checkbox group.
### CheckboxGroupMessage [#checkboxgroupmessage]
Error or validation message for the checkbox group.
## Accessibility [#accessibility]
### Keyboard Interactions [#keyboard-interactions]
# Circular Progress
URL: /docs/components/base/circular-progress
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/circular-progress
```
```bash
pnpm dlx shadcn@latest add @diceui/circular-progress
```
```bash
yarn dlx shadcn@latest add @diceui/circular-progress
```
```bash
bun x shadcn@latest add @diceui/circular-progress
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/react
```
```bash
pnpm add @base-ui/react
```
```bash
yarn add @base-ui/react
```
```bash
bun add @base-ui/react
```
Copy and paste the following code into your project.
Add the following CSS animations to your
`globals.css`
file:
```css
@theme {
--animate-spin-around: spin-around 0.8s linear infinite;
@keyframes spin-around {
0% {
transform: rotate(-90deg);
}
100% {
transform: rotate(270deg);
}
}
}
```
## Layout [#layout]
Import the parts and compose them together.
```tsx
import {
CircularProgress,
CircularProgressIndicator,
CircularProgressTrack,
CircularProgressRange,
CircularProgressValueText,
} from "@/components/ui/circular-progress";
return (
)
```
Or use the `Combined` component to get all the parts in one.
```tsx
import { CircularProgressCombined } from "@/components/ui/circular-progress";
```
## Examples [#examples]
### Interactive Demo [#interactive-demo]
A circular progress with interactive controls and simulated upload progress.
### Colors [#colors]
Different color themes using Tailwind CSS stroke and text utilities to customize the track, range, and value text colors.
## Theming [#theming]
The circular progress component uses CSS `currentColor` for stroke colors, making it easy to theme using Tailwind's text or stroke utilities:
### Track Theming [#track-theming]
```tsx
```
### Range Theming [#range-theming]
```tsx
```
### Value Text Theming [#value-text-theming]
```tsx
```
### Custom Stroke Styles [#custom-stroke-styles]
You can also use Tailwind's stroke utilities directly:
```tsx
```
## API Reference [#api-reference]
### CircularProgress [#circularprogress]
The main container component for the circular progress.
### CircularProgressIndicator [#circularprogressindicator]
The SVG container that holds the circular progress tracks and ranges.
### CircularProgressTrack [#circularprogresstrack]
The background circle that represents the full range of possible values.
### CircularProgressRange [#circularprogressrange]
The portion of the circle that represents the current progress value.
### CircularProgressValueText [#circularprogressvaluetext]
The text element that displays the current progress value or custom content.
### CircularProgressCombined [#circularprogresscombined]
The combined component that includes all the parts.
## Accessibility [#accessibility]
### Screen Reader Support [#screen-reader-support]
* Uses the `progressbar` role for proper screen reader identification
* Provides `aria-valuemin`, `aria-valuemax`, `aria-valuenow`, and `aria-valuetext` attributes
* Supports indeterminate state by omitting `aria-valuenow` when value is null
## Notes [#notes]
* The component automatically handles indeterminate states when `value` is `null` or `undefined`
* Progress values are automatically clamped to the valid range between `min` and `max`
* Invalid `max` or `value` props will log console errors and use fallback values
* The indeterminate animation uses CSS custom properties and can be customized via the `--animate-spin-around` variable
* All stroke colors use `currentColor` by default, making them responsive to text color changes
# Color Picker
URL: /docs/components/base/color-picker
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/color-picker
```
```bash
pnpm dlx shadcn@latest add @diceui/color-picker
```
```bash
yarn dlx shadcn@latest add @diceui/color-picker
```
```bash
bun x shadcn@latest add @diceui/color-picker
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/react @base-ui/utils
```
```bash
pnpm add @base-ui/react @base-ui/utils
```
```bash
yarn add @base-ui/react @base-ui/utils
```
```bash
bun add @base-ui/react @base-ui/utils
```
Copy and paste the visually hidden input component into your
`components/visually-hidden-input.tsx`
file.
Copy and paste the following code into your project.
Update the import paths to match your project setup.
## Layout [#layout]
Import the parts, and compose them together.
```tsx
import {
ColorPicker,
ColorPickerAlphaSlider,
ColorPickerArea,
ColorPickerContent,
ColorPickerEyeDropper,
ColorPickerFormatSelect,
ColorPickerHueSlider,
ColorPickerInput,
ColorPickerSwatch,
ColorPickerTrigger,
} from "@/components/ui/color-picker";
return (
)
```
## Examples [#examples]
### Inline Color Picker [#inline-color-picker]
Use the `inline` prop to render the color picker inline instead of in a popover.
### Controlled State [#controlled-state]
A color picker with controlled state management.
### With Form [#with-form]
A color picker with form integration.
## API Reference [#api-reference]
### ColorPicker [#colorpicker]
The main container component for the color picker.
### ColorPickerTrigger [#colorpickertrigger]
The trigger button that opens the color picker popover.
### ColorPickerContent [#colorpickercontent]
The content container for the color picker components.
### ColorPickerArea [#colorpickerarea]
The 2D color area for selecting hue and saturation.
### ColorPickerSwatch [#colorpickerswatch]
A color swatch that displays the current color.
### ColorPickerHueSlider [#colorpickerhueslider]
A slider for adjusting the hue value of the color.
### ColorPickerAlphaSlider [#colorpickeralphaslider]
A slider for adjusting the alpha (transparency) value of the color.
### ColorPickerEyeDropper [#colorpickereyedropper]
A button that activates the browser's native eye dropper tool to pick colors from the screen.
**Note:** The EyeDropper component only renders when the browser supports the native EyeDropper API. It will return `null` in unsupported browsers.
### ColorPickerFormatSelect [#colorpickerformatselect]
A select dropdown for choosing the color format (hex, rgb, hsl, hsb).
### ColorPickerInput [#colorpickerinput]
An input field that displays and allows editing of the color value in the selected format.
## Accessibility [#accessibility]
### Keyboard Interactions [#keyboard-interactions]
## Browser Support [#browser-support]
### EyeDropper API [#eyedropper-api]
The EyeDropper component requires browser support for the native EyeDropper API:
* **Chrome/Edge**: Supported from version 95+
* **Firefox**: Not supported
* **Safari**: Not supported
The component gracefully handles unsupported browsers by not rendering the eye dropper button.
## Color Formats [#color-formats]
The color picker supports the following color formats:
* **HEX**: Hexadecimal color notation (e.g., `#3b82f6`)
* **RGB**: Red, Green, Blue color notation (e.g., `rgb(59, 130, 246)`)
* **HSL**: Hue, Saturation, Lightness color notation (e.g., `hsl(217, 91%, 60%)`)
* **HSB**: Hue, Saturation, Brightness color notation (e.g., `hsb(217, 76%, 96%)`)
All formats support alpha channel for transparency when not using the `withoutAlpha` prop.
# Color Swatch
URL: /docs/components/base/color-swatch
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/color-swatch
```
```bash
pnpm dlx shadcn@latest add @diceui/color-swatch
```
```bash
yarn dlx shadcn@latest add @diceui/color-swatch
```
```bash
bun x shadcn@latest add @diceui/color-swatch
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/react
```
```bash
pnpm add @base-ui/react
```
```bash
yarn add @base-ui/react
```
```bash
bun add @base-ui/react
```
Copy and paste the following code into your project.
## Usage [#usage]
Import the component and use it to display color values.
```tsx
import { ColorSwatch } from "@/components/ui/color-swatch";
```
## Examples [#examples]
### Different Sizes [#different-sizes]
The color swatch component supports three different sizes: `sm`, `default`, and `lg`.
### Transparency Support [#transparency-support]
The color swatch automatically detects transparent colors and displays them with a checkerboard background pattern.
## API Reference [#api-reference]
### ColorSwatch [#colorswatch]
A color swatch component that displays a color value with optional transparency support.
## Accessibility [#accessibility]
The color swatch component includes proper accessibility features:
* **ARIA Label**: Automatically generates descriptive `aria-label` text based on the color value
* **Role**: Uses `role="img"` to indicate it's an image representation of a color
* **Disabled State**: Properly handles disabled state with appropriate visual and interaction changes
### Screen Reader Support [#screen-reader-support]
* When a color value is provided, the `aria-label` reads "Color swatch: \[color-value]"
* When no color is selected, the `aria-label` reads "No color selected"
## Color Format Support [#color-format-support]
The color swatch component supports various color formats:
* **HEX**: `#3b82f6`
* **RGB**: `rgb(59, 130, 246)`
* **RGBA**: `rgba(59, 130, 246, 0.5)`
* **HSL**: `hsl(217, 91%, 60%)`
* **HSLA**: `hsla(217, 91%, 60%, 0.5)`
* **Named Colors**: `blue`, `red`, etc.
## Transparency Detection [#transparency-detection]
The component automatically detects transparent colors by checking for:
* `rgba()` or `hsla()` function notation
* RGB/HSL with 4 values (including alpha)
* Any color format that includes transparency information
When transparency is detected, a checkerboard pattern is displayed behind the color to show the transparency effect. Use the `withoutTransparency` prop to disable this behavior.
# Combobox
URL: /docs/components/base/combobox
## Installation [#installation]
npm
pnpm
yarn
bun
```bash
npm install @diceui/combobox
```
```bash
pnpm add @diceui/combobox
```
```bash
yarn add @diceui/combobox
```
```bash
bun add @diceui/combobox
```
## Installation with shadcn/ui [#installation-with-shadcnui]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/combobox
```
```bash
pnpm dlx shadcn@latest add @diceui/combobox
```
```bash
yarn dlx shadcn@latest add @diceui/combobox
```
```bash
bun x shadcn@latest add @diceui/combobox
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @diceui/combobox
```
```bash
pnpm add @diceui/combobox
```
```bash
yarn add @diceui/combobox
```
```bash
bun add @diceui/combobox
```
Copy and paste the following code into your project.
## Layout [#layout]
Import the parts, and compose them together.
```tsx
import {
Combobox,
ComboboxLabel,
ComboboxAnchor,
ComboboxBadgeList,
ComboboxBadgeItem,
ComboboxBadgeItemDelete,
ComboboxInput,
ComboboxTrigger,
ComboboxCancel,
ComboboxPortal,
ComboboxContent,
ComboboxArrow,
ComboboxLoading,
ComboboxEmpty,
ComboboxGroup,
ComboboxGroupLabel,
ComboboxItem,
ComboboxItemText,
ComboboxItemIndicator,
ComboboxSeparator,
} from "@diceui/combobox";
return (
)
```
## Examples [#examples]
### With Groups [#with-groups]
### With Multiple Selection [#with-multiple-selection]
### With Custom Filter [#with-custom-filter]
### With Debounce [#with-debounce]
### With Virtualization [#with-virtualization]
### With Tags Input [#with-tags-input]
## API Reference [#api-reference]
### Combobox [#combobox]
The container for all combobox parts.
### ComboboxLabel [#comboboxlabel]
An accessible label that describes the combobox. Associates with the input element for screen readers.
### ComboboxAnchor [#comboboxanchor]
A wrapper element that positions the combobox popover relative to the input and trigger. Provides the reference point for popover positioning.
### ComboboxTrigger [#comboboxtrigger]
A button that toggles the combobox popover. Handles focus management and keyboard interactions for opening/closing the popover.
### ComboboxInput [#comboboxinput]
The text input field that users can type into to filter options.
### ComboboxBadgeList [#comboboxbadgelist]
A container for displaying selected items as badges in a multi-select combobox.
### ComboboxBadgeItem [#comboboxbadgeitem]
An individual badge representing a selected item in a multi-select combobox.
### ComboboxBadgeItemDelete [#comboboxbadgeitemdelete]
A button to remove a selected item from the multi-select combobox.
### ComboboxCancel [#comboboxcancel]
A button that clears the input value and resets the filter.
### ComboboxPortal [#comboboxportal]
A portal for rendering the combobox content outside of its DOM hierarchy.
### ComboboxContent [#comboboxcontent]
The popover container for combobox items. Positions the combobox popover relative to the anchor.
### ComboboxArrow [#comboboxarrow]
A visual arrow element that points to the anchor.
### ComboboxLoading [#comboboxloading]
A loading indicator for asynchronous filtering operations.
### ComboboxEmpty [#comboboxempty]
A placeholder component displayed when no options match the current filter.
### ComboboxGroup [#comboboxgroup]
A container for logically grouping related options.
### ComboboxGroupLabel [#comboboxgrouplabel]
A label that describes a group of options.
### ComboboxItem [#comboboxitem]
An interactive item in the combobox list.
### ComboboxItemText [#comboboxitemtext]
The textual content of an item.
### ComboboxItemIndicator [#comboboxitemindicator]
A visual indicator for selected options.
### ComboboxSeparator [#comboboxseparator]
A visual divider for separating options or groups.
## Accessibility [#accessibility]
### Keyboard Interactions [#keyboard-interactions]
# Command Stack
URL: /docs/components/base/command-stack
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/command-stack
```
```bash
pnpm dlx shadcn@latest add @diceui/command-stack
```
```bash
yarn dlx shadcn@latest add @diceui/command-stack
```
```bash
bun x shadcn@latest add @diceui/command-stack
```
Install the command component from shadcn/ui.
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add command
```
```bash
pnpm dlx shadcn@latest add command
```
```bash
yarn dlx shadcn@latest add command
```
```bash
bun x shadcn@latest add command
```
Copy and paste the following code into your project.
Update the import paths to match your project setup.
## Layout [#layout]
Import the parts and compose them together.
```tsx
import {
CommandStack,
CommandStackBreadcrumb,
CommandStackEmpty,
CommandStackGroup,
CommandStackInput,
CommandStackItem,
CommandStackList,
CommandStackPage,
CommandStackShortcut,
} from "@/components/ui/command-stack";
return (
)
```
## Examples [#examples]
### Popover [#popover]
Put the stack in a popover for nested menus, such as a filter menu where each filter opens its options. Set `selectionMode` on a page to make its items toggleable, and control the selection with `value` and `onValueChange`. The stack goes back to the root page whenever the popover closes.
### Command Palette [#command-palette]
Render the stack inside `CommandDialog` to build a command palette. This example uses the `line` input and opens with ⌘ J, since ⌘ K opens the docs search.
### Workspace [#workspace]
A workspace menu that nests pages several levels deep, from members to a member's role. Items can show avatars, descriptions and trailing details.
### Async [#async]
Load a page's items when it opens. `useCommandStack` gives access to the active page, and `CommandStackLoading` hides the empty state while items load.
## API Reference [#api-reference]
### CommandStack [#commandstack]
The root component. It keeps the stack of open pages and the search value, and clears the search whenever the page changes.
### CommandStackBreadcrumb [#commandstackbreadcrumb]
Shows the open pages, using each page's `label`.
### CommandStackInput [#commandstackinput]
The search input. Pressing Backspace while it's empty goes back a page. Set `variant="line"` for a plain row with a divider below it.
### CommandStackList [#commandstacklist]
The scrollable list of pages, groups and items.
### CommandStackEmpty [#commandstackempty]
Shown when no items match the search. It stays hidden while a `CommandStackLoading` is rendered.
### CommandStackLoading [#commandstackloading]
Shown while a page's items load.
### CommandStackPage [#commandstackpage]
A page of items. Only the active page renders its children.
### CommandStackGroup [#commandstackgroup]
A group of items with an optional heading.
### CommandStackItem [#commandstackitem]
A selectable item. Set `page` to open a page when it's selected, which also shows a chevron, or give it a `value` on a page with a `selectionMode` to make it toggleable.
### CommandStackShortcut [#commandstackshortcut]
A keyboard shortcut hint shown at the end of an item.
### CommandStackSeparator [#commandstackseparator]
A line between groups.
### useCommandStack [#usecommandstack]
Reads and changes the stack's pages from any component inside it. It returns `pages`, `activePage`, `search`, `value`, `pushPage(page)`, `popPage()`, `setPages(pages)` and `setValue(value)`.
```tsx
import { useCommandStack } from "@/components/ui/command-stack";
function OpenSettings() {
const { pushPage } = useCommandStack();
return (
pushPage("settings")}>
Settings
);
}
```
## Accessibility [#accessibility]
The input keeps focus while you move between pages. On a nested page, the input shows a back button labelled "Back". The breadcrumb is a labelled navigation landmark that marks the current page, and opening a page announces its label to screen readers.
### Keyboard Interactions [#keyboard-interactions]
# Compare Slider
URL: /docs/components/base/compare-slider
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/compare-slider
```
```bash
pnpm dlx shadcn@latest add @diceui/compare-slider
```
```bash
yarn dlx shadcn@latest add @diceui/compare-slider
```
```bash
bun x shadcn@latest add @diceui/compare-slider
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/react @base-ui/utils
```
```bash
pnpm add @base-ui/react @base-ui/utils
```
```bash
yarn add @base-ui/react @base-ui/utils
```
```bash
bun add @base-ui/react @base-ui/utils
```
Copy and paste the following code into your project.
Update the import paths to match your project setup.
## Layout [#layout]
Import the parts, and compose them together.
```tsx
import {
CompareSlider,
CompareSliderBefore,
CompareSliderAfter,
CompareSliderHandle,
} from "@/components/ui/compare-slider";
return (
)
```
## Examples [#examples]
### Controlled State [#controlled-state]
A compare slider with external controls for the slider position.
### Vertical Orientation [#vertical-orientation]
A compare slider with vertical orientation, perfect for comparing tall images or content.
### Customization [#customization]
Compare slider with custom handle, labels, and vertical orientation.
## API Reference [#api-reference]
### CompareSlider [#compareslider]
The root container for the compare slider component.
### CompareSliderBefore [#comparesliderbefore]
The container for the "before" content that appears on the left (or top in vertical mode).
### CompareSliderAfter [#comparesliderafter]
The container for the "after" content that appears on the right (or bottom in vertical mode).
### CompareSliderHandle [#comparesliderhandle]
The draggable handle that controls the comparison position.
### CompareSliderLabel [#comparesliderlabel]
Custom labels that can be positioned on either side of the comparison.
## Accessibility [#accessibility]
### Keyboard Interactions [#keyboard-interactions]
### Mouse and Touch Interactions [#mouse-and-touch-interactions]
* **Drag**: Click and drag the handle to adjust the comparison position
* **Click**: Click anywhere on the slider container to jump to that position
* **Touch**: Full touch support for mobile devices
## Advanced Usage [#advanced-usage]
### Custom Content Types [#custom-content-types]
The compare slider works with any React content, not just images:
```tsx
Old Design
New Design
```
### Vertical Orientation [#vertical-orientation-1]
Use vertical orientation for comparing content that works better in a vertical layout. The slider handle moves vertically, and the "before" content appears on top while "after" content appears on bottom.
```tsx
{/* Top content */}
{/* Bottom content */}
```
See the [Vertical Orientation example](#vertical-orientation) for a complete demo.
### Custom Labels [#custom-labels]
Add custom labels to identify each side:
```tsx
{/* Content */}
{/* Content */}
```
Or use the `CompareSliderLabel` component for more control:
```tsx
{/* Content */}
{/* Content */}
Original
Enhanced
```
## Browser Support [#browser-support]
### Core Features [#core-features]
All core comparison features work in modern browsers:
* **Chrome/Edge**: Full support
* **Firefox**: Full support
* **Safari**: Full support (iOS 13+)
### Touch Gestures [#touch-gestures]
Touch interactions require modern touch APIs:
* **iOS Safari**: Supported from iOS 13+
* **Chrome Mobile**: Full support
* **Firefox Mobile**: Full support
## Troubleshooting [#troubleshooting]
### Content Overflow [#content-overflow]
Ensure your content is properly contained within the slider:
```tsx
{/* ... */}
```
### Performance with Large Images [#performance-with-large-images]
For large images, consider:
1. Using optimized image formats (WebP, AVIF)
2. Lazy loading images
3. Using appropriate image sizes for the display size
4. Implementing image preloading for smoother transitions
### Mobile Considerations [#mobile-considerations]
On mobile devices:
* Ensure touch targets are adequately sized
* Test on various screen sizes
* Consider using vertical orientation for better mobile UX
* Ensure content is responsive and scales appropriately
## Credits [#credits]
* [Samuel Ferrara](https://unsplash.com/@samferrara?utm_source=unsplash\&utm_medium=referral\&utm_content=creditCopyText) on [Unsplash](https://unsplash.com/photos/aerial-photo-of-foggy-mountains-1527pjeb6jg?utm_source=unsplash\&utm_medium=referral\&utm_content=creditCopyText) - For the demo images used in the examples.
# Cropper
URL: /docs/components/base/cropper
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/cropper
```
```bash
pnpm dlx shadcn@latest add @diceui/cropper
```
```bash
yarn dlx shadcn@latest add @diceui/cropper
```
```bash
bun x shadcn@latest add @diceui/cropper
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/react @base-ui/utils
```
```bash
pnpm add @base-ui/react @base-ui/utils
```
```bash
yarn add @base-ui/react @base-ui/utils
```
```bash
bun add @base-ui/react @base-ui/utils
```
Copy and paste the following code into your project.
Update the import paths to match your project setup.
## Layout [#layout]
Import the parts, and compose them together.
```tsx
import {
Cropper,
CropperArea,
CropperImage,
CropperVideo,
} from "@/components/ui/cropper";
return (
)
```
## Examples [#examples]
### Controlled State [#controlled-state]
A cropper with external controls for zoom, rotation, and crop position.
### With File Upload [#with-file-upload]
A cropper integrated with the [FileUpload](https://diceui.com/docs/components/radix/file-upload) component for uploading and cropping images.
### Different Shapes [#different-shapes]
A cropper with different shapes and configuration options.
### Video Cropping [#video-cropping]
A cropper that works with video content.
## API Reference [#api-reference]
### Cropper [#cropper]
The root container for the cropper component.
### CropperImage [#cropperimage]
The image element to be cropped.
### CropperVideo [#croppervideo]
The video element to be cropped.
### CropperArea [#cropperarea]
The crop area overlay that shows the selected region.
## Accessibility [#accessibility]
### Keyboard Interactions [#keyboard-interactions]
### Mouse and Touch Interactions [#mouse-and-touch-interactions]
* **Drag**: Pan the media within the crop area
* **Scroll/Wheel**: Zoom in and out (can be disabled with `preventScrollZoom`)
* **Pinch**: Zoom and rotate on touch devices
* **Two-finger drag**: Pan while maintaining pinch zoom
## Advanced Usage [#advanced-usage]
### Custom Crop Calculations [#custom-crop-calculations]
You can use the crop data from `onCropComplete` to perform server-side cropping:
```tsx
const onCropComplete = (croppedArea, croppedAreaPixels) => {
// croppedArea contains percentages (0-100)
// croppedAreaPixels contains actual pixel coordinates
// Send to server for processing
cropImage({
x: croppedAreaPixels.x,
y: croppedAreaPixels.y,
width: croppedAreaPixels.width,
height: croppedAreaPixels.height,
});
};
```
### Performance Optimization [#performance-optimization]
The cropper includes several performance optimizations:
* **LRU Caching**: Frequently used calculations are cached
* **RAF Throttling**: UI updates are throttled using requestAnimationFrame
* **Quantization**: Values are quantized to reduce cache misses
* **Lazy Computation**: Expensive calculations are deferred when possible
### Object Fit Modes [#object-fit-modes]
The cropper supports different object fit modes:
* **contain**: Media fits entirely within the container (default)
* **cover**: Media covers the entire container, may be cropped
* **horizontal-cover**: Media width matches container width
* **vertical-cover**: Media height matches container height
## Browser Support [#browser-support]
### Core Features [#core-features]
All core cropping features work in modern browsers:
* **Chrome/Edge**: Full support
* **Firefox**: Full support
* **Safari**: Full support (iOS 13+)
### Touch Gestures [#touch-gestures]
Multi-touch gestures require modern touch APIs:
* **iOS Safari**: Supported from iOS 13+
* **Chrome Mobile**: Full support
* **Firefox Mobile**: Basic touch support
### Video Support [#video-support]
Video cropping requires modern video APIs:
* **Chrome/Edge**: Full support for all video formats
* **Firefox**: Full support with some codec limitations
* **Safari**: Full support with H.264/HEVC
## Troubleshooting [#troubleshooting]
### CORS Issues [#cors-issues]
When cropping images from external domains, ensure proper CORS headers:
```tsx
```
### Performance with Large Media [#performance-with-large-media]
For large images or videos, consider:
1. Pre-processing media to reasonable sizes
2. Using `snapPixels` for crisp rendering
3. Limiting zoom range with `minZoom` and `maxZoom`
4. Reducing `keyboardStep` for smoother interactions
### Mobile Considerations [#mobile-considerations]
On mobile devices:
* Use appropriate viewport meta tags
* Consider touch target sizes for controls
* Test pinch-to-zoom interactions
* Ensure adequate spacing around interactive elements
## Credits [#credits]
* [Unsplash](https://unsplash.com/) - For the photos used in examples.
* [Blender Foundation](https://www.blender.org/) - For the video used in examples.
# Data Grid
URL: /docs/components/base/data-grid
## Installation [#installation]
Install the main component and dependencies:
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add "@diceui/data-grid"
```
```bash
pnpm dlx shadcn@latest add "@diceui/data-grid"
```
```bash
yarn dlx shadcn@latest add "@diceui/data-grid"
```
```bash
bun x shadcn@latest add "@diceui/data-grid"
```
Install the following optional components:
[`getDataGridSelectColumn`](#getdatagridselectcolumn):
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add "@diceui/data-grid-select-column"
```
```bash
pnpm dlx shadcn@latest add "@diceui/data-grid-select-column"
```
```bash
yarn dlx shadcn@latest add "@diceui/data-grid-select-column"
```
```bash
bun x shadcn@latest add "@diceui/data-grid-select-column"
```
[`getDataGridActionsColumn`](#getdatagridactionscolumn):
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add "@diceui/data-grid-actions-column"
```
```bash
pnpm dlx shadcn@latest add "@diceui/data-grid-actions-column"
```
```bash
yarn dlx shadcn@latest add "@diceui/data-grid-actions-column"
```
```bash
bun x shadcn@latest add "@diceui/data-grid-actions-column"
```
[`DataGridSortMenu`](#datagridsortmenu):
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add "@diceui/data-grid-sort-menu"
```
```bash
pnpm dlx shadcn@latest add "@diceui/data-grid-sort-menu"
```
```bash
yarn dlx shadcn@latest add "@diceui/data-grid-sort-menu"
```
```bash
bun x shadcn@latest add "@diceui/data-grid-sort-menu"
```
[`DataGridFilterMenu`](#datagridfiltermenu):
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add "@diceui/data-grid-filter-menu"
```
```bash
pnpm dlx shadcn@latest add "@diceui/data-grid-filter-menu"
```
```bash
yarn dlx shadcn@latest add "@diceui/data-grid-filter-menu"
```
```bash
bun x shadcn@latest add "@diceui/data-grid-filter-menu"
```
[`DataGridRowHeightMenu`](#datagridrowheightmenu):
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add "@diceui/data-grid-row-height-menu"
```
```bash
pnpm dlx shadcn@latest add "@diceui/data-grid-row-height-menu"
```
```bash
yarn dlx shadcn@latest add "@diceui/data-grid-row-height-menu"
```
```bash
bun x shadcn@latest add "@diceui/data-grid-row-height-menu"
```
[`DataGridViewMenu`](#datagridviewmenu):
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add "@diceui/data-grid-view-menu"
```
```bash
pnpm dlx shadcn@latest add "@diceui/data-grid-view-menu"
```
```bash
yarn dlx shadcn@latest add "@diceui/data-grid-view-menu"
```
```bash
bun x shadcn@latest add "@diceui/data-grid-view-menu"
```
[`DataGridKeyboardShortcuts`](#datagridkeyboardshortcuts):
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add "@diceui/data-grid-keyboard-shortcuts"
```
```bash
pnpm dlx shadcn@latest add "@diceui/data-grid-keyboard-shortcuts"
```
```bash
yarn dlx shadcn@latest add "@diceui/data-grid-keyboard-shortcuts"
```
```bash
bun x shadcn@latest add "@diceui/data-grid-keyboard-shortcuts"
```
[`DataGridSkeleton`](#datagridskeleton):
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add "@diceui/data-grid-skeleton"
```
```bash
pnpm dlx shadcn@latest add "@diceui/data-grid-skeleton"
```
```bash
yarn dlx shadcn@latest add "@diceui/data-grid-skeleton"
```
```bash
bun x shadcn@latest add "@diceui/data-grid-skeleton"
```
[`useDataGridUndoRedo`](#usedatagridundoredo):
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add "@diceui/use-data-grid-undo-redo"
```
```bash
pnpm dlx shadcn@latest add "@diceui/use-data-grid-undo-redo"
```
```bash
yarn dlx shadcn@latest add "@diceui/use-data-grid-undo-redo"
```
```bash
bun x shadcn@latest add "@diceui/use-data-grid-undo-redo"
```
## Usage [#usage]
### Basic Data Grid [#basic-data-grid]
```tsx
import { DataGrid } from "@/components/data-grid/data-grid";
import { DataGridKeyboardShortcuts } from "@/components/data-grid/data-grid-keyboard-shortcuts";
import { useDataGrid } from "@/hooks/use-data-grid";
export default function MyDataGrid() {
const [data, setData] = React.useState(initialData);
const columns = React.useMemo(() => [
{
id: "name",
accessorKey: "name",
header: "Name",
meta: {
cell: {
variant: "short-text",
},
},
},
// ... other columns
], []);
const { table, ...dataGridProps } = useDataGrid({
data,
columns,
onDataChange: setData,
getRowId: (row) => row.id,
});
return (
<>
>
);
}
```
### With Toolbar Menus [#with-toolbar-menus]
Add sort, filter, row height, and view menus:
```tsx
import { DataGrid } from "@/components/data-grid/data-grid";
import { DataGridFilterMenu } from "@/components/data-grid/data-grid-filter-menu";
import { DataGridKeyboardShortcuts } from "@/components/data-grid/data-grid-keyboard-shortcuts";
import { DataGridRowHeightMenu } from "@/components/data-grid/data-grid-row-height-menu";
import { DataGridSortMenu } from "@/components/data-grid/data-grid-sort-menu";
import { DataGridViewMenu } from "@/components/data-grid/data-grid-view-menu";
import { useDataGrid } from "@/hooks/use-data-grid";
export default function DataGridToolbarDemo() {
const { table, ...dataGridProps } = useDataGrid({
data,
columns,
onDataChange: setData,
});
return (
{/* Toolbar */}
);
}
```
### With Row Management [#with-row-management]
Add and delete rows with callbacks:
```tsx
const onRowAdd = React.useCallback(() => {
const newRow = { id: generateId() };
setData((prev) => [...prev, newRow]);
return {
rowId: newRow.id,
columnId: "name", // Focus this column after creating the new row
};
}, []);
const onRowsDelete = React.useCallback((rows, rowIds) => {
// rows: array of row data objects
// rowIds: array of row ids
setData((prev) => prev.filter((row) => !rows.includes(row)));
}, []);
const { table, ...dataGridProps } = useDataGrid({
data,
columns,
onDataChange: setData,
onRowAdd,
onRowsDelete,
getRowId: (row) => row.id,
});
```
### With Search [#with-search]
Use the `enableSearch` prop to enable search functionality:
```tsx
const { table, ...dataGridProps } = useDataGrid({
data,
columns,
onDataChange: setData,
enableSearch: true, // Enable search (Ctrl/Cmd+F)
});
return (
<>
>
);
```
### With Paste Support [#with-paste-support]
Use the `enablePaste` prop to enable pasting from clipboard:
```tsx
const { table, ...dataGridProps } = useDataGrid({
data,
columns,
onDataChange: setData,
enablePaste: true, // Enable paste (Ctrl/Cmd+V)
onRowsAdd: async (count) => {
// Called when paste needs to add new rows
// This is more performant than adding rows one by one with the `onRowAdd` prop
const newRows = Array.from({ length: count }, () => ({ id: generateId() }));
setData((prev) => [...prev, ...newRows]);
},
});
```
### With Undo/Redo [#with-undoredo]
Use the `useDataGridUndoRedo` hook to add undo/redo support with keyboard shortcuts (Ctrl/Cmd+Z to undo, Ctrl/Cmd+Shift+Z or Ctrl/Cmd+Y to redo):
```tsx
import { useDataGrid } from "@/hooks/use-data-grid";
import {
useDataGridUndoRedo,
type UndoRedoCellUpdate,
} from "@/hooks/use-data-grid-undo-redo";
export default function MyDataGrid() {
const [data, setData] = React.useState(initialData);
const { trackCellsUpdate, trackRowsAdd, trackRowsDelete } =
useDataGridUndoRedo({
data,
onDataChange: setData,
getRowId: (row) => row.id,
});
const onDataChange = React.useCallback(
(newData: Person[]) => {
// Track cell updates for undo/redo
const cellUpdates: Array = [];
for (let rowIndex = 0; rowIndex < data.length; rowIndex++) {
const oldRow = data[rowIndex];
const newRow = newData[rowIndex];
if (!oldRow || !newRow) continue;
for (const key of Object.keys(oldRow)) {
const oldValue = oldRow[key];
const newValue = newRow[key];
if (!Object.is(oldValue, newValue)) {
cellUpdates.push({
rowId: oldRow.id,
columnId: key,
previousValue: oldValue,
newValue,
});
}
}
}
if (cellUpdates.length > 0) {
trackCellsUpdate(cellUpdates);
}
setData(newData);
},
[data, trackCellsUpdate],
);
const onRowAdd = React.useCallback(() => {
const newRow = { id: generateId() };
setData((prev) => [...prev, newRow]);
trackRowsAdd([newRow]);
return { rowId: newRow.id, columnId: "name" };
}, [trackRowsAdd]);
const onRowsDelete = React.useCallback(
(rows) => {
trackRowsDelete(rows);
setData((prev) => prev.filter((row) => !rows.includes(row)));
},
[trackRowsDelete],
);
const { table, ...dataGridProps } = useDataGrid({
data,
columns,
onDataChange,
onRowAdd,
onRowsDelete,
getRowId: (row) => row.id,
});
return (
<>
>
);
}
```
### Read-Only Mode [#read-only-mode]
Use the `readOnly` prop to make the grid read-only:
```tsx
const { table, ...dataGridProps } = useDataGrid({
data,
columns,
readOnly: true, // Disable all editing
});
```
### RTL Support [#rtl-support]
Wrap the grid in a `DirectionProvider` and the language direction will be automatically detected. The `direction` component is included when you install the data grid — see the [shadcn Direction docs](https://ui.shadcn.com/docs/components/base/direction) for the underlying API.
```tsx
import { DirectionProvider } from "@/components/ui/direction";
return (
)
function DataGridImpl() {
const { table, ...dataGridProps } = useDataGrid({
data,
columns,
});
return (
)
}
```
### Auto Focus [#auto-focus]
Use the `autoFocus` prop to automatically focus any navigable cell on mount:
```tsx
const { table, ...dataGridProps } = useDataGrid({
data,
columns,
autoFocus: true, // Focus first navigable cell
// Or focus a specific cell:
// autoFocus: { rowId: "row-1", columnId: "name" },
});
```
### Custom Height and Stretch Columns [#custom-height-and-stretch-columns]
Control the grid height and column stretching:
```tsx
```
### Loading States [#loading-states]
Use the `DataGridSkeleton` component for loading states:
```tsx
import { Suspense } from "react";
import {
DataGridSkeleton,
DataGridSkeletonGrid,
DataGridSkeletonToolbar,
} from "@/components/data-grid/data-grid-skeleton";
export default function Page() {
return (
}
>
);
}
```
## Cell Variants [#cell-variants]
The Data Grid supports various cell variants for different data formats:
### Short Text Cell [#short-text-cell]
Single-line text input with inline editing:
```tsx
{
id: "name",
accessorKey: "name",
header: "Name",
meta: {
cell: {
variant: "short-text",
},
},
}
```
### Long Text Cell [#long-text-cell]
Multi-line text displayed in a popover with auto-save:
```tsx
{
id: "notes",
accessorKey: "notes",
header: "Notes",
meta: {
cell: {
variant: "long-text",
},
},
}
```
### Number Cell [#number-cell]
Numeric input with optional constraints:
```tsx
{
id: "price",
accessorKey: "price",
header: "Price",
meta: {
cell: {
variant: "number",
min: 0,
max: 1000,
step: 0.01,
},
},
}
```
### URL Cell [#url-cell]
URL input with validation and clickable links:
```tsx
{
id: "website",
accessorKey: "website",
header: "Website",
meta: {
cell: {
variant: "url",
},
},
}
```
### Checkbox Cell [#checkbox-cell]
Boolean checkbox for true/false values:
```tsx
{
id: "isActive",
accessorKey: "isActive",
header: "Active",
meta: {
cell: {
variant: "checkbox",
},
},
}
```
### Select Cell [#select-cell]
Single-select input with predefined options:
```tsx
{
id: "category",
accessorKey: "category",
header: "Category",
meta: {
cell: {
variant: "select",
options: [
{ label: "Electronics", value: "electronics" },
{ label: "Clothing", value: "clothing" },
{ label: "Books", value: "books" },
],
},
},
}
```
### Multi-Select Cell [#multi-select-cell]
Multi-select input with predefined options and badge display:
```tsx
{
id: "skills",
accessorKey: "skills",
header: "Skills",
meta: {
cell: {
variant: "multi-select",
options: [
{ label: "JavaScript", value: "javascript" },
{ label: "TypeScript", value: "typescript" },
{ label: "React", value: "react" },
],
},
},
}
```
### Date Cell [#date-cell]
Date picker with calendar popover:
```tsx
{
id: "startDate",
accessorKey: "startDate",
header: "Start Date",
meta: {
cell: {
variant: "date",
},
},
}
```
### File Cell [#file-cell]
File upload with support for multiple files and file management:
```tsx
{
id: "attachments",
accessorKey: "attachments",
header: "Attachments",
meta: {
cell: {
variant: "file",
maxFileSize: 10 * 1024 * 1024, // 10MB
maxFiles: 5,
accept: "image/*,video/*,audio/*,.pdf,.doc,.docx",
multiple: true,
},
},
}
```
To use file cells, provide upload and delete handlers:
```tsx
const onFilesUpload = React.useCallback(async ({ files, rowId, columnId }) => {
// Upload files to your server/storage
const formData = new FormData();
files.forEach(file => formData.append('files', file));
const response = await fetch('/api/upload', {
method: 'POST',
body: formData
});
const data = await response.json();
// Return array of file metadata
return data.files.map(f => ({
id: f.fileId,
name: f.fileName,
size: f.fileSize,
type: f.fileType,
url: f.fileUrl
}));
}, []);
const onFilesDelete = React.useCallback(async ({ fileIds, rowId, columnId }) => {
// Delete files from your server/storage
await fetch('/api/files', {
method: 'DELETE',
body: JSON.stringify({ fileIds })
});
}, []);
const { table, ...dataGridProps } = useDataGrid({
data,
columns,
onFilesUpload,
onFilesDelete,
});
```
## Row Selection [#row-selection]
Add a selection column to enable row selection with shift-click support using the `getDataGridSelectColumn` helper:
```tsx
import { getDataGridSelectColumn } from "@/components/data-grid/data-grid-select-column";
const columns = [
getDataGridSelectColumn(),
// ... other columns
];
```
You can customize the select column by passing options:
```tsx
getDataGridSelectColumn({
size: 50, // Custom width (default: 40)
enableHiding: true, // Allow hiding via view menu (default: false)
enableResizing: true, // Allow resizing (default: false)
})
```
The shift-click functionality is handled automatically by the `useDataGrid` hook when you include the select column.
## Row Actions [#row-actions]
Add a menu of actions to each row with `getDataGridActionsColumn`, and show bulk actions for the selection with the `actionBar` prop. The action bar renders while rows or a range of cells are selected.
```tsx
import { getDataGridActionsColumn } from "@/components/data-grid/data-grid-actions-column";
import { getDataGridSelectColumn } from "@/components/data-grid/data-grid-select-column";
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
const columns = React.useMemo(() => [
getDataGridSelectColumn(),
// ... other columns
getDataGridActionsColumn({
actions: ({ row }) => (
onRowDelete(row.original)}>
Delete
),
}),
], [onRowDelete]);
const { table, ...dataGridProps } = useDataGrid({
data,
columns,
initialState: {
columnPinning: { start: ["select"], end: ["actions"] },
},
});
return (
}
/>
);
```
## Cell Architecture [#cell-architecture]
The Data Grid uses a three-layer cell composition pattern:
1. **DataGridCell**: Routes to the appropriate cell variant based on the column's `meta.cell.variant` property
2. **Cell Variants**: Implement specific editing UIs for different data variants (text, number, select, etc.)
3. **DataGridCellWrapper**: Provides common functionality for all cells (focus, selection, keyboard interactions)
```tsx
// Cell composition flow
↓
// Based on variant
↓
{/* Cell-specific content */}
```
Each cell variant receives the same props and wraps its content in `DataGridCellWrapper`, which provides:
* Focus management and visual focus ring
* Selection state and highlighting
* Search match highlighting
* Click, double-click, and keyboard event management
* Edit mode triggering (Enter, F2, Space, or typing)
### Creating Custom Cell Variants [#creating-custom-cell-variants]
You can create custom cell variants by implementing the `DataGridCellProps` interface and wrapping your content in `DataGridCellWrapper`:
```tsx
import { DataGridCellWrapper } from "@/components/data-grid/data-grid-cell-wrapper";
import type { DataGridCellProps } from "@/lib/data-grid-types";
export function CustomCell(props: DataGridCellProps) {
const { cell, isEditing, readOnly } = props;
const value = cell.getValue() as CustomCellValue;
function onCommit(nextValue: CustomCellValue) {
if (!readOnly) cell.setValue(nextValue);
cell.table.stopEditing();
}
return (
{/* Your custom cell content */}
);
}
```
Cells read and write data through the cell, with `cell.getValue()` and `cell.setValue()`, and control edit mode with `cell.startEditing()` and `cell.table.stopEditing()`.
## Column Configuration [#column-configuration]
### Enabling Filtering and Sorting [#enabling-filtering-and-sorting]
To enable filtering and sorting on columns, use the `filterFn` from the data grid library:
```tsx
import { getFilterFn } from "@/lib/data-grid-filters";
const columns = React.useMemo(() => {
const filterFn = getFilterFn();
return [
{
id: "name",
accessorKey: "name",
header: "Name",
filterFn, // Enable filtering
// Sorting is enabled by default
meta: {
label: "Name", // Label shown in filter/sort menus
cell: {
variant: "short-text",
},
},
},
// ... other columns
];
}, []);
```
### Column Pinning [#column-pinning]
Pin columns to the left or right:
```tsx
const { table, ...dataGridProps } = useDataGrid({
data,
columns,
initialState: {
columnPinning: {
start: ["select", "name"], // Pin to the start side
end: ["actions"], // Pin to the end side
},
},
});
```
You can also pin/unpin columns dynamically via the column header dropdown menu.
### Column Resizing [#column-resizing]
Column resizing is enabled by default. Users can:
* Drag the column resize handle
* Double-click the resize handle to auto-fit the column width
Set minimum column size using `minSize`:
```tsx
{
id: "name",
accessorKey: "name",
header: "Name",
minSize: 180, // Minimum width in pixels
meta: {
cell: {
variant: "short-text",
},
},
}
```
## Context Menu Actions [#context-menu-actions]
Right-click on cells to access context menu options:
* **Copy** (Ctrl/Cmd+C): Copy selected cells to clipboard
* **Cut** (Ctrl/Cmd+X): Cut selected cells (shows visual indicator)
* **Clear** (Delete/Backspace): Clear content from selected cells
* **Delete rows** (Ctrl/Cmd+Backspace): Remove selected rows (only available when `onRowsDelete` is provided)
## API Reference [#api-reference]
### useDataGrid [#usedatagrid]
Hook for initializing the data grid with state management and editing capabilities.
### useDataGridUndoRedo [#usedatagridundoredo]
Hook for adding undo/redo support to the data grid with keyboard shortcuts and history management.
Returns:
### DataGrid [#datagrid]
Main data grid component with virtualization and editing capabilities.
### getDataGridSelectColumn [#getdatagridselectcolumn]
A utility function that returns a reusable select column definition for the data grid with checkbox selection and shift-click support.
### getDataGridActionsColumn [#getdatagridactionscolumn]
A utility function that returns an actions column with a dropdown menu for each row.
### DataGridColumnHeader [#datagridcolumnheader]
Column header with sorting controls and visual indicators for sort direction.
### DataGridCell [#datagridcell]
Routes to the appropriate cell variant based on the column's `meta.cell.variant` property.
### DataGridCellWrapper [#datagridcellwrapper]
Base wrapper providing common functionality for all cell variants including focus management, selection state, search highlighting, and keyboard interactions.
### DataGridCellVariants [#datagridcellvariants]
Individual cell variants for different data variants. Each variant implements the `DataGridCellProps` interface and wraps its content in `DataGridCellWrapper`.
Available cell variants:
* **ShortTextCell**: Single-line text input with inline contentEditable
* **LongTextCell**: Multi-line textarea displayed in a popover dialog with auto-save
* **NumberCell**: Numeric input with optional min, max, and step constraints
* **UrlCell**: URL input with validation and clickable links
* **SelectCell**: Single-select dropdown with predefined options
* **MultiSelectCell**: Multi-select input with badge display and command palette
* **CheckboxCell**: Boolean checkbox for true/false values
* **DateCell**: Date picker with calendar popover
* **FileCell**: File upload with support for multiple files and file management
### DataGridRow [#datagridrow]
Individual row component with virtualization support for large datasets.
### DataGridSearch [#datagridsearch]
Search menu with keyboard shortcuts for finding and navigating between matching cells in the grid.
### DataGridFilterMenu [#datagridfiltermenu]
Filter menu with drag-and-drop reordering and advanced filtering operators for text, number, date, select, and boolean fields.
### DataGridSortMenu [#datagridsortmenu]
Sort menu with drag-and-drop reordering for multi-column sorting with ascending/descending controls.
### DataGridRowHeightMenu [#datagridrowheightmenu]
Row height menu for adjusting row sizes between short, medium, tall, and extra-tall options.
### DataGridViewMenu [#datagridviewmenu]
View menu for controlling column visibility with search functionality.
### DataGridContextMenu [#datagridcontextmenu]
Right-click context menu for quick access to common cell and row actions like copy, cut, clear, and delete.
### DataGridPasteDialog [#datagridpastedialog]
Dialog for handling paste operations that require adding new rows to the grid.
### DataGridKeyboardShortcuts [#datagridkeyboardshortcuts]
Searchable reference dialog for all available keyboard shortcuts for navigating and interacting with the data grid.
### DataGridSkeleton [#datagridskeleton]
A composable skeleton component for the data grid with toolbar and grid parts for loading states.
```tsx
import {
DataGridSkeleton,
DataGridSkeletonGrid,
DataGridSkeletonToolbar,
} from "@/components/data-grid/data-grid-skeleton";
return (
);
```
#### DataGridSkeletonToolbar [#datagridskeletontoolbar]
#### DataGridSkeletonGrid [#datagridskeletongrid]
## Accessibility [#accessibility]
The Data Grid follows WAI-ARIA guidelines for grid widgets:
* Full keyboard navigation support
* Proper ARIA labels, roles, and properties
* Focus management with visible focus indicators
* Keyboard shortcuts for all actions
* Screen reader friendly cell updates
## Keyboard Interactions [#keyboard-interactions]
### Navigation [#navigation]
### Selection [#selection]
### Editing [#editing]
### Search & Shortcuts [#search--shortcuts]
## Features [#features]
The Data Grid component provides a comprehensive spreadsheet-like experience with:
### Core Features [#core-features]
* **High Performance**: Virtualized rows and columns for handling large datasets (10,000+ rows)
* **Cell Editing**: In-place editing with 9 different cell variants
* **Cell Selection**: Single and multi-cell selection with keyboard and mouse
* **Keyboard Navigation**: Full keyboard support with Excel-like shortcuts
* **Copy/Cut/Paste**: Full clipboard support including paste from Excel/Google Sheets
* **Undo/Redo**: Full history support for cell updates, row additions, and deletions (Ctrl/Cmd+Z, Ctrl/Cmd+Shift+Z)
* **Context Menu**: Right-click actions for cells and rows
* **Search**: Find and navigate to matching cells (Ctrl/Cmd+F)
* **Filtering**: Advanced filtering with multiple operators and drag-and-drop reordering
* **Sorting**: Multi-column sorting with drag-and-drop reordering
* **Row Management**: Add and delete rows with callbacks
* **Column Features**: Resizing, pinning (left/right), hiding, and reordering
### Cell Variants [#cell-variants-1]
* **Text Cells**: Short-text and long-text with auto-save
* **Number Cells**: With min/max/step constraints
* **URL Cells**: With validation and clickable links
* **Date Cells**: Calendar picker with keyboard navigation
* **Select Cells**: Single and multi-select with search
* **Checkbox Cells**: Boolean values
* **File Cells**: Upload and manage multiple files per cell
### Advanced Features [#advanced-features]
* **Smart Paste**: Automatically expands grid when pasting more data than fits
* **Auto-Fill**: Type to start editing, like in Excel
* **Row Heights**: Adjustable row heights (short, medium, tall, extra-tall)
* **RTL Support**: Full right-to-left language support
* **Read-Only Mode**: Lock the grid to prevent editing
* **Auto-Focus**: Focus specific cell on mount
* **Accessibility**: Full ARIA support and keyboard navigation
## Credits [#credits]
* [TanStack Table](https://tanstack.com/table) - For the table state management.
* [TanStack Virtual](https://tanstack.com/virtual) - For the virtualization.
* [shadcn/ui](https://ui.shadcn.com) - For the UI components.
* [Airtable](https://www.airtable.com) and [Glide Data Grid](https://grid.glideapps.com/) - For accessibility and best practices.
# Data Table
URL: /docs/components/base/data-table
## Installation [#installation]
Install the main component and dependencies:
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add "@diceui/data-table"
```
```bash
pnpm dlx shadcn@latest add "@diceui/data-table"
```
```bash
yarn dlx shadcn@latest add "@diceui/data-table"
```
```bash
bun x shadcn@latest add "@diceui/data-table"
```
Filter and sort menu installs bundle a `sortable` component. Primitives come from [`Base UI`](https://base-ui.com).
Wrap your application with the [`NuqsAdapter`](https://nuqs.47ng.com/docs/adapters) for query state management:
```tsx
import { NuqsAdapter } from "nuqs/adapters/next/app";
```
Install the following optional components:
[`DataTableSortMenu`](#datatablesortmenu):
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add "@diceui/data-table-sort-menu"
```
```bash
pnpm dlx shadcn@latest add "@diceui/data-table-sort-menu"
```
```bash
yarn dlx shadcn@latest add "@diceui/data-table-sort-menu"
```
```bash
bun x shadcn@latest add "@diceui/data-table-sort-menu"
```
[`DataTableFilterMenu`](#datatablefiltermenu):
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add "@diceui/data-table-filter-menu"
```
```bash
pnpm dlx shadcn@latest add "@diceui/data-table-filter-menu"
```
```bash
yarn dlx shadcn@latest add "@diceui/data-table-filter-menu"
```
```bash
bun x shadcn@latest add "@diceui/data-table-filter-menu"
```
[`DataTableCommandFilterMenu`](#datatablecommandfiltermenu):
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add "@diceui/data-table-command-filter-menu"
```
```bash
pnpm dlx shadcn@latest add "@diceui/data-table-command-filter-menu"
```
```bash
yarn dlx shadcn@latest add "@diceui/data-table-command-filter-menu"
```
```bash
bun x shadcn@latest add "@diceui/data-table-command-filter-menu"
```
[`getDataTableSelectColumn`](#row-selection):
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add "@diceui/data-table-select-column"
```
```bash
pnpm dlx shadcn@latest add "@diceui/data-table-select-column"
```
```bash
yarn dlx shadcn@latest add "@diceui/data-table-select-column"
```
```bash
bun x shadcn@latest add "@diceui/data-table-select-column"
```
[`getDataTableActionsColumn`](#row-actions):
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add "@diceui/data-table-actions-column"
```
```bash
pnpm dlx shadcn@latest add "@diceui/data-table-actions-column"
```
```bash
yarn dlx shadcn@latest add "@diceui/data-table-actions-column"
```
```bash
bun x shadcn@latest add "@diceui/data-table-actions-column"
```
## Layout [#layout]
Import the components and compose them together:
```tsx
import { DataTable } from "@/components/data-table/data-table";
import { DataTableSortMenu } from "@/components/data-table/data-table-sort-menu";
import { DataTableToolbar } from "@/components/data-table/data-table-toolbar";
import { useDataTable } from "@/hooks/use-data-table";
const { table } = useDataTable({
data,
columns,
pageCount,
});
return (
);
```
For the advanced toolbar with a filter menu, swap the toolbar:
```tsx
import { DataTableAdvancedToolbar } from "@/components/data-table/data-table-advanced-toolbar";
import { DataTableFilterMenu } from "@/components/data-table/data-table-filter-menu";
return (
);
```
## Walkthrough [#walkthrough]
Define columns with appropriate metadata:
```tsx
import { Text, CalendarIcon, DollarSign } from "lucide-react";
import { DataTableColumnHeader } from "@/components/data-table/data-table-column-header";
const columns = React.useMemo(() => [
{
// Provide an unique id for the column
// This id will be used as query key for the column filter
id: "title", // [!code highlight]
accessorKey: "title",
header: ({ column }) => (
),
cell: ({ row }) =>
{row.getValue("title")}
,
// Define the column meta options for sorting, filtering, and view options
meta: { // [!code highlight]
label: "Title", // [!code highlight]
placeholder: "Search titles...", // [!code highlight]
variant: "text", // [!code highlight]
icon: Text, // [!code highlight]
}, // [!code highlight]
// By default, the column will not be filtered. Set to `true` to enable filtering.
enableColumnFilter: true, // [!code highlight]
},
], []);
```
Initialize the table state using the `useDataTable` hook:
```tsx
import { useDataTable } from "@/hooks/use-data-table";
function DataTableDemo() {
const { table } = useDataTable({
data,
columns,
// Pass the total number of pages for server-side data,
// or set `mode: "client"` to sort, filter, and paginate in the browser
pageCount, // [!code highlight]
initialState: {
sorting: [{ id: "createdAt", desc: true }],
pagination: { pageSize: 10 },
},
// Unique identifier for rows, can be used for unique row selection
getRowId: (row) => row.id, // [!code highlight]
});
return (
// ... render table
);
}
```
Pass the table instance to the `DataTable`, and `DataTableToolbar` components:
```tsx
import { DataTable } from "@/components/data-table/data-table";
import { DataTableToolbar } from "@/components/data-table/data-table-toolbar";
import { DataTableSortMenu } from "@/components/data-table/data-table-sort-menu";
function DataTableDemo() {
return (
);
}
```
For advanced filtering, use the `DataTableAdvancedToolbar` component:
```tsx
import { DataTableAdvancedToolbar } from "@/components/data-table/data-table-advanced-toolbar";
import { DataTableFilterMenu } from "@/components/data-table/data-table-filter-menu";
import { DataTableSortMenu } from "@/components/data-table/data-table-sort-menu";
function DataTableDemo() {
return (
);
}
```
Alternatively, swap out `DataTableFilterMenu` with `DataTableCommandFilterMenu` for a command palette-style interface:
```tsx
import { DataTableAdvancedToolbar } from "@/components/data-table/data-table-advanced-toolbar";
import { DataTableFilterMenu } from "@/components/data-table/data-table-filter-menu"; // [!code --]
import { DataTableCommandFilterMenu } from "@/components/data-table/data-table-command-filter-menu"; // [!code ++]
import { DataTableSortMenu } from "@/components/data-table/data-table-sort-menu";
function DataTableDemo() {
return (
{/* [!code --] */}
{/* [!code ++] */}
);
}
```
Render an action bar on row selection:
```tsx
import { ActionBar } from "@/components/ui/action-bar";
function TableActionBar({ table }: { table: Table }) {
const rows = table.getFilteredSelectedRowModel().rows;
const onOpenChange = React.useCallback((open: boolean) => {
if (!open) {
table.toggleAllRowsSelected(false);
}
},
[table],
);
return (
0} onOpenChange={onOpenChange}>
{/* Add your custom actions here */}
);
}
function DataTableDemo() {
return (
}
>
);
}
```
## Row Selection [#row-selection]
Use `getDataTableSelectColumn` to add a checkbox column for selecting rows:
```tsx
import { getDataTableSelectColumn } from "@/components/data-table/data-table-select-column";
const columns = React.useMemo[]>(
() => [
getDataTableSelectColumn(),
// ...other columns
],
[],
);
```
Cells are memoized and only re-render when the state they subscribe to changes. If you render your own selection-dependent cell, read the selection inside `Subscribe` instead of calling `row.getIsSelected()` directly:
```tsx
import { Subscribe } from "@tanstack/react-table";
cell: ({ row }) => (
selection[row.id] === true}
>
{(isSelected) => (
row.toggleSelected(!!value)}
/>
)}
),
```
## Row Actions [#row-actions]
Use `getDataTableActionsColumn` to add a menu of actions to each row:
```tsx
import { getDataTableActionsColumn } from "@/components/data-table/data-table-actions-column";
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
const columns = React.useMemo[]>(
() => [
// ...other columns
getDataTableActionsColumn({
actions: ({ row }) => (
onRowDelete(row.original)}>
Delete
),
}),
],
[onRowDelete],
);
```
Pin it to the end with `initialState.columnPinning.end`, like `{ start: ["select"], end: ["actions"] }`.
## Client and Server Mode [#client-and-server-mode]
`useDataTable` runs in one of two modes. Both keep pagination, sorting, and filters in the URL.
`pageCount` is required in server mode and not allowed in client mode. TypeScript reports an error if you pass it in client mode or leave it out in server mode.
### Client Mode [#client-mode]
Use client mode when the full dataset fits in the browser:
```tsx
const { table } = useDataTable({
mode: "client",
data,
columns,
getRowId: (row) => row.id,
});
```
### Server Mode [#server-mode]
Use server mode for large datasets. Describe the filterable and sortable columns once, and share that config between the server and the column definitions.
Define the column configs and search params:
```ts title="lib/validations.ts"
import { createSearchParamsCache } from "nuqs/server";
import type { DataTableColumnConfig } from "@/lib/data-table-types";
import { getDataTableSearchParams } from "@/lib/data-table-parsers";
export const tasksColumnConfigs = {
// Sortable, not filterable
code: { isSortable: false },
title: { variant: "text" },
status: { variant: "multiSelect" },
estimatedHours: { variant: "range" },
createdAt: { variant: "dateRange" },
} as const satisfies Record;
export const searchParamsCache = createSearchParamsCache(
getDataTableSearchParams({
columnConfigs: tasksColumnConfigs,
defaultSorting: [{ id: "createdAt", desc: true }],
}),
);
```
Parse the search params on the server and turn them into a query:
```tsx title="app/page.tsx"
import { getDataTableQuery } from "@/lib/data-table-parsers";
export default async function Page(props: {
searchParams: Promise>;
}) {
const search = searchParamsCache.parse(await props.searchParams);
// { page, perPage, sorting, filters, joinOperator }
const query = getDataTableQuery(search, tasksColumnConfigs);
const { data, pageCount } = await getTasks(query);
return ;
}
```
Type the query function's input with `DataTableColumnConfigsQuery`. Each filter has an `id`, `variant`, `operator`, and `value` to map onto your database query.
Spread `getColumnOptions` into each column so filtering and sorting match the config:
```tsx
import { getColumnOptions } from "@/lib/data-table-parsers";
{
id: "title",
accessorKey: "title",
meta: { label: "Title", variant: "text" },
...getColumnOptions(tasksColumnConfigs.title), // [!code highlight]
}
```
Pass the server data and `pageCount` to `useDataTable`. Pass `startTransition` from `React.useTransition()` to show loading states while the server re-renders:
```tsx
const [isPending, startTransition] = React.useTransition();
const { table } = useDataTable({
data,
columns,
pageCount,
startTransition,
});
```
### URL Format [#url-format]
Each filterable column has its own search param, keyed by column id. The value is the operator followed by the filter value. When a filter uses the column's default operator, the operator is left out.
```txt
?title=report # text, default operator (contains)
?title=eq.Weekly%20report # text, "is"
?status=todo,done # multi-select, default operator (has any of)
?estimatedHours=2,8 # range, default operator (between)
?estimatedHours=gt.4 # range, "is greater than"
?createdAt=is.empty # no value
?sort=createdAt.desc,title.asc
?joinOperator=or
```
## API Reference [#api-reference]
### Column Definitions [#column-definitions]
The column definitions are used to define the columns of the data table.
```tsx
const columns = React.useMemo[]>(() => [
{
// Required: Unique identifier for the column
id: "title", // [!code highlight]
// Required: Key to access the data, `accessorFn` can also be used
accessorKey: "title", // [!code highlight]
// Optional: Custom header component
header: ({ column }) => (
),
// Optional: Custom cell component
cell: ({ row }) =>
{row.getValue("title")}
,
// Optional: Meta options for filtering, sorting, and view options
meta: {
label: "Title",
placeholder: "Search titles...",
variant: "text",
icon: Text,
},
// By default, the column will not be filtered. Set to `true` to enable filtering.
enableColumnFilter: true, // [!code highlight]
},
{
id: "status",
// Access nested data using `accessorFn`
accessorFn: (row) => row.lineItem.status,
header: "Status",
meta: {
label: "Status",
variant: "select",
options: [
{ label: "Active", value: "active" },
{ label: "Inactive", value: "inactive" },
],
},
enableColumnFilter: true,
},
], []);
```
#### Properties [#properties]
Core configuration options for defining columns.
#### Column Meta [#column-meta]
Column meta options for filtering, sorting, and view options.
#### Filter Variants [#filter-variants]
Available filter variants for [column meta](#column-meta).
Reference the [TanStack Table Column Definitions Guide](https://tanstack.com/table/latest/docs/guide/column-defs#column-definitions-guide) for detailed column definition guide.
### useDataTable [#usedatatable]
A hook for initializing the data table with state management.
### DataTable [#datatable]
The main data table component.
### getDataTableActionsColumn [#getdatatableactionscolumn]
A utility function that returns an actions column with a dropdown menu for each row.
### DataTableColumnHeader [#datatablecolumnheader]
Custom header component for columns with sorting.
### DataTableToolbar [#datatabletoolbar]
Standard toolbar with filtering and view options.
### DataTableAdvancedToolbar [#datatableadvancedtoolbar]
Advanced toolbar with more comprehensive filtering capabilities.
### DataTableViewOptions [#datatableviewoptions]
Controls column visibility and display preferences in the data table.
### DataTableSortMenu [#datatablesortmenu]
List of applied sorting with ability to add, remove, and modify sorting.
### DataTableFilterMenu [#datatablefiltermenu]
List of applied filters with ability to add, remove, and modify filters.
### DataTableCommandFilterMenu [#datatablecommandfiltermenu]
Command palette-style filter menu with ability to add, remove, and modify filters.
### DataTablePagination [#datatablepagination]
Pagination controls for the data table.
## Accessibility [#accessibility]
### Keyboard Interactions [#keyboard-interactions]
## Features [#features]
* **Advanced Filtering** - Multiple filter types (text, number, date, select, multi-select) with customizable operators
* **URL State Management** - Sync table state with URL search params using [nuqs](https://nuqs.47ng.com)
* **Sorting** - Multi-column sorting with persistent state
* **Pagination** - Server-side or client-side pagination with customizable page sizes
* **Column Visibility** - Toggle column visibility with view options menu
* **Row Selection** - Single or multi-row selection with action bar
* **Column Pinning** - Pin columns to left or right for better UX
* **Keyboard Navigation** - Full keyboard support with shortcuts for filter and sort menus
* **Responsive** - Mobile-first design with overflow handling
* **Customizable** - Flexible API for custom filters, columns, and actions
## Credits [#credits]
* [shadcn/ui](https://github.com/shadcn-ui/ui/tree/main/apps/www/app/\(app\)/examples/tasks) - For the initial implementation of the data table.
# Editable
URL: /docs/components/base/editable
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/editable
```
```bash
pnpm dlx shadcn@latest add @diceui/editable
```
```bash
yarn dlx shadcn@latest add @diceui/editable
```
```bash
bun x shadcn@latest add @diceui/editable
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/react @base-ui/utils
```
```bash
pnpm add @base-ui/react @base-ui/utils
```
```bash
yarn add @base-ui/react @base-ui/utils
```
```bash
bun add @base-ui/react @base-ui/utils
```
Copy and paste the visually hidden input component into your
`components/visually-hidden-input.tsx`
file.
Copy and paste the following code into your project.
Update the import paths to match your project setup.
## Layout [#layout]
Import the parts, and compose them together.
```tsx
import {
Editable,
EditableLabel,
EditableArea,
EditablePreview,
EditableInput,
EditableTrigger,
EditableToolbar,
EditableSubmit,
EditableCancel,
} from "@/components/ui/editable";
return (
)
```
## Examples [#examples]
### With Double Click [#with-double-click]
Trigger edit mode with double click instead of single click.
### With Autosize [#with-autosize]
Input that automatically resizes based on content.
### Todo List [#todo-list]
### With Form [#with-form]
Control the editable component in a form.
## API Reference [#api-reference]
### Editable [#editable]
The main container component for editable functionality.
### EditableLabel [#editablelabel]
The label component for the editable field.
### EditableArea [#editablearea]
Container for the preview and input components.
### EditablePreview [#editablepreview]
The preview component that displays the current value.
### EditableInput [#editableinput]
The input component for editing the value.
### EditableTrigger [#editabletrigger]
Button to trigger edit mode.
### EditableToolbar [#editabletoolbar]
Container for action buttons.
### EditableSubmit [#editablesubmit]
Button to submit changes.
### EditableCancel [#editablecancel]
Button to cancel changes.
## Accessibility [#accessibility]
### Keyboard Interactions [#keyboard-interactions]
# Faceted
URL: /docs/components/base/faceted
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/faceted
```
```bash
pnpm dlx shadcn@latest add @diceui/faceted
```
```bash
yarn dlx shadcn@latest add @diceui/faceted
```
```bash
bun x shadcn@latest add @diceui/faceted
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/react @base-ui/utils cmdk
```
```bash
pnpm add @base-ui/react @base-ui/utils cmdk
```
```bash
yarn add @base-ui/react @base-ui/utils cmdk
```
```bash
bun add @base-ui/react @base-ui/utils cmdk
```
Install the command and popover components from shadcn/ui.
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add command popover
```
```bash
pnpm dlx shadcn@latest add command popover
```
```bash
yarn dlx shadcn@latest add command popover
```
```bash
bun x shadcn@latest add command popover
```
Copy and paste the following code into your project.
Update the import paths to match your project setup.
## Layout [#layout]
Import the parts and compose them together.
```tsx
import {
Faceted,
FacetedClear,
FacetedContent,
FacetedEmpty,
FacetedGroup,
FacetedInput,
FacetedItem,
FacetedItemIndicator,
FacetedList,
FacetedLoading,
FacetedTrigger,
FacetedValue,
} from "@/components/ui/faceted";
return (
)
```
## Examples [#examples]
### Multiple [#multiple]
Set `multiple` to select more than one value. `FacetedItemIndicator` can show a count until the item is selected, and `FacetedClear` appears once something is selected.
### Groups [#groups]
Split items into groups with headings, and separate them with `FacetedSeparator`.
### Async [#async]
Search on the server by setting `shouldFilter={false}` on `FacetedContent` and controlling the search with `value` and `onValueChange` on `FacetedInput`. Show `FacetedLoading` while a request is pending. Keep the selected options in `items` so their badges stay labeled when they aren't in the current results.
### Controlled [#controlled]
Control the selection with `value` and `onValueChange`.
## API Reference [#api-reference]
### Faceted [#faceted]
The root component. It holds the selection and the popover's open state.
### FacetedTrigger [#facetedtrigger]
The button that opens the popover. Use `render` to render your own button.
### FacetedValue [#facetedvalue]
Shows the current selection inside the trigger, as badges or a placeholder. Labels come from the `items` passed to `Faceted`.
### FacetedBadgeList [#facetedbadgelist]
The container for the selection badges.
### FacetedBadge [#facetedbadge]
A badge for one selected option.
### FacetedContent [#facetedcontent]
The popover content. It wraps its children in a command menu.
### FacetedInput [#facetedinput]
The search input that filters the items. Set `variant="line"` for a plain row with a divider below it.
### FacetedList [#facetedlist]
The scrollable list of groups and items.
### FacetedEmpty [#facetedempty]
Shown when no items match the search.
### FacetedLoading [#facetedloading]
Shown while results are loading, such as during a server search.
### FacetedGroup [#facetedgroup]
A group of items with an optional heading.
### FacetedItem [#faceteditem]
A selectable option.
### FacetedItemIndicator [#faceteditemindicator]
The check shown on selected items. Its children, such as a count, show while the item isn't selected.
### FacetedClear [#facetedclear]
An item that clears the selection, in its own group below a separator. It only renders when something is selected.
### FacetedSeparator [#facetedseparator]
A line between groups.
## Accessibility [#accessibility]
### Keyboard Interactions [#keyboard-interactions]
# File Upload
URL: /docs/components/base/file-upload
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/file-upload
```
```bash
pnpm dlx shadcn@latest add @diceui/file-upload
```
```bash
yarn dlx shadcn@latest add @diceui/file-upload
```
```bash
bun x shadcn@latest add @diceui/file-upload
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/react @base-ui/utils
```
```bash
pnpm add @base-ui/react @base-ui/utils
```
```bash
yarn add @base-ui/react @base-ui/utils
```
```bash
bun add @base-ui/react @base-ui/utils
```
Copy and paste the direction utilities into your
`components/direction.tsx`
file.
Copy and paste the following code into your project.
Update the import paths to match your project setup.
## Layout [#layout]
Import the parts, and compose them together.
```tsx
import {
FileUpload,
FileUploadDropzone,
FileUploadTrigger,
FileUploadList,
FileUploadItem,
FileUploadItemPreview,
FileUploadItemMetadata,
FileUploadItemProgress,
FileUploadItemDelete,
FileUploadClear,
} from "@/components/ui/file-upload";
return (
)
```
## Examples [#examples]
### With Validation [#with-validation]
Validate files with the `onFileValidate` prop on the `Root` component based on type, size, and custom rules. This will override the default file rejection message.
### Direct Upload [#direct-upload]
Upload files directly with the `onUpload` prop on the `Root` component.
### Circular Progress [#circular-progress]
Render a circular progress indicator instead of a linear one by enabling the `circular` prop on the `ItemProgress` component.
### Fill Progress [#fill-progress]
Render a fill progress indicator instead of a linear one by enabling the `fill` prop on the `ItemProgress` component.
### With uploadthing [#with-uploadthing]
Integrate with [uploadthing](https://uploadthing.com) for secure, type-safe file uploads with real-time progress tracking.
### With Chat Input [#with-chat-input]
Integrate into a chat input for uploading files. For demo the `Dropzone` is absolutely positioned to cover the entire viewport.
### With Form [#with-form]
Use the `value` and `onValueChange` props to handle file uploads with validation and submission.
## API Reference [#api-reference]
### FileUpload [#fileupload]
The main container component for the file upload functionality.
### FileUploadDropzone [#fileuploaddropzone]
A container for drag and drop functionality.
### FileUploadTrigger [#fileuploadtrigger]
A button that opens the file selection dialog.
### FileUploadList [#fileuploadlist]
A container for displaying uploaded files.
### FileUploadItem [#fileuploaditem]
Individual file item component.
### FileUploadItemPreview [#fileuploaditempreview]
Displays a preview of the file, showing an image for image files or an appropriate icon for other file types.
### FileUploadItemMetadata [#fileuploaditemmetadata]
Displays file information such as name, size, and error messages.
### FileUploadItemProgress [#fileuploaditemprogress]
Shows the upload progress for a file.
### FileUploadItemDelete [#fileuploaditemdelete]
A button to remove a file from the list.
### FileUploadClear [#fileuploadclear]
A button to clear all files from the list.
## Accessibility [#accessibility]
### Keyboard Interactions [#keyboard-interactions]
## Credits [#credits]
* [Building a Hold to Delete Component](https://emilkowal.ski/ui/building-a-hold-to-delete-component) - For the fill progress indicator.
# FPS
URL: /docs/components/base/fps
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/fps
```
```bash
pnpm dlx shadcn@latest add @diceui/fps
```
```bash
yarn dlx shadcn@latest add @diceui/fps
```
```bash
bun x shadcn@latest add @diceui/fps
```
Copy and paste the following code into your project.
## Examples [#examples]
### Positioning Strategy [#positioning-strategy]
Control whether the FPS counter uses `fixed` or `absolute` positioning.
### Custom Position [#custom-position]
Choose from four corner positions for the FPS counter.
```tsx
import { Fps } from "@/components/fps"
export default function App() {
return (
{/* Your app content */}
)
}
```
### Custom Thresholds [#custom-thresholds]
Configure warning and error thresholds for color-coded performance indicators.
```tsx
import { Fps } from "@/components/fps"
export default function App() {
return (
{/* Your app content */}
)
}
```
### Conditional Rendering [#conditional-rendering]
Enable the FPS counter only in development environments.
```tsx
import { Fps } from "@/components/fps"
export default function App() {
const isDevelopment = process.env.NODE_ENV === "development"
return (
{/* Your app content */}
)
}
```
## API Reference [#api-reference]
### Fps [#fps]
A component that displays a real-time FPS counter overlay.
## Features [#features]
* **Real-time monitoring**: Uses `requestAnimationFrame` for accurate FPS measurement
* **Color-coded display**: Automatically changes color based on performance thresholds
* Green: Good performance (above warning threshold)
* Yellow: Warning (below warning threshold)
* Red: Poor performance (below error threshold)
* **Flexible positioning**: Choose between `fixed` and `absolute` positioning strategies
* **Customizable position**: Choose from four corner positions
* **Configurable update interval**: Control how often the FPS value updates
* **Performance optimized**: Minimal overhead with efficient frame counting
## Positioning Strategies [#positioning-strategies]
### Fixed Positioning [#fixed-positioning]
When using `strategy="fixed"`, the FPS counter is positioned relative to the viewport and rendered via a portal into the document body. This is useful when you want the counter to remain visible while scrolling.
```tsx
```
### Absolute Positioning [#absolute-positioning]
When using `strategy="absolute"`, the FPS counter is rendered directly in place (without a portal) and positioned relative to its nearest positioned ancestor. This is useful when you want the counter to be contained within a specific element with a `relative` wrapper.
```tsx
```
**Note:** Unlike `fixed` positioning, `absolute` positioning does not use a portal, so the component will respect relative positioning contexts and be contained within its parent element.
## Performance Considerations [#performance-considerations]
The FPS counter uses `requestAnimationFrame` to measure frame rate, which has minimal performance impact. The component:
* Only updates the display at the specified interval (default: 500ms)
* Uses refs to avoid unnecessary re-renders
* Automatically cleans up animation frames on unmount
For production builds, consider disabling the FPS counter:
```tsx
```
# Gauge
URL: /docs/components/base/gauge
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/gauge
```
```bash
pnpm dlx shadcn@latest add @diceui/gauge
```
```bash
yarn dlx shadcn@latest add @diceui/gauge
```
```bash
bun x shadcn@latest add @diceui/gauge
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/react @base-ui/utils
```
```bash
pnpm add @base-ui/react @base-ui/utils
```
```bash
yarn add @base-ui/react @base-ui/utils
```
```bash
bun add @base-ui/react @base-ui/utils
```
Copy and paste the following code into your project.
## Layout [#layout]
Import the parts and compose them together.
```tsx
import {
Gauge,
GaugeIndicator,
GaugeTrack,
GaugeRange,
GaugeValueText,
GaugeLabel,
} from "@/components/ui/gauge";
return (
Label
)
```
Or use the `Combined` component to get all the parts in one.
```tsx
import { GaugeCombined } from "@/components/ui/gauge";
```
## Examples [#examples]
### Sizes [#sizes]
Different gauge sizes to fit various UI contexts.
### Colors [#colors]
Different color themes for various use cases like system monitoring, health indicators, and status displays.
### Variants [#variants]
Different arc configurations including semi-circle, three-quarter circle, and full circle gauges.
## Value Text Formatting [#value-text-formatting]
By default, the gauge displays the percentage value (0–100) based on `value`, `min`, and `max`. You can customize the format using the `getValueText` prop:
### Show Percentage [#show-percentage]
```tsx
{
const percentage = ((value - min) / (max - min)) * 100;
return `${Math.round(percentage)}%`;
}}
>
{/* ... */}
```
### Show Fraction [#show-fraction]
```tsx
`${value}/${max}`}
>
{/* ... */}
```
### Custom Text [#custom-text]
```tsx
`${value} points`}
>
{/* ... */}
```
## Theming [#theming]
The gauge component uses CSS `currentColor` for stroke colors, making it easy to theme using Tailwind's text utilities:
### Track Theming [#track-theming]
```tsx
```
### Range Theming [#range-theming]
```tsx
```
### Value Text Theming [#value-text-theming]
```tsx
```
### Label Theming [#label-theming]
```tsx
```
## API Reference [#api-reference]
### Gauge [#gauge]
The main container component for the gauge.
### GaugeIndicator [#gaugeindicator]
The SVG container that holds the gauge arc paths.
### GaugeTrack [#gaugetrack]
The background arc that represents the full range of possible values.
### GaugeRange [#gaugerange]
The portion of the arc that represents the current gauge value with smooth animations.
### GaugeValueText [#gaugevaluetext]
The text element that displays the current gauge value or custom content. Automatically centers within the arc's visual bounds.
### GaugeLabel [#gaugelabel]
An optional label element that displays below the gauge.
### GaugeCombined [#gaugecombined]
The combined component that includes all the parts.
## Accessibility [#accessibility]
### Screen Reader Support [#screen-reader-support]
* Uses the `meter` role for proper screen reader identification
* Provides `aria-valuemin`, `aria-valuemax`, `aria-valuenow`, and `aria-valuetext` attributes
* Supports `aria-labelledby` when a label prop is provided
* Supports indeterminate state by omitting `aria-valuenow` when value is null
## Notes [#notes]
* The component automatically handles indeterminate states when `value` is `null` or `undefined`
* Gauge values are automatically clamped to the valid range between `min` and `max`
* Invalid `max` or `value` props will log console errors and use fallback values
* Supports full circles (360°) by automatically splitting into two semi-circles for proper SVG rendering
* Value text automatically centers within the arc's visual bounds for both full and partial circles
* The gauge range uses `stroke-dashoffset` animations for smooth, performant filling effects
* All stroke colors use `currentColor` by default, making them responsive to text color changes
* Default angles are 0° (start) to 360° (end) for a full circle gauge
# Kanban
URL: /docs/components/base/kanban
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/kanban
```
```bash
pnpm dlx shadcn@latest add @diceui/kanban
```
```bash
yarn dlx shadcn@latest add @diceui/kanban
```
```bash
bun x shadcn@latest add @diceui/kanban
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/react @base-ui/utils @dnd-kit/core @dnd-kit/modifiers @dnd-kit/sortable @dnd-kit/utilities
```
```bash
pnpm add @base-ui/react @base-ui/utils @dnd-kit/core @dnd-kit/modifiers @dnd-kit/sortable @dnd-kit/utilities
```
```bash
yarn add @base-ui/react @base-ui/utils @dnd-kit/core @dnd-kit/modifiers @dnd-kit/sortable @dnd-kit/utilities
```
```bash
bun add @base-ui/react @base-ui/utils @dnd-kit/core @dnd-kit/modifiers @dnd-kit/sortable @dnd-kit/utilities
```
Copy and paste the following code into your project.
Update the import paths to match your project setup.
## Layout [#layout]
Import the parts, and compose them together.
```tsx
import {
Kanban,
KanbanBoard,
KanbanColumn,
KanbanColumnHandle,
KanbanItem,
KanbanItemHandle,
KanbanOverlay,
} from "@/components/ui/kanban";
return (
)
```
Every part accepts a `render` prop, so a column or item can be composed with your own element or component instead of the default `div`.
```tsx
}>
```
## Usage [#usage]
### With Primitive Values [#with-primitive-values]
When using primitive arrays (strings, numbers), the `getItemValue` prop is optional. The component will automatically use the items themselves as unique identifiers.
```tsx
const [columns, setColumns] = React.useState({
todo: ["Task 1", "Task 2"],
done: ["Task 3"],
});
{Object.entries(columns).map(([columnValue, items]) => (
{items.map((item) => (
{item}
))}
))}
```
### With Object Arrays [#with-object-arrays]
When using object arrays, the `getItemValue` prop is required to extract unique identifiers from each item.
```tsx
const [columns, setColumns] = React.useState({
todo: [
{ id: 1, title: "Task 1" },
{ id: 2, title: "Task 2" },
],
done: [
{ id: 3, title: "Task 3" },
],
});
item.id}
>
{Object.entries(columns).map(([columnValue, items]) => (
{items.map((item) => (
{item.title}
))}
))}
```
## Examples [#examples]
### With Dynamic Overlay [#with-dynamic-overlay]
Display a dynamic overlay when an item or column is being dragged.
## API Reference [#api-reference]
### Kanban [#kanban]
The main container component for kanban board functionality.
### KanbanBoard [#kanbanboard]
Container for kanban columns.
### KanbanColumn [#kanbancolumn]
Individual kanban column component.
### KanbanColumnHandle [#kanbancolumnhandle]
A button component that acts as a drag handle for kanban columns.
### KanbanItem [#kanbanitem]
Individual kanban item component.
### KanbanItemHandle [#kanbanitemhandle]
A button component that acts as a drag handle for kanban items.
### KanbanOverlay [#kanbanoverlay]
The overlay component that appears when an item or column is being dragged.
## Accessibility [#accessibility]
### Keyboard Interactions [#keyboard-interactions]
# Kbd
URL: /docs/components/base/kbd
**Deprecated.** Kbd was removed from Dice UI in October 2025. shadcn/ui ships a [Kbd](https://ui.shadcn.com/docs/components/base/kbd) component, so use that instead:
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add kbd
```
```bash
pnpm dlx shadcn@latest add kbd
```
```bash
yarn dlx shadcn@latest add kbd
```
```bash
bun x shadcn@latest add kbd
```
## Migrating [#migrating]
`@diceui/kbd` no longer installs. Replace it with shadcn/ui's `Kbd` and `KbdGroup`:
| Dice UI | shadcn/ui |
| ---------------------------------- | ------------------------------------------ |
| `Kbd.Root` / `KbdRoot` | `KbdGroup` |
| `Kbd.Key` / `KbdKey` | `Kbd` |
| `Kbd.Separator` / `KbdSeparator` | Text between keys, such as `+`, or nothing |
| `title` on `Kbd.Key` | Wrap the key in `` |
| `variant` and `size` on `Kbd.Root` | `className` |
```tsx
import * as Kbd from "@/components/ui/kbd"; // [!code --]
import { Kbd, KbdGroup } from "@/components/ui/kbd"; // [!code ++]
// Before
⌘K
// After
⌘
K
```
`Kbd.Key` added a `title` for common symbols such as ⌘, ⇧ and ⌥ automatically. shadcn/ui's `Kbd` doesn't, so add an `` where a symbol needs a description.
# Key Value
URL: /docs/components/base/key-value
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/key-value
```
```bash
pnpm dlx shadcn@latest add @diceui/key-value
```
```bash
yarn dlx shadcn@latest add @diceui/key-value
```
```bash
bun x shadcn@latest add @diceui/key-value
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/react @base-ui/utils
```
```bash
pnpm add @base-ui/react @base-ui/utils
```
```bash
yarn add @base-ui/react @base-ui/utils
```
```bash
bun add @base-ui/react @base-ui/utils
```
Copy and paste the visually hidden input component into your
`components/visually-hidden-input.tsx`
file.
Copy and paste the following code into your project.
Update the import paths to match your project setup.
## Layout [#layout]
Import the parts, and compose them together.
```tsx
import {
KeyValue,
KeyValueList,
KeyValueItem,
KeyValueKeyInput,
KeyValueValueInput,
KeyValueRemove,
KeyValueError,
KeyValueAdd,
} from "@/components/ui/key-value";
return (
)
```
## Examples [#examples]
### With Paste Support [#with-paste-support]
Paste multiple key-value pairs at once. Supports formats like `KEY=VALUE`, `KEY: VALUE`, and tab-separated values.
### With Validation [#with-validation]
Add validation rules for keys and values with error messages.
### With Form [#with-form]
Integrate with React Hook Form for form validation.
## API Reference [#api-reference]
### KeyValue [#keyvalue]
The main container component that manages the key-value items state.
### KeyValueList [#keyvaluelist]
Container for rendering the list of key-value items.
### KeyValueItem [#keyvalueitem]
Individual key-value pair item container.
### KeyInput [#keyinput]
Input field for the key part of the item.
### ValueInput [#valueinput]
Input field for the value part of the item.
### KeyValueRemove [#keyvalueremove]
Button to remove a key-value item.
### KeyValueAdd [#keyvalueadd]
Button to add a new key-value item.
### KeyValueError [#keyvalueerror]
Error message display for validation errors.
## Accessibility [#accessibility]
### Keyboard Interactions [#keyboard-interactions]
## Features [#features]
* **Dynamic Items**: Add and remove key-value pairs dynamically
* **Paste Support**: Paste multiple items at once in various formats (`KEY=VALUE`, `KEY: VALUE`, tab-separated)
* **Validation**: Built-in validation for keys and values with custom validators
* **Duplicate Detection**: Optional prevention of duplicate keys
* **Item Limits**: Set minimum and maximum item counts
* **Form Integration**: Works seamlessly with React Hook Form
* **Controlled/Uncontrolled**: Supports both controlled and uncontrolled patterns
* **Accessibility**: Full keyboard navigation and screen reader support
* **Customizable**: Fully customizable styling and behavior
## Paste Formats [#paste-formats]
The component supports pasting multiple key-value pairs in the following formats:
```
KEY=VALUE
DATABASE_URL=postgresql://localhost:5432
API_KEY=sk-1234567890
KEY: VALUE
DATABASE_URL: postgresql://localhost:5432
API_KEY: sk-1234567890
KEY VALUE (tab-separated)
DATABASE_URL postgresql://localhost:5432
API_KEY sk-1234567890
```
When pasting multiple lines, the component will automatically parse and create separate items for each line.
# Listbox
URL: /docs/components/base/listbox
## Installation [#installation]
npm
pnpm
yarn
bun
```bash
npm install @diceui/listbox
```
```bash
pnpm add @diceui/listbox
```
```bash
yarn add @diceui/listbox
```
```bash
bun add @diceui/listbox
```
## Installation with shadcn/ui [#installation-with-shadcnui]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/listbox
```
```bash
pnpm dlx shadcn@latest add @diceui/listbox
```
```bash
yarn dlx shadcn@latest add @diceui/listbox
```
```bash
bun x shadcn@latest add @diceui/listbox
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @diceui/listbox
```
```bash
pnpm add @diceui/listbox
```
```bash
yarn add @diceui/listbox
```
```bash
bun add @diceui/listbox
```
Copy and paste the following code into your project.
## Layout [#layout]
Import the parts, and compose them together.
```tsx
import {
ListboxRoot,
ListboxGroup,
ListboxGroupLabel,
ListboxItem,
ListboxItemIndicator,
} from "@diceui/listbox"
return (
)
```
## Examples [#examples]
### Horizontal Orientation [#horizontal-orientation]
Set `orientation="horizontal"` to create a horizontally navigable list.
### Grid Layout [#grid-layout]
For grid layouts, use `orientation="mixed"` to enable navigation in both directions.
Use CSS Grid to arrange the items in a grid structure. In grid layouts,
arrow keys will navigate accordingly:
* Up/Down: Navigates within a column
* Left/Right: Navigates within a row
### Grouped Items [#grouped-items]
Group items together to create a list of related options.
## API Reference [#api-reference]
### Listbox [#listbox]
The root component for creating listboxes.
### ListboxGroup [#listboxgroup]
A group of items inside the selectable list.
### ListboxGroupLabel [#listboxgrouplabel]
A label for the group of items.
### ListboxItem [#listboxitem]
An item inside the selectable list.
### ListboxItemIndicator [#listboxitemindicator]
A visual indicator that shows when the item is selected.
## Accessibility [#accessibility]
### Keyboard Interactions [#keyboard-interactions]
# Marquee
URL: /docs/components/base/marquee
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add "@diceui/marquee"
```
```bash
pnpm dlx shadcn@latest add "@diceui/marquee"
```
```bash
yarn dlx shadcn@latest add "@diceui/marquee"
```
```bash
bun x shadcn@latest add "@diceui/marquee"
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/react @base-ui/utils
```
```bash
pnpm add @base-ui/react @base-ui/utils
```
```bash
yarn add @base-ui/react @base-ui/utils
```
```bash
bun add @base-ui/react @base-ui/utils
```
Copy and paste the following code into your project.
Add the following CSS animations to your
`globals.css`
file:
```css
:root {
--animate-marquee-left: marquee-left var(--marquee-duration) linear var(--marquee-loop-count);
--animate-marquee-right: marquee-right var(--marquee-duration) linear var(--marquee-loop-count);
--animate-marquee-left-rtl: marquee-left-rtl var(--marquee-duration) linear var(--marquee-loop-count);
--animate-marquee-right-rtl: marquee-right-rtl var(--marquee-duration) linear var(--marquee-loop-count);
--animate-marquee-up: marquee-up var(--marquee-duration) linear var(--marquee-loop-count);
--animate-marquee-down: marquee-down var(--marquee-duration) linear var(--marquee-loop-count);
@keyframes marquee-left {
0% {
transform: translateX(0%);
}
100% {
transform: translateX(calc(-100% - var(--marquee-gap)));
}
}
@keyframes marquee-right {
0% {
transform: translateX(calc(-100% - var(--marquee-gap)));
}
100% {
transform: translateX(0%);
}
}
@keyframes marquee-up {
0% {
transform: translateY(0%);
}
100% {
transform: translateY(calc(-100% - var(--marquee-gap)));
}
}
@keyframes marquee-down {
0% {
transform: translateY(calc(-100% - var(--marquee-gap)));
}
100% {
transform: translateY(0%);
}
}
@keyframes marquee-left-rtl {
0% {
transform: translateX(0%);
}
100% {
transform: translateX(calc(100% + var(--marquee-gap)));
}
}
@keyframes marquee-right-rtl {
0% {
transform: translateX(calc(100% + var(--marquee-gap)));
}
100% {
transform: translateX(0%);
}
}
}
```
## Layout [#layout]
Import the parts and compose them together.
```tsx
import * as Marquee from "@/components/ui/marquee"
return (
)
```
## Examples [#examples]
### Logo Showcase [#logo-showcase]
Use the marquee to showcase logos or brands in a continuous scroll.
### Vertical Layout [#vertical-layout]
Use `side` to control the direction of the marquee.
### With RTL [#with-rtl]
The marquee component automatically adapts to RTL (right-to-left) layouts.
## API Reference [#api-reference]
### Marquee [#marquee]
The main marquee component that creates continuous scrolling animations.
### MarqueeContent [#marqueecontent]
Contains the scrolling content and handles repetition for seamless animation.
### MarqueeItem [#marqueeitem]
Individual items within the marquee content.
### MarqueeEdge [#marqueeedge]
Edge overlay components for smooth gradient transitions.
## Accessibility [#accessibility]
### Keyboard Interactions [#keyboard-interactions]
## Features [#features]
* **RTL Support**: Automatically adapts to RTL (right-to-left) layouts
* **Screen Reader Support**: Content remains accessible to assistive technologies
* **Reduced Motion**: Respects user's `prefers-reduced-motion` setting
* **Pause Controls**:
* **Hover**: Can be configured to pause animation when hovered
* **Keyboard**: Press Space key to pause/resume (when `pauseOnKeyboard` is enabled)
* **Focus Management**: Proper focus indicators and keyboard navigation when `pauseOnKeyboard` is enabled
# Mask Input
URL: /docs/components/base/mask-input
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/mask-input
```
```bash
pnpm dlx shadcn@latest add @diceui/mask-input
```
```bash
yarn dlx shadcn@latest add @diceui/mask-input
```
```bash
bun x shadcn@latest add @diceui/mask-input
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/react @base-ui/utils
```
```bash
pnpm add @base-ui/react @base-ui/utils
```
```bash
yarn add @base-ui/react @base-ui/utils
```
```bash
bun add @base-ui/react @base-ui/utils
```
Copy and paste the following code into your project.
## Layout [#layout]
Import and use the component directly.
```tsx
import { MaskInput } from "@/components/ui/mask-input";
{
console.log('Masked:', masked); // "(555) 123-4567"
console.log('Unmasked:', unmasked); // "5551234567"
}}
/>
```
## Features [#features]
* **Smart cursor positioning** - Cursor stays in the correct position during typing and pasting
* **Paste support** - Intelligently handles pasted content with proper formatting
* **Built-in patterns** - Common formats like phone, SSN, date, credit card, etc.
* **Custom patterns** - Create your own mask patterns with validation
* **Optional mask placeholders** - Control when mask format hints are shown with `maskPlaceholder`
* **TypeScript support** - Full type safety with IntelliSense
* **Accessibility** - ARIA attributes and keyboard navigation
* **Form integration** - Works seamlessly with form libraries
* **Composition support** - Use `render` prop to render as a different component
## Examples [#examples]
### With custom patterns [#with-custom-patterns]
Create custom mask patterns for specific formatting needs.
### With validation modes [#with-validation-modes]
Control when validation occurs with different validation modes, similar to react-hook-form.
### Card information [#card-information]
Card information with credit card number, expiry date, and CVC fields.
### With form [#with-form]
Integrate masked inputs with form validation using react-hook-form.
## Built-in Mask Patterns [#built-in-mask-patterns]
The component includes several predefined mask patterns:
| Pattern | Format | Example | Description |
| ------------------ | --------------------- | ------------------- | ------------------------------------------- |
| `phone` | `(###) ###-####` | (555) 123-4567 | US phone number |
| `ssn` | `###-##-####` | 123-45-6789 | Social Security Number |
| `date` | `##/##/####` | 12/25/2023 | Date (MM/DD/YYYY) |
| `time` | `##:##` | 14:30 | Time (HH:MM) |
| `creditCard` | `#### #### #### ####` | 1234 5678 9012 3456 | Credit card number |
| `creditCardExpiry` | `##/##` | 12/25 | Credit card expiry date (MM/YY) |
| `zipCode` | `#####` | 12345 | US ZIP code |
| `zipCodeExtended` | `#####-####` | 12345-6789 | US ZIP+4 code |
| `currency` | Dynamic | \$1,234.56 | Currency formatting using Intl.NumberFormat |
| `percentage` | `##.##%` | 12.34% | Percentage with decimals |
| `licensePlate` | `###-###` | ABC-123 | License plate format |
| `ipv4` | `###.###.###.###` | 192.168.1.1 | IPv4 address |
| `macAddress` | `##:##:##:##:##:##` | 00:1B:44:11:3A:B7 | MAC address |
| `isbn` | `###-#-###-#####-#` | 978-0-123-45678-9 | ISBN-13 book identifier |
| `ein` | `##-#######` | 12-3456789 | Employer Identification Number |
## Custom Mask Patterns [#custom-mask-patterns]
Create custom patterns using the `MaskPattern` interface:
```tsx
const customPattern: MaskPattern = {
pattern: "###-###-####",
transform: (value, opts) => value.replace(/[^A-Z0-9]/gi, "").toUpperCase(),
validate: (value, opts) => value.length === 10,
};
```
## Currency Formatting [#currency-formatting]
The currency mask uses the `Intl.NumberFormat` API for localization and currency formatting.
```tsx
// Default USD formatting
// Euro formatting with German locale
// Japanese Yen formatting
// British Pound formatting
```
## Mask Placeholders [#mask-placeholders]
Use the `maskPlaceholder` prop to control when mask format hints are shown. The mask placeholder only appears when the input is focused and the prop is provided.
```tsx
// Shows mask placeholder when focused
// No mask placeholder - just regular placeholder behavior
```
## API Reference [#api-reference]
### MaskInput [#maskinput]
The main masked input component that handles formatting and user input.
### MaskPattern [#maskpattern]
Interface for creating custom mask patterns.
### MaskPatternKey [#maskpatternkey]
Predefined mask pattern keys for common input formats.
| Pattern | Description |
| ------------------ | ------------------------------------------- |
| `phone` | US phone number |
| `ssn` | Social Security Number |
| `date` | Date (MM/DD/YYYY) |
| `time` | Time (HH:MM) |
| `creditCard` | Credit card number |
| `creditCardExpiry` | Credit card expiry date (MM/YY) |
| `zipCode` | US ZIP code |
| `zipCodeExtended` | US ZIP+4 code |
| `currency` | Currency formatting using Intl.NumberFormat |
| `percentage` | Percentage with decimals |
| `licensePlate` | License plate format |
| `ipv4` | IPv4 address |
| `macAddress` | MAC address |
| `isbn` | ISBN-13 book identifier |
| `ein` | Employer Identification Number |
### TransformOptions [#transformoptions]
Options passed to the transform function for advanced formatting.
### ValidateOptions [#validateoptions]
Options passed to the validate function for enhanced validation.
## Data Attributes [#data-attributes]
## Accessibility [#accessibility]
### Keyboard Interactions [#keyboard-interactions]
# Masonry
URL: /docs/components/base/masonry
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/masonry
```
```bash
pnpm dlx shadcn@latest add @diceui/masonry
```
```bash
yarn dlx shadcn@latest add @diceui/masonry
```
```bash
bun x shadcn@latest add @diceui/masonry
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/react @base-ui/utils
```
```bash
pnpm add @base-ui/react @base-ui/utils
```
```bash
yarn add @base-ui/react @base-ui/utils
```
```bash
bun add @base-ui/react @base-ui/utils
```
Copy and paste the following code into your project.
Update the import paths to match your project setup.
## Layout [#layout]
Import the parts, and compose them together.
```tsx
import {
Masonry,
MasonryItem,
} from "@/components/ui/masonry";
return (
)
```
## Examples [#examples]
### Linear Layout [#linear-layout]
Set `linear` to `true` to maintain item order from left to right.
### Server Side Rendering [#server-side-rendering]
Use `defaultWidth` and `defaultHeight`, and item `fallback` to render items on the server. This is useful for preventing layout shift and hydration errors.
## API Reference [#api-reference]
### Masonry [#masonry]
The main container component for the masonry layout.
### MasonryItem [#masonryitem]
Individual item component within the masonry layout.
# Media Player
URL: /docs/components/base/media-player
## Installation [#installation]
> **Prerequisites:** Before installing the media player component, you'll need to update your existing shadcn/ui components to support portal containers.
**DropdownMenu**
```diff
function DropdownMenuContent({
align = "start",
alignOffset = 0,
side = "bottom",
sideOffset = 4,
className,
+ container,
...props
}: MenuPrimitive.Popup.Props &
Pick<
MenuPrimitive.Positioner.Props,
"align" | "alignOffset" | "side" | "sideOffset"
- >) {
+ > & {
+ container?: MenuPrimitive.Portal.Props["container"];
+ }) {
return (
-
+
```
**Tooltip**
```diff
function TooltipContent({
className,
side = "top",
sideOffset = 4,
align = "center",
alignOffset = 0,
+ container,
children,
...props
}: TooltipPrimitive.Popup.Props &
Pick<
TooltipPrimitive.Positioner.Props,
"align" | "alignOffset" | "side" | "sideOffset"
- >) {
+ > & {
+ container?: TooltipPrimitive.Portal.Props["container"];
+ }) {
return (
-
+
```
Command
Manual
After completing the prerequisite component updates, install the media player:
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/media-player
```
```bash
pnpm dlx shadcn@latest add @diceui/media-player
```
```bash
yarn dlx shadcn@latest add @diceui/media-player
```
```bash
bun x shadcn@latest add @diceui/media-player
```
After completing the prerequisite component updates, install the required dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/react @base-ui/utils media-chrome
```
```bash
pnpm add @base-ui/react @base-ui/utils media-chrome
```
```bash
yarn add @base-ui/react @base-ui/utils media-chrome
```
```bash
bun add @base-ui/react @base-ui/utils media-chrome
```
Copy and paste the following code into your project.
Update the import paths to match your project setup.
## Layout [#layout]
Import the parts, and compose them together.
```tsx
import {
MediaPlayer,
MediaPlayerVideo,
MediaPlayerAudio,
MediaPlayerLoading,
MediaPlayerError,
MediaPlayerVolumeIndicator,
MediaPlayerControls,
MediaPlayerControlsOverlay,
MediaPlayerPlay,
MediaPlayerSeekBackward,
MediaPlayerSeekForward,
MediaPlayerVolume,
MediaPlayerSeek,
MediaPlayerTime,
MediaPlayerPlaybackSpeed,
MediaPlayerLoop,
MediaPlayerCaptions,
MediaPlayerFullscreen,
MediaPlayerDownload,
MediaPlayerSettings,
} from "@/components/ui/media-player";
return (
)
```
## Examples [#examples]
### Audio Player [#audio-player]
Use the `Audio` component instead of `Video` for audio playback.
### With Settings Menu [#with-settings-menu]
Media player with a settings menu with playback speed, caption option, and resolution selector.
### HLS Playback [#hls-playback]
Media player with HLS (HTTP Live Streaming) support for adaptive bitrate streaming.
This example demonstrates using the [Mux Video React](https://github.com/muxinc/elements/tree/main/packages/mux-video-react) package as the video element to enable HLS playback.
### With Error Handling [#with-error-handling]
Media player with custom error handling and retry functionality.
### With Playlist [#with-playlist]
A media player example that includes a playlist, similar to music streaming applications.
## API Reference [#api-reference]
### MediaPlayer [#mediaplayer]
The main container component for the media player.
### MediaPlayerVideo [#mediaplayervideo]
The video element, integrated with the player state.
### MediaPlayerAudio [#mediaplayeraudio]
The audio element, integrated with the player state.
### MediaPlayerControls [#mediaplayercontrols]
A container for the media player controls.
### MediaPlayerControlsOverlay [#mediaplayercontrolsoverlay]
Displays as a subtle backdrop that improves readability for media controls.
### MediaPlayerLoading [#mediaplayerloading]
A loading indicator that appears when media is loading, similar to YouTube/Netflix style.
### MediaPlayerError [#mediaplayererror]
An error component that displays when media playback encounters an error, with retry and reload options.
### MediaPlayerVolumeIndicator [#mediaplayervolumeindicator]
A volume indicator that appears when the volume is changed with keyboard interactions.
### MediaPlayerPlay [#mediaplayerplay]
A button to play or pause the media.
### MediaPlayerSeekBackward [#mediaplayerseekbackward]
A button to seek backward in the media.
### MediaPlayerSeekForward [#mediaplayerseekforward]
A button to seek forward in the media.
### MediaPlayerSeek [#mediaplayerseek]
A slider component to seek through the media playback.
#### Styling [#styling]
```tsx
```
### MediaPlayerVolume [#mediaplayervolume]
A slider component to control the media volume.
### MediaPlayerTime [#mediaplayertime]
Displays the current time, duration, or remaining time of the media.
### MediaPlayerPlaybackSpeed [#mediaplayerplaybackspeed]
A select dropdown to control the media playback speed.
### MediaPlayerLoop [#mediaplayerloop]
A button to toggle loop mode.
### MediaPlayerFullscreen [#mediaplayerfullscreen]
A button to toggle fullscreen mode.
### MediaPlayerPiP [#mediaplayerpip]
A button to toggle picture in picture mode (video only).
### MediaPlayerCaptions [#mediaplayercaptions]
A button to toggle captions or subtitles (video only).
### MediaPlayerDownload [#mediaplayerdownload]
A button to download the media file.
### MediaPlayerSettings [#mediaplayersettings]
A dropdown menu with playback speed selector, caption selector, and resolution selector.
**Features:**
* Playback speed control with customizable speeds
* Video quality/resolution selection (when available)
* Captions/subtitles control
* Organized in a clean dropdown interface
```tsx
```
## Accessibility [#accessibility]
### Keyboard Interactions [#keyboard-interactions]
## Credits [#credits]
* [FASSounds](https://pixabay.com/users/fassounds-3433550/?utm_source=link-attribution\&utm_medium=referral\&utm_campaign=music\&utm_content=160166) - For the audio file used in basic examples.
* [Pika](https://pika.art) - For the video file used in basic examples.
* [Elephants Dream](https://orange.blender.org/) - Open movie by the Blender Foundation, used in settings demo under Creative Commons Attribution 2.5.
* [Mux](https://www.mux.com/) - For HLS video streaming and VTT files used in HLS and settings demos.
* [Media Chrome](https://www.media-chrome.org/) - For VTT chapter and caption files used in examples.
* [RandomMind](https://opengameart.org/users/randommind) - For "Medieval: Battle" track used in playlist demo, available under CC0 from OpenGameArt.org.
* [The Lemming Shepherds](https://www.dropbox.com/s/mvvwaw1msplnteq/City%20Lights%20-%20The%20Lemming%20Shepherds.mp3) - For "City Lights" track used in playlist demo.
* [Picsum](https://picsum.photos/) - For placeholder cover images used in playlist demo.
# Mention
URL: /docs/components/base/mention
## Installation [#installation]
npm
pnpm
yarn
bun
```bash
npm install @diceui/mention
```
```bash
pnpm add @diceui/mention
```
```bash
yarn add @diceui/mention
```
```bash
bun add @diceui/mention
```
## Installation with shadcn/ui [#installation-with-shadcnui]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/mention
```
```bash
pnpm dlx shadcn@latest add @diceui/mention
```
```bash
yarn dlx shadcn@latest add @diceui/mention
```
```bash
bun x shadcn@latest add @diceui/mention
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @diceui/mention
```
```bash
pnpm add @diceui/mention
```
```bash
yarn add @diceui/mention
```
```bash
bun add @diceui/mention
```
Copy and paste the following code into your project.
## Layout [#layout]
Import the parts, and compose them together.
```tsx
import {
Mention,
MentionLabel,
MentionInput,
MentionPortal,
MentionContent,
MentionItem,
} from "@diceui/mention";
return (
)
```
## Examples [#examples]
### Custom Trigger [#custom-trigger]
### With Custom Filter [#with-custom-filter]
## API Reference [#api-reference]
### Mention [#mention]
The container for all mention parts. Mention tags can be styled using the `data-tag` attribute within the root.
### MentionLabel [#mentionlabel]
An accessible label that describes the mention input. Associates with the input element for screen readers.
### MentionInput [#mentioninput]
The text input field that users can type into to trigger mentions.
### MentionPortal [#mentionportal]
A portal for rendering the mention content outside of its DOM hierarchy.
### MentionContent [#mentioncontent]
The popover container for mention items. Positions the mention popover relative to the cursor position.
### MentionItem [#mentionitem]
An interactive option in the mention list.
## Accessibility [#accessibility]
### Keyboard Interactions [#keyboard-interactions]
# Phone Input
URL: /docs/components/base/phone-input
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/phone-input
```
```bash
pnpm dlx shadcn@latest add @diceui/phone-input
```
```bash
yarn dlx shadcn@latest add @diceui/phone-input
```
```bash
bun x shadcn@latest add @diceui/phone-input
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/react @base-ui/utils
```
```bash
pnpm add @base-ui/react @base-ui/utils
```
```bash
yarn add @base-ui/react @base-ui/utils
```
```bash
bun add @base-ui/react @base-ui/utils
```
Copy and paste the visually hidden input component into your project.
Copy and paste the following code into your project.
Update the import paths to match your project setup.
## Layout [#layout]
Import the parts, and compose them together.
```tsx
import {
PhoneInput,
PhoneInputCountrySelect,
PhoneInputField,
} from "@/components/ui/phone-input";
return (
)
```
## Examples [#examples]
### Custom Countries [#custom-countries]
Provide a custom list of countries to display in the dropdown.
### With Form [#with-form]
Use the phone input component in a form with validation.
## API Reference [#api-reference]
### PhoneInput [#phoneinput]
The root container component that acts as both the wrapper and input group. Handles layout, borders, and focus states.
### PhoneInputCountrySelect [#phoneinputcountryselect]
The button component that triggers the country dropdown. Uses Popover and Command internally for the country list.
### PhoneInputField [#phoneinputfield]
The input field component for entering the phone number.
## Accessibility [#accessibility]
### Keyboard Interactions [#keyboard-interactions]
# Presentation
URL: /docs/components/base/presentation
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/presentation
```
```bash
pnpm dlx shadcn@latest add @diceui/presentation
```
```bash
yarn dlx shadcn@latest add @diceui/presentation
```
```bash
bun x shadcn@latest add @diceui/presentation
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @diceui/pptx
```
```bash
pnpm add @diceui/pptx
```
```bash
yarn add @diceui/pptx
```
```bash
bun add @diceui/pptx
```
Copy and paste the following hook into your
`hooks`
directory.
Copy and paste the following code into your project.
Update the import paths to match your project setup.
`@diceui/pptx` pulls in `@diceui/pptx-core` automatically. The thumbnail rail collapses below 768px behind a toggle, which is why this item also depends on `button` and `use-mobile`.
## Layout [#layout]
Import the parts, and compose them together.
```tsx
import {
Presentation,
PresentationContent,
PresentationError,
PresentationLoading,
PresentationSelection,
PresentationSlide,
PresentationThumbnailList,
PresentationViewport,
} from "@/components/ui/presentation";
return (
)
```
Pass a `File`, `Blob`, `ArrayBuffer`, or `Uint8Array` to `file` on `Presentation`. There is no toolbar in this item — toolbars are assembled around the primitives.
## Examples [#examples]
### Editing [#editing]
Load with `readOnly={false}` and place `PresentationSelection` inside `PresentationSlide` to move, resize, and edit text. Undo and redo shortcuts are opt-in via `undoRedoShortcuts`. Drag thumbnails to reorder slides.
This example also uses `PresentationZoomSelect`, a companion control built with `useZoom` and `select`. Install it with `@diceui/presentation-zoom-select`.
## API Reference [#api-reference]
### PresentationProvider [#presentationprovider]
Makes an existing store available to descendants without rendering any DOM. Use it when a toolbar has to sit outside `Presentation`, or when the store is created with `useCreatePresentationStore` before the tree mounts.
### Presentation [#presentation]
The outermost component. Creates an internal store (or inherits one from `PresentationProvider`), loads the file, and provides context to all descendants.
### PresentationContent [#presentationcontent]
Layout wrapper for the viewport column next to the thumbnail rail.
### PresentationViewport [#presentationviewport]
Scrollable container that centers the slide and optionally auto-fits it to fill the available space. The styled wrapper defaults `autoFit` to `true` with 10px padding.
### PresentationSlide [#presentationslide]
Renders the active slide as a scaled DOM tree. Mounts an empty wrapper immediately so sibling layout is stable. Children are placed in an overlay; put `PresentationSelection` here.
### PresentationSelection [#presentationselection]
PowerPoint-style editing overlay. Enables drag-to-move, resize, inline text editing, multi-select, and keyboard shortcuts. Renders nothing unless the presentation was loaded with `readOnly={false}`.
Must be placed inside `PresentationSlide`.
### PresentationLoading [#presentationloading]
Renders its children only while the presentation is in the `"loading"` state.
### PresentationError [#presentationerror]
Renders its children only when the presentation fails to parse.
### PresentationThumbnailList [#presentationthumbnaillist]
Scrollable list of slide thumbnails. Below 768px the rail collapses behind a toggle button and closes on outside pointerup or Escape.
### PresentationThumbnailItem [#presentationthumbnailitem]
Clickable item for a single slide in a `PresentationThumbnailList`.
### PresentationThumbnailItemPreview [#presentationthumbnailitempreview]
Renders the slide miniature for the enclosing `PresentationThumbnailItem`. Previews are rendered lazily as they approach the viewport.
### PresentationThumbnailItemNumber [#presentationthumbnailitemnumber]
Renders the 1-based slide number for the enclosing `PresentationThumbnailItem`.
### PresentationZoomSelect [#presentationzoomselect]
Companion select for Fit and explicit zoom levels. Must be used inside `PresentationProvider` or `Presentation`.
### usePresentation [#usepresentation]
Subscribes to top-level presentation state: parse status, progress, and errors.
### useSlide [#useslide]
Subscribes to slide navigation state and exposes navigation actions.
### useZoom [#usezoom]
Subscribes to zoom state. Setting an explicit level turns auto-fit off; `setAutoFit(true)` turns it back on.
### useHistory [#usehistory]
Undo, redo, and whether the deck has unsaved edits.
Create a store with `useCreatePresentationStore` for programmatic `load`, `edit`, `save`, and `reset`. See the [store API](https://pptx.diceui.com/docs/store) for the full imperative surface.
## Accessibility [#accessibility]
### Keyboard Interactions [#keyboard-interactions]
#### Thumbnail list [#thumbnail-list]
#### Selection overlay [#selection-overlay]
Available when the presentation is loaded with `readOnly={false}`.
# QR Code
URL: /docs/components/base/qr-code
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/qr-code
```
```bash
pnpm dlx shadcn@latest add @diceui/qr-code
```
```bash
yarn dlx shadcn@latest add @diceui/qr-code
```
```bash
bun x shadcn@latest add @diceui/qr-code
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/react @base-ui/utils qrcode
```
```bash
pnpm add @base-ui/react @base-ui/utils qrcode
```
```bash
yarn add @base-ui/react @base-ui/utils qrcode
```
```bash
bun add @base-ui/react @base-ui/utils qrcode
```
Install the type definitions:
npm
pnpm
yarn
bun
```bash
npm install @types/qrcode
```
```bash
pnpm add @types/qrcode
```
```bash
yarn add @types/qrcode
```
```bash
bun add @types/qrcode
```
Copy and paste the following code into your project.
Update the import paths to match your project setup.
## Layout [#layout]
Import the parts, and compose them together.
```tsx
import {
QRCode,
QRCodeCanvas,
QRCodeSvg,
QRCodeImage,
QRCodeOverlay,
QRCodeSkeleton,
QRCodeDownload,
} from "@/components/ui/qr-code";
return (
)
```
Swap `Canvas` with `Svg` or `Image` to render the qr code in svg and image formats respectively.
## Examples [#examples]
### Different Formats [#different-formats]
Render QR codes as Canvas, SVG, or Image elements.
### Customization [#customization]
Customize colors, size, and error correction levels.
### Overlay [#overlay]
Add logos, icons, or custom elements to the center of QR codes.
## API Reference [#api-reference]
### QRCode [#qrcode]
The main container component that provides context for QR code generation.
### Image [#image]
Renders the QR code as an HTML image element.
### Canvas [#canvas]
Renders the QR code using HTML5 Canvas.
### Svg [#svg]
Renders the QR code as an SVG element.
### Overlay [#overlay-1]
Overlays content (like logos or icons) in the center of the QR code.
### Skeleton [#skeleton]
Displays a loading placeholder while the QR code is being generated. Automatically hides once the QR code is ready.
### Download [#download]
A button component for downloading the QR code.
## Accessibility [#accessibility]
### Keyboard Interactions [#keyboard-interactions]
## Error Correction Levels [#error-correction-levels]
QR codes support different error correction levels that determine how much of the code can be damaged while still being readable:
* **L (Low)**: \~7% of data can be restored
* **M (Medium)**: \~15% of data can be restored (default)
* **Q (Quartile)**: \~25% of data can be restored
* **H (High)**: \~30% of data can be restored
Higher error correction levels result in denser QR codes but provide better resilience to damage or distortion.
## Usage Notes [#usage-notes]
* The component uses dynamic imports to avoid SSR issues with the QR code library
* Canvas rendering provides the best performance for static QR codes
* SVG rendering is ideal for scalable, print-ready QR codes
* The download functionality works in all modern browsers
* QR codes are generated client-side for privacy and performance
* Child elements are automatically constrained by the `--qr-code-size` CSS variable to prevent layout issues
* When using the Overlay component, set `level="H"` (High error correction) to ensure the QR code remains scannable with up to 30% coverage
# Rating
URL: /docs/components/base/rating
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add "@diceui/rating"
```
```bash
pnpm dlx shadcn@latest add "@diceui/rating"
```
```bash
yarn dlx shadcn@latest add "@diceui/rating"
```
```bash
bun x shadcn@latest add "@diceui/rating"
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/react @base-ui/utils
```
```bash
pnpm add @base-ui/react @base-ui/utils
```
```bash
yarn add @base-ui/react @base-ui/utils
```
```bash
bun add @base-ui/react @base-ui/utils
```
Copy and paste the visually hidden input component into your
`components/visually-hidden-input.tsx`
file.
Copy and paste the following code into your project.
Update the import paths to match your project setup.
## Layout [#layout]
Import the parts and compose them together.
```tsx
import { Rating, RatingItem } from "@/components/ui/rating";
return (
)
```
## Examples [#examples]
### Themes [#themes]
Customize the rating component with different colors and icons.
### Controlled State [#controlled-state]
Control the rating value with state.
### With Form [#with-form]
Integrate the rating component with form validation.
## API Reference [#api-reference]
### Rating [#rating]
The main container component for the rating.
### RatingItem [#ratingitem]
Individual rating item (star) component.
## Accessibility [#accessibility]
### Keyboard Interactions [#keyboard-interactions]
# Relative Time Card
URL: /docs/components/base/relative-time-card
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/relative-time-card
```
```bash
pnpm dlx shadcn@latest add @diceui/relative-time-card
```
```bash
yarn dlx shadcn@latest add @diceui/relative-time-card
```
```bash
bun x shadcn@latest add @diceui/relative-time-card
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/react class-variance-authority
```
```bash
pnpm add @base-ui/react class-variance-authority
```
```bash
yarn add @base-ui/react class-variance-authority
```
```bash
bun add @base-ui/react class-variance-authority
```
Copy and paste the hover card component into your project.
Copy and paste the following code into your project.
Update the import paths to match your project setup.
## Examples [#examples]
### With Multiple Timezones [#with-multiple-timezones]
### With Variants [#with-variants]
## API Reference [#api-reference]
### RelativeTimeCard [#relativetimecard]
The main component that displays relative time with hover functionality.
## Accessibility [#accessibility]
### Keyboard Interactions [#keyboard-interactions]
## Credits [#credits]
* [John Phamous](https://x.com/JohnPhamous/status/1836091528911216803) - For the initial implementation.
# Responsive Dialog
URL: /docs/components/base/responsive-dialog
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/responsive-dialog
```
```bash
pnpm dlx shadcn@latest add @diceui/responsive-dialog
```
```bash
yarn dlx shadcn@latest add @diceui/responsive-dialog
```
```bash
bun x shadcn@latest add @diceui/responsive-dialog
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/utils vaul
```
```bash
pnpm add @base-ui/utils vaul
```
```bash
yarn add @base-ui/utils vaul
```
```bash
bun add @base-ui/utils vaul
```
Copy and paste the following hooks into your
`hooks`
directory.
Copy and paste the dialog and drawer components into your project.
Copy and paste the following code into your project.
Update the import paths to match your project setup.
## Layout [#layout]
Import the parts, and compose them together.
```tsx
import {
ResponsiveDialog,
ResponsiveDialogContent,
ResponsiveDialogDescription,
ResponsiveDialogFooter,
ResponsiveDialogHeader,
ResponsiveDialogTitle,
ResponsiveDialogTrigger,
} from "@/components/ui/responsive-dialog";
```
## Examples [#examples]
### Confirmation Dialog [#confirmation-dialog]
Use the responsive dialog to confirm destructive actions like deleting items.
### Variant Styling [#variant-styling]
Each component exposes a `data-variant` attribute that can be used to apply different styles based on whether the dialog or drawer is rendered.
```tsx
{/* content */}
{/* buttons */}
```
## API Reference [#api-reference]
### ResponsiveDialog [#responsivedialog]
The root component that manages the dialog/drawer state.
### ResponsiveDialogTrigger [#responsivedialogtrigger]
The button that opens the dialog/drawer.
### ResponsiveDialogContent [#responsivedialogcontent]
The content container for the dialog/drawer.
### ResponsiveDialogHeader [#responsivedialogheader]
The header section of the dialog/drawer.
### ResponsiveDialogFooter [#responsivedialogfooter]
The footer section of the dialog/drawer.
### ResponsiveDialogTitle [#responsivedialogtitle]
The title of the dialog/drawer.
### ResponsiveDialogDescription [#responsivedialogdescription]
The description of the dialog/drawer.
### ResponsiveDialogClose [#responsivedialogclose]
The close button for the dialog/drawer.
### ResponsiveDialogOverlay [#responsivedialogoverlay]
The overlay behind the dialog/drawer.
### ResponsiveDialogPortal [#responsivedialogportal]
The portal container for the dialog/drawer.
## Accessibility [#accessibility]
Adheres to the [Dialog WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/).
### Keyboard Interactions [#keyboard-interactions]
# Scroll Spy
URL: /docs/components/base/scroll-spy
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/scroll-spy
```
```bash
pnpm dlx shadcn@latest add @diceui/scroll-spy
```
```bash
yarn dlx shadcn@latest add @diceui/scroll-spy
```
```bash
bun x shadcn@latest add @diceui/scroll-spy
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/react @base-ui/utils
```
```bash
pnpm add @base-ui/react @base-ui/utils
```
```bash
yarn add @base-ui/react @base-ui/utils
```
```bash
bun add @base-ui/react @base-ui/utils
```
Copy and paste the direction utilities into your project.
Copy and paste the following code into your project.
Update the import paths to match your project setup.
## Layout [#layout]
Import the parts, and compose them together.
```tsx
import {
ScrollSpy,
ScrollSpyNav,
ScrollSpyLink,
ScrollSpyViewport,
ScrollSpySection,
} from "@/components/ui/scroll-spy";
return (
)
```
## Examples [#examples]
### Vertical Orientation [#vertical-orientation]
Set `orientation="vertical"` for content with vertical navigation.
### Controlled State [#controlled-state]
Use the `value` and `onValueChange` props to control the active section externally.
### Sticky Layout [#sticky-layout]
For full-page scroll behavior, you can use a sticky positioned navigation sidebar that stays fixed while the content scrolls. This works with the default window scroll (no `scrollContainer` prop needed).
```tsx
IntroductionGetting StartedUsageAPI Reference
Introduction
Your content here...
Getting Started
Your content here...
{/* More content sections */}
```
The key is to apply `sticky top-[offset]` to the `ScrollSpyNav` to keep the navigation visible as the page scrolls.
## API Reference [#api-reference]
### ScrollSpy [#scrollspy]
The root component that manages scroll tracking and contains all ScrollSpy parts.
### Nav [#nav]
The navigation container component.
### Link [#link]
Navigation link that scrolls to a section.
### Viewport [#viewport]
The viewport container component for sections.
### Section [#section]
Content section that gets tracked by the scroll spy.
## Accessibility [#accessibility]
### Keyboard Shortcuts [#keyboard-shortcuts]
The ScrollSpy component follows standard link navigation patterns:
# Scroller
URL: /docs/components/base/scroller
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/scroller
```
```bash
pnpm dlx shadcn@latest add @diceui/scroller
```
```bash
yarn dlx shadcn@latest add @diceui/scroller
```
```bash
bun x shadcn@latest add @diceui/scroller
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/react @base-ui/utils
```
```bash
pnpm add @base-ui/react @base-ui/utils
```
```bash
yarn add @base-ui/react @base-ui/utils
```
```bash
bun add @base-ui/react @base-ui/utils
```
Copy and paste the following code into your project.
## Layout [#layout]
Import the parts, and compose them together.
```tsx
import { Scroller } from "@/components/ui/scroller"
{/* Scrollable content */}
```
## Examples [#examples]
### Horizontal Scroll [#horizontal-scroll]
Set the `orientation` to `horizontal` to enable horizontal scrolling.
### Hidden Scrollbar [#hidden-scrollbar]
Set the `hideScrollbar` to `true` to hide the scrollbar while maintaining scroll functionality.
### Navigation Buttons [#navigation-buttons]
Set the `withNavigation` to `true` to enable navigation buttons.
## API Reference [#api-reference]
### Scroller [#scroller]
The main scrollable container component.
# Segmented Input
URL: /docs/components/base/segmented-input
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/segmented-input
```
```bash
pnpm dlx shadcn@latest add @diceui/segmented-input
```
```bash
yarn dlx shadcn@latest add @diceui/segmented-input
```
```bash
bun x shadcn@latest add @diceui/segmented-input
```
Copy and paste the following code into your project.
## Layout [#layout]
Import the parts, and compose them together.
```tsx
import * as SegmentedInput from "@/components/ui/segmented-input";
return (
)
```
## Examples [#examples]
### Form Input [#form-input]
Use segmented inputs for structured form data like phone numbers or addresses.
### RGB Color Input [#rgb-color-input]
Create color input controls using segmented inputs for RGB values.
### Vertical Layout [#vertical-layout]
Display segmented inputs in a vertical orientation.
## API Reference [#api-reference]
### SegmentedInput [#segmentedinput]
The main segmented input container.
### SegmentedInputItem [#segmentedinputitem]
Individual input items within the segmented input.
## Accessibility [#accessibility]
The SegmentedInput component follows standard web accessibility practices. Users navigate between inputs using Tab and Shift+Tab keys, which is the expected behavior for form controls.
### Keyboard Interactions [#keyboard-interactions]
# Selection Toolbar
URL: /docs/components/base/selection-toolbar
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/selection-toolbar
```
```bash
pnpm dlx shadcn@latest add @diceui/selection-toolbar
```
```bash
yarn dlx shadcn@latest add @diceui/selection-toolbar
```
```bash
bun x shadcn@latest add @diceui/selection-toolbar
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @floating-ui/react-dom @base-ui/react @base-ui/utils
```
```bash
pnpm add @floating-ui/react-dom @base-ui/react @base-ui/utils
```
```bash
yarn add @floating-ui/react-dom @base-ui/react @base-ui/utils
```
```bash
bun add @floating-ui/react-dom @base-ui/react @base-ui/utils
```
Copy and paste the following code into your project.
Update the import paths to match your project setup.
## Layout [#layout]
Import the parts, and compose them together.
```tsx
import {
SelectionToolbar,
SelectionToolbarItem,
SelectionToolbarSeparator,
} from "@/components/ui/selection-toolbar";
return (
)
```
## Examples [#examples]
### Selection Info [#selection-info]
Track selection information with the `onSelectionChange` callback to display word count, character count, and other metrics.
## API Reference [#api-reference]
### SelectionToolbar [#selectiontoolbar]
The root component that manages the toolbar's visibility and positioning.
### SelectionToolbarItem [#selectiontoolbaritem]
An actionable item within the toolbar, typically containing an icon.
### SelectionToolbarSeparator [#selectiontoolbarseparator]
A visual separator between toolbar items.
## Accessibility [#accessibility]
### Keyboard Interactions [#keyboard-interactions]
# Sortable
URL: /docs/components/base/sortable
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/sortable
```
```bash
pnpm dlx shadcn@latest add @diceui/sortable
```
```bash
yarn dlx shadcn@latest add @diceui/sortable
```
```bash
bun x shadcn@latest add @diceui/sortable
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/react @base-ui/utils @dnd-kit/core @dnd-kit/modifiers @dnd-kit/sortable @dnd-kit/utilities
```
```bash
pnpm add @base-ui/react @base-ui/utils @dnd-kit/core @dnd-kit/modifiers @dnd-kit/sortable @dnd-kit/utilities
```
```bash
yarn add @base-ui/react @base-ui/utils @dnd-kit/core @dnd-kit/modifiers @dnd-kit/sortable @dnd-kit/utilities
```
```bash
bun add @base-ui/react @base-ui/utils @dnd-kit/core @dnd-kit/modifiers @dnd-kit/sortable @dnd-kit/utilities
```
Copy and paste the following code into your project.
Update the import paths to match your project setup.
## Layout [#layout]
Import the parts, and compose them together.
```tsx
import {
Sortable,
SortableContent,
SortableItem,
SortableItemHandle,
SortableOverlay,
} from "@/components/ui/sortable";
return (
)
```
Every part accepts a `render` prop, so an item can be composed with your own element or component instead of the default `div`.
```tsx
}>
{item.name}
```
## Usage [#usage]
### With Primitive Values [#with-primitive-values]
When using primitive arrays (strings, numbers), the `getItemValue` prop is optional. The component will automatically use the item itself as the unique identifier.
```tsx
const [items, setItems] = React.useState(["Item 1", "Item 2", "Item 3"]);
{items.map((item) => (
{item}
))}
```
### With Object Arrays [#with-object-arrays]
When using object arrays, the `getItemValue` prop is required to extract a unique identifier from each item.
```tsx
const [items, setItems] = React.useState([
{ id: 1, name: "Item 1" },
{ id: 2, name: "Item 2" },
]);
item.id}
>
{items.map((item) => (
{item.name}
))}
```
## Examples [#examples]
### With Dynamic Overlay [#with-dynamic-overlay]
Display a dynamic overlay when an item is being dragged.
### With Handle [#with-handle]
Use `SortableItemHandle` as a drag handle for sortable items.
### With Primitive Values [#with-primitive-values-1]
Use an array of primitives (string or number) instead of objects for sorting.
## API Reference [#api-reference]
### Sortable [#sortable]
The main container component for sortable functionality.
### SortableContent [#sortablecontent]
Container for sortable items. Multiple `SortableContent` components can be used within a `Sortable` component.
### SortableItem [#sortableitem]
Individual sortable item component.
### SortableItemHandle [#sortableitemhandle]
A button component that acts as a drag handle for sortable items.
The component renders a `button` and adds the following styles:
* `select-none` for pointer events
* `cursor-grab` when not dragging (unless `flatCursor` is true)
* `cursor-grabbing` when dragging (unless `flatCursor` is true)
* `cursor-default` when `flatCursor` is true
### SortableOverlay [#sortableoverlay]
The overlay component that appears when an item is being dragged.
## Accessibility [#accessibility]
### Keyboard Interactions [#keyboard-interactions]
# Speed Dial
URL: /docs/components/base/speed-dial
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/speed-dial
```
```bash
pnpm dlx shadcn@latest add @diceui/speed-dial
```
```bash
yarn dlx shadcn@latest add @diceui/speed-dial
```
```bash
bun x shadcn@latest add @diceui/speed-dial
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/react @base-ui/utils
```
```bash
pnpm add @base-ui/react @base-ui/utils
```
```bash
yarn add @base-ui/react @base-ui/utils
```
```bash
bun add @base-ui/react @base-ui/utils
```
Copy and paste the following code into your project.
Update the import paths to match your project setup.
## Layout [#layout]
Import the parts, and compose them together.
```tsx
import {
SpeedDial,
SpeedDialTrigger,
SpeedDialContent,
SpeedDialItem,
SpeedDialLabel,
SpeedDialAction,
} from "@/components/ui/speed-dial";
return (
)
```
## Examples [#examples]
### With Labels [#with-labels]
Display visible labels next to each action button for better discoverability.
### Hover Mode [#hover-mode]
Set `activationMode="hover"` on the root component to open the speed dial when hovering over the trigger. The speed dial will automatically close when the mouse leaves. Use the `delay` prop to control how long to wait before the speed dial opens.
### Controlled State [#controlled-state]
Use the `open` and `onOpenChange` props to control the speed dial state programmatically.
### Sides [#sides]
The speed dial can expand in different directions using the `side` prop.
### Fixed Positioning [#fixed-positioning]
To position the speed dial at a fixed location in the viewport (e.g., bottom-right corner), apply positioning classes to the `SpeedDial` root component, not the trigger.
```tsx
{/* actions */}
```
**Important:** Apply `fixed` positioning to the `SpeedDial` root, not the `SpeedDialTrigger`. This ensures the content stays aligned with the trigger.
**Why this matters:** The content uses `absolute` positioning relative to its parent. If you apply `fixed` to the trigger instead, the content won't be able to position itself correctly relative to the trigger.
```tsx
// ❌ Incorrect - content won't align properly
{/* actions */}
// ✅ Correct - content aligns with trigger
{/* actions */}
```
## API Reference [#api-reference]
### SpeedDial [#speeddial]
The main container component for the speed dial.
### SpeedDialTrigger [#speeddialtrigger]
The button that toggles the speed dial open/closed state.
### SpeedDialContent [#speeddialcontent]
The container for the action items that appears when the speed dial is open.
### SpeedDialItem [#speeddialitem]
A wrapper for each action and its associated label.
### SpeedDialAction [#speeddialaction]
An interactive button within the speed dial that triggers an action.
### SpeedDialLabel [#speeddiallabel]
A text label that describes the associated action.
## Accessibility [#accessibility]
### Keyboard Interactions [#keyboard-interactions]
# Stack
URL: /docs/components/base/stack
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/stack
```
```bash
pnpm dlx shadcn@latest add @diceui/stack
```
```bash
yarn dlx shadcn@latest add @diceui/stack
```
```bash
bun x shadcn@latest add @diceui/stack
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/react
```
```bash
pnpm add @base-ui/react
```
```bash
yarn add @base-ui/react
```
```bash
bun add @base-ui/react
```
Copy and paste the following code into your project.
## Layout [#layout]
```tsx
import * as Stack from "@/components/ui/stack";
```
## Examples [#examples]
### Without Expansion [#without-expansion]
Disable the hover expansion effect for a static stack.
### Different Sides [#different-sides]
Stack items from different sides using the `side` prop.
## API Reference [#api-reference]
### Stack.Root [#stackroot]
The main container component that manages layout and hover interactions.
### Stack.Item [#stackitem]
Individual items within the stack. These are automatically positioned and animated.
## Features [#features]
* **Hover Expansion**: Items expand on hover to reveal all stacked items
* **Customizable**: Control visible items, gap, offset, and scale factor
* **Smooth Animations**: Elegant CSS transitions for all interactions
* **Flexible Styling**: Works with any content and styling approach
* **Accessibility**: Proper data attributes and semantic HTML
## Usage Notes [#usage-notes]
* The stack uses absolute positioning for items, ensure the parent container has enough space
* Use the `visibleItems` prop to control how many items are visible in the collapsed state
* The `scaleFactor` prop determines how much each subsequent item shrinks (0.05 = 5% smaller)
* Set `expandOnHover={false}` to disable the expansion effect
* All items beyond `visibleItems` will have reduced opacity and be non-interactive when collapsed
## Credits [#credits]
* [Emil Kowalski](https://emilkowal.ski/) - For the [Sonner](https://github.com/emilkowalski/sonner) toast library.
# Stat
URL: /docs/components/base/stat
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/stat
```
```bash
pnpm dlx shadcn@latest add @diceui/stat
```
```bash
yarn dlx shadcn@latest add @diceui/stat
```
```bash
bun x shadcn@latest add @diceui/stat
```
Copy and paste the following code into your project.
## Layout [#layout]
Import the parts, and compose them together.
```tsx
import {
Stat,
StatLabel,
StatValue,
StatIndicator,
StatTrend,
StatDescription,
StatSeparator,
} from "@/components/ui/stat";
return (
Total Revenue$45,231
+20.1% from last month
Total revenue generated in the current billing period
);
```
## Examples [#examples]
### Variants [#variants]
Explore different indicator variants and color themes.
### Layout Options [#layout-options]
Combine different stat components to create rich statistical displays.
## API Reference [#api-reference]
### Stat [#stat]
The main container component that provides a card-style layout for displaying statistics.
### StatLabel [#statlabel]
A label component for the statistic title or category.
### StatIndicator [#statindicator]
A visual indicator component that can display icons, badges, or action buttons with various color themes.
### StatValue [#statvalue]
Displays the primary statistic value with emphasized typography.
### StatTrend [#stattrend]
Displays trend information with directional styling (up, down, or neutral).
### StatSeparator [#statseparator]
A horizontal separator for dividing content within the stat card.
### StatDescription [#statdescription]
Additional descriptive text for providing context about the stat.
# Status
URL: /docs/components/base/status
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/status
```
```bash
pnpm dlx shadcn@latest add @diceui/status
```
```bash
yarn dlx shadcn@latest add @diceui/status
```
```bash
bun x shadcn@latest add @diceui/status
```
Copy and paste the following code into your project.
## Layout [#layout]
Import the parts, and compose them together.
```tsx
import {
Status,
StatusIndicator,
StatusLabel,
} from "@/components/ui/status";
return (
Online
);
```
## Examples [#examples]
### Variants [#variants]
Status supports five color variants to represent different states.
### Text Only [#text-only]
Use status without the indicator for a simpler appearance.
### Service Status List [#service-status-list]
Display multiple status items in a list format, ideal for system health dashboards.
## API Reference [#api-reference]
### Status [#status]
The main container component that provides the badge-style wrapper with color variants.
### StatusIndicator [#statusindicator]
An animated pulse indicator for the status.
### StatusLabel [#statuslabel]
The text label for the status.
## Accessibility [#accessibility]
The Status component uses semantic HTML and follows best practices for accessibility:
* Uses `div` elements with proper ARIA attributes when needed
* Color is not the only means of conveying information—always include text labels
* Supports keyboard navigation when used with interactive elements via `asChild`
## Notes [#notes]
* The animated ping effect uses Tailwind's built-in `animate-ping` utility for smooth performance
* Colors automatically adapt to dark mode
* The indicator animation runs continuously to draw attention to live status changes
* Use the `asChild` prop to render Status as a link or button for interactive use cases
# Stepper
URL: /docs/components/base/stepper
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/stepper
```
```bash
pnpm dlx shadcn@latest add @diceui/stepper
```
```bash
yarn dlx shadcn@latest add @diceui/stepper
```
```bash
bun x shadcn@latest add @diceui/stepper
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/react @base-ui/utils
```
```bash
pnpm add @base-ui/react @base-ui/utils
```
```bash
yarn add @base-ui/react @base-ui/utils
```
```bash
bun add @base-ui/react @base-ui/utils
```
Copy and paste the direction utility into your project.
Copy and paste the following code into your project.
Update the import paths to match your project setup.
## Layout [#layout]
Import the parts, and compose them together.
```tsx
import {
Stepper,
StepperList,
StepperItem,
StepperTrigger,
StepperIndicator,
StepperTitle,
StepperDescription,
StepperSeparator,
StepperContent,
StepperPrev,
StepperNext,
} from "@/components/ui/stepper";
return (
)
```
## Examples [#examples]
### Vertical Layout [#vertical-layout]
A stepper with vertical orientation for compact layouts.
### With Validation [#with-validation]
Use the `onValidate` prop to validate the current step before moving to the next one.
### With Form [#with-form]
A stepper integrated with form validation, showing step-by-step form completion.
## API Reference [#api-reference]
### Stepper [#stepper]
The main container component for the stepper.
### StepperList [#stepperlist]
The container for stepper items, typically an ordered list.
### StepperItem [#stepperitem]
A single step item in the stepper.
### StepperTrigger [#steppertrigger]
The clickable trigger for each step, typically wrapping the indicator.
### StepperIndicator [#stepperindicator]
The visual indicator showing the step number or completion status.
### StepperSeparator [#stepperseparator]
The line connecting steps, showing progress between them.
### StepperTitle [#steppertitle]
The title text for each step.
### StepperDescription [#stepperdescription]
The description text for each step.
### StepperContent [#steppercontent]
The content area that displays for the active step.
### StepperPrev [#stepperprev]
A navigation button that moves to the previous step. Automatically disabled on the first step and skips validation when navigating backwards.
### StepperNext [#steppernext]
A navigation button that moves to the next step. Automatically disabled on the last step and respects validation rules when navigating forwards.
## Accessibility [#accessibility]
### Keyboard Interactions [#keyboard-interactions]
# Swap
URL: /docs/components/base/swap
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/swap
```
```bash
pnpm dlx shadcn@latest add @diceui/swap
```
```bash
yarn dlx shadcn@latest add @diceui/swap
```
```bash
bun x shadcn@latest add @diceui/swap
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/react @base-ui/utils
```
```bash
pnpm add @base-ui/react @base-ui/utils
```
```bash
yarn add @base-ui/react @base-ui/utils
```
```bash
bun add @base-ui/react @base-ui/utils
```
Copy and paste the following code into your project.
Update the import paths to match your project setup.
## Layout [#layout]
Import the parts, and compose them together.
```tsx
import { Swap, SwapOn, SwapOff } from "@/components/ui/swap";
return (
)
```
## Examples [#examples]
### Animations [#animations]
The swap component supports 4 different animation types: fade, rotate, flip, and scale.
## API Reference [#api-reference]
### Swap [#swap]
The main container component for swap functionality.
### SwapOn [#swapon]
The content shown when the swap is in the swapped state.
### SwapOff [#swapoff]
The content shown when the swap is in the default state.
## Accessibility [#accessibility]
### Keyboard Interactions [#keyboard-interactions]
# Tags Input
URL: /docs/components/base/tags-input
## Installation [#installation]
npm
pnpm
yarn
bun
```bash
npm install @diceui/tags-input
```
```bash
pnpm add @diceui/tags-input
```
```bash
yarn add @diceui/tags-input
```
```bash
bun add @diceui/tags-input
```
## Installation with shadcn/ui [#installation-with-shadcnui]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/tags-input
```
```bash
pnpm dlx shadcn@latest add @diceui/tags-input
```
```bash
yarn dlx shadcn@latest add @diceui/tags-input
```
```bash
bun x shadcn@latest add @diceui/tags-input
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @diceui/tags-input
```
```bash
pnpm add @diceui/tags-input
```
```bash
yarn add @diceui/tags-input
```
```bash
bun add @diceui/tags-input
```
Copy and paste the following code into your project.
## Layout [#layout]
Import the parts, and compose them together.
```tsx
import {
TagsInput,
TagsInputLabel,
TagsInputItem,
TagsInputItemText,
TagsInputItemDelete,
TagsInputInput,
TagsInputClear,
} from "@diceui/tags-input";
return (
)
```
## Examples [#examples]
### Editable [#editable]
### With Validation [#with-validation]
Validate the input value before adding it to the list. Can be used to prevent duplicate tags.
### With Sortable [#with-sortable]
`TagsInput` can be composed with [`Sortable`](/docs/components/base/sortable) to allow reordering of tags.
## API Reference [#api-reference]
### TagsInput [#tagsinput]
Container for the tags input.
### TagsInputLabel [#tagsinputlabel]
Label element for the tags input.
### TagsInputInput [#tagsinputinput]
Text input for adding new tags.
### TagsInputItem [#tagsinputitem]
Individual tag item.
### TagsInputItemText [#tagsinputitemtext]
Text content of a tag.
### TagsInputItemDelete [#tagsinputitemdelete]
Button to remove a tag.
### TagsInputClear [#tagsinputclear]
Button to clear all tags.
## Accessibility [#accessibility]
### Keyboard Interactions [#keyboard-interactions]
# Time Picker
URL: /docs/components/base/time-picker
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/time-picker
```
```bash
pnpm dlx shadcn@latest add @diceui/time-picker
```
```bash
yarn dlx shadcn@latest add @diceui/time-picker
```
```bash
bun x shadcn@latest add @diceui/time-picker
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/react @base-ui/utils
```
```bash
pnpm add @base-ui/react @base-ui/utils
```
```bash
yarn add @base-ui/react @base-ui/utils
```
```bash
bun add @base-ui/react @base-ui/utils
```
Copy and paste the visually hidden input component into your project.
Copy and paste the following code into your project.
Update the import paths to match your project setup.
## Layout [#layout]
Import the parts, and compose them together.
```tsx
import {
TimePicker,
TimePickerLabel,
TimePickerInputGroup,
TimePickerInput,
TimePickerSeparator,
TimePickerTrigger,
TimePickerContent,
TimePickerHour,
TimePickerMinute,
TimePickerClear,
} from "@/components/ui/time-picker";
return (
)
```
## Examples [#examples]
### With Step [#with-step]
Use the `hourStep`, `minuteStep`, and `secondStep` props to set custom intervals for hour, minute, and second selection respectively.
### With Seconds [#with-seconds]
Include seconds in time selection.
### Custom Placeholders [#custom-placeholders]
Customize empty segment placeholders for different display formats.
### Open on Focus [#open-on-focus]
Use the `openOnFocus` prop to open the content when the input is focused.
### Input Group Click Action [#input-group-click-action]
Configure what happens when clicking on empty space in the input group. By default, it focuses the first input for inline editing, but you can set it to open the popover instead.
### Controlled State [#controlled-state]
Control the time picker value programmatically.
### With Form [#with-form]
Use the time picker in a form with validation.
## API Reference [#api-reference]
### TimePicker [#timepicker]
The main container component for time picker functionality.
### TimePickerLabel [#timepickerlabel]
The label component for the time picker field.
### TimePickerInputGroup [#timepickerinputgroup]
The container for input segments that sets up CSS variables for dynamic segment widths.
Must use style prop to override the css variables of the input segment, because the width is dynamically calculated based on the placeholder length.
### TimePickerTrigger [#timepickertrigger]
Button to open the time picker content.
### TimePickerContent [#timepickercontent]
Container for the time selection interface.
### TimePickerHour [#timepickerhour]
Component for selecting hours.
### TimePickerMinute [#timepickerminute]
Component for selecting minutes.
### TimePickerSecond [#timepickersecond]
Component for selecting seconds.
### TimePickerPeriod [#timepickerperiod]
Component for selecting AM/PM in 12-hour format.
### TimePickerSeparator [#timepickerseparator]
Visual separator between time units.
### TimePickerClear [#timepickerclear]
Button to clear the selected time.
### TimePickerInput [#timepickerinput]
Inline editable input field for time segments (hour, minute, second, period).
## Accessibility [#accessibility]
### Keyboard Interactions [#keyboard-interactions]
## Notes [#notes]
### Behavior [#behavior]
* **Native HTML time input behavior**: Replicates the exact behavior of `` for maximum familiarity
* Auto-pads single digits instantly (typing "1" shows "01")
* Smart auto-advance after two digits or when digit exceeds maximum first digit
* Partial time values supported (e.g., "10:--" instead of "10:00")
* Selection preserved after actions for seamless typing
* **Inline editing**: All time segments are always visible and editable, no need to open the content
* **Content for convenience**: The clock icon trigger opens the content for easier selection with mouse/touch
* **Keyboard-first design**: Full keyboard navigation between segments using arrow keys or tab
* **Clear segments**: Press Backspace or Delete on a selected segment to clear it back to "--"
### Format & Locale [#format--locale]
* **Automatic format detection**: Display format (12-hour vs 24-hour) is automatically detected from user's locale settings
* **Consistent value format**: The time value is always stored in 24-hour format ("HH:mm" or "HH:mm:ss"), regardless of display format
* **Locale override**: Use the `locale` prop to explicitly set a locale (e.g., "en-US" for 12-hour, "en-GB" for 24-hour)
* **Period shortcuts**: In 12-hour format, use A/P or 1/2 keys to quickly set AM/PM
# Timeline
URL: /docs/components/base/timeline
## Installation [#installation]
Command
Manual
npm
pnpm
yarn
bun
```bash
npx shadcn@latest add @diceui/timeline
```
```bash
pnpm dlx shadcn@latest add @diceui/timeline
```
```bash
yarn dlx shadcn@latest add @diceui/timeline
```
```bash
bun x shadcn@latest add @diceui/timeline
```
Install the following dependencies:
npm
pnpm
yarn
bun
```bash
npm install @base-ui/react @base-ui/utils
```
```bash
pnpm add @base-ui/react @base-ui/utils
```
```bash
yarn add @base-ui/react @base-ui/utils
```
```bash
bun add @base-ui/react @base-ui/utils
```
Copy and paste the
`Direction`
component into your project.
Copy and paste the following code into your project.
Update the import paths to match your project setup.
## Layout [#layout]
```tsx
import {
Timeline,
TimelineItem,
TimelineDot,
TimelineConnector,
TimelineContent,
TimelineHeader,
TimelineTitle,
TimelineTime,
TimelineDescription,
} from "@/components/ui/timeline";
```
## Examples [#examples]
### Horizontal Timeline [#horizontal-timeline]
Display timeline events horizontally across the screen.
### RTL Timeline [#rtl-timeline]
Display timeline with right-to-left layout for RTL languages.
### Alternate Timeline [#alternate-timeline]
Display timeline events in an alternating pattern with content on both sides.
### Horizontal Alternate Timeline [#horizontal-alternate-timeline]
Display timeline events horizontally with content alternating above and below.
### With Custom Dots [#with-custom-dots]
Add custom icons or content to the timeline dots using CSS variables.
## API Reference [#api-reference]
### Timeline [#timeline]
The root container for timeline items.
### TimelineItem [#timelineitem]
A single timeline item containing content, marker, and connector.
### TimelineDot [#timelinedot]
The visual marker/dot for a timeline item.
### TimelineConnector [#timelineconnector]
The line connecting timeline items.
### TimelineHeader [#timelineheader]
Container for the title and time of a timeline item.
### TimelineTitle [#timelinetitle]
The title/heading of a timeline item.
### TimelineDescription [#timelinedescription]
The description/body text of a timeline item.
### TimelineContent [#timelinecontent]
Container for the timeline item's content (header, description, etc.).
### TimelineTime [#timelinetime]
A semantic time element for displaying dates/times.
## Features [#features]
### Flexible Orientations [#flexible-orientations]
The timeline supports both vertical and horizontal orientations. Use the `orientation` prop on the root `Timeline` component to switch between layouts.
### Alternate Variant [#alternate-variant]
The timeline supports an alternate variant where content alternates on both sides of the timeline. Use the `variant="alternate"` prop on the root `Timeline` component to enable this layout. This works with both vertical and horizontal orientations:
* **Vertical alternate**: Content alternates left and right of the center line
* **Horizontal alternate**: Content alternates above and below the center line
```tsx
{/* Content alternates above and below */}
```
### RTL Support [#rtl-support]
The timeline fully supports right-to-left (RTL) layouts through the `dir` prop. When set to `"rtl"`, the timeline automatically flips its layout direction, making it ideal for RTL languages like Arabic, Hebrew, and Persian.
### Active Index [#active-index]
Control the visual state of timeline items using the `activeIndex` prop on the root component. Items before the active index will be marked as "completed", the item at the active index will be "active", and items after will be "pending".
```tsx
Step 1 - CompletedStep 2 - CompletedStep 3 - Active (index 2)Step 4 - Pending
```
The `activeIndex` is zero-based, so `activeIndex={2}` makes the third item active.
### Custom Icons [#custom-icons]
Replace the default dot marker with custom icons or React components by passing children to `TimelineDot`, giving you full control over the visual appearance.
### Composition Pattern [#composition-pattern]
Built with Base UI's `useRender` hook for flexible composition. All components accept a `render` prop for custom rendering, giving you complete control over the structure and styling of your timeline.
## Accessibility [#accessibility]
### ARIA Roles [#aria-roles]
The timeline uses ARIA roles and attributes for proper accessibility:
* Root uses `role="list"` and `aria-orientation` to represent an ordered list of events
* Each item uses `role="listitem"` for proper list semantics
* Active items use `aria-current="step"` to indicate current position in the timeline
* Semantic `