Dice UI

repository·main·Indexed 24 days ago

https://github.com/sadmann7/diceui

A collection of accessible, copy-paste ready UI components built with React, TypeScript, and Tailwind CSS, following the shadcn/ui pattern. Features include a component registry, specialized components like Action Bar, Angle Slider, AvatarGroup, and Mention, and a shared utility package @diceui/shared.

Tokens
83.3K
Snippets
242
Records
529
Agent score
84%

What's inside diceui

  1. Overview of Dice UI features and design principles

    main

    Dice UI is a collection of accessible, composable components designed to extend shadcn/ui. It is built using React, TypeScript, and Tailwind CSS.

    Key characteristics include:

    • Composable Design: Build complex interfaces by combining simple, focused components.
    • shadcn/ui Integration: Uses the same design principles, styling approach, and registry distribution as shadcn/ui.
    • Copy-paste Ready: Follows the same installation experience as shadcn/ui components with no complex setup or configuration required.
    • Accessibility: Every component follows WCAG guidelines, includes proper ARIA attributes, and supports keyboard navigation out of the box.
    • Customizability: Built with Tailwind CSS to easily match your existing design system.
  2. Core features of the Data Grid

    main

    The Data Grid is a high-performance, spreadsheet-like component designed for large datasets. Key capabilities include:

    • Performance: Virtualized rows and columns (supports 10,000+ rows).
    • Cell Editing: In-place editing with 9 different cell variants.
    • Clipboard: Full support for Copy/Cut/Paste, including data from Excel/Google Sheets.
    • History: Undo/Redo support for cell updates, row additions, and deletions.
    • Data Management: Advanced filtering (multiple operators), multi-column sorting (drag-and-drop), and row management (add/delete).
    • Column Controls: Resizing, pinning (left/right), hiding, and reordering.
    • Advanced UX: Smart Paste (auto-expands grid), Auto-Fill (type to edit), RTL support, and Read-Only mode.
  3. Get started with Dice UI

    main
    Dice UI provides accessible components built with React, TypeScript, and Tailwind CSS. The components are designed to be copy-paste ready and highly customizable. For full installation instructions, component references, and usage guides, visit the official documentation website.
  4. Validate steps in the Stepper

    main

    You can prevent users from proceeding to the next step if the current step's data is invalid by using the onValidate prop on the Stepper component.

    • StepperNext respects validation rules and will not advance if onValidate returns false.
    • StepperPrev skips validation when navigating backwards, allowing users to correct previous steps freely.
  5. Configure TimePicker format and locale

    main

    The TimePicker handles time formatting based on the user's locale, but you can control this behavior using the locale prop:

    • Automatic detection: The display format (12-hour vs 24-hour) is automatically detected from the user's locale settings.
    • Value format: Regardless of the display format, the time value is always stored in a consistent 24-hour format ("HH:mm" or "HH:mm:ss").
    • Manual override: Use the locale prop to explicitly set a specific locale (e.g., locale="en-US" for 12-hour format or locale="en-GB" for 24-hour format).
    • 12-hour shortcuts: In 12-hour mode, users can use A/P or 1/2 keys to quickly toggle AM/PM.
  6. How the Timeline component works

    main

    The Timeline component is a composable UI for displaying chronological events. It uses a root-and-item pattern where a Timeline container manages the state and layout for multiple TimelineItem components.

    Key Features

    • Orientations: Supports vertical (default) and horizontal layouts via the orientation prop.
    • Alternate Variant: Using variant="alternate" allows content to alternate on both sides (vertical) or above and below (horizontal) the timeline axis.
    • RTL Support: Use the dir="rtl" prop to automatically flip the layout for right-to-left languages.
    • Visual States: Use the activeIndex prop on the root component to automatically manage the status of items. Items before the activeIndex are marked as completed, the item at the index is active, and subsequent items are pending.
    • Customization: You can replace the default dot marker by passing children to TimelineDot (e.g., icons or custom components).
    <Timeline.Root activeIndex={2}>
      <Timeline.Item>Step 1 - Completed</Timeline.Item>
      <Timeline.Item>Step 2 - Completed</Timeline.Item>
      <Timeline.Item>Step 3 - Active (index 2)</Timeline.Item>
      <Timeline.Item>Step 4 - Pending</Timeline.Item>
    </Timeline.Root>
  7. Style components using the `data-variant` attribute

    main

    Each component (such as ResponsiveDialogContent and ResponsiveDialogFooter) exposes a data-variant attribute. You can use this attribute in your CSS or Tailwind classes to apply specific styles depending on whether the component is currently rendered as a dialog (desktop) or a drawer (mobile).

    <ResponsiveDialogContent className="data-[variant=drawer]:pb-8 data-[variant=dialog]:max-w-md">
      {/* content */}
    </ResponsiveDialogContent>
    
    <ResponsiveDialogFooter className="data-[variant=drawer]:flex-col data-[variant=dialog]:flex-row">
      {/* buttons */}
    </ResponsiveDialogFooter>
  8. Configure Timeline orientation and variants

    main

    The Timeline root component accepts props to control the layout direction and visual pattern:

    • orientation: Set to "vertical" (default) or "horizontal".
    • variant: Set to "default" or "alternate". The alternate variant places content on both sides of the timeline (left/right for vertical, above/below for horizontal).
    • dir: Set to "rtl" to enable right-to-left layout support.
    <Timeline variant="alternate" orientation="horizontal">
      {/* Content alternates above and below */}
    </Timeline>
  9. Configure AvatarGroup layout and overflow

    main

    The AvatarGroup component provides several ways to manage large lists and layout orientation:

    • Truncation: Use the max prop to automatically truncate long lists and show overflow indicators.
    • Custom Overflow: Use the renderOverflow prop to provide a custom component for the overflow indicator.
    • RTL Support: Supports right-to-left layouts and vertical RTL stacking.
    • Orientation: Can be configured via the data-orientation attribute.
  10. Color Picker supported formats and EyeDropper support

    main

    Supported Color Formats

    The component supports:

    • HEX (e.g., #3b82f6)
    • RGB (e.g., rgb(59, 130, 246))
    • HSL (e.g., hsl(217, 91%, 60%))
    • HSB (e.g., hsb(217, 76%, 96%))

    All formats support the alpha channel unless the withoutAlpha prop is used.

    EyeDropper API Support

    The ColorPickerEyeDropper component only renders in browsers that support the native EyeDropper API:

    • Chrome/Edge: Supported (v95+)
    • Firefox: Not supported
    • Safari: Not supported

    In unsupported browsers, the component gracefully hides the eye dropper button.