Rigid UI

Draggable Dashboard

A flexible dashboard component with drag-and-drop functionality for rearranging layout items.

Usage

Dashboard

Drag items to customize your layout

Total Revenue
$45,231.89
+20.1% from last month
Active Users
2,350
+180.1% from last month
Sales
12,234
-19% from last month
Performance
573
+201 since last hour
Revenue Overview
Last 6 months
Jan
Feb
Mar
Apr
May
Jun
draggable-dashboard.tsx
import DraggableDashboard, { DraggableWrapper } from "@/components/draggable-dashboard"

export default function MyDashboard() {
  return (
      <div className="w-full max-w-4xl mx-auto">
        <DraggableDashboard
          showLockToggle={true}
          showHandles={true}
          gridCols={3}
          gap={4}
          defaultLocked={false}
          persistenceKey="my-dashboard"
        >
            <DraggableWrapper id="revenue" gridSize={{ cols: 1, rows: 1 }}>
              <RevenueCard />
            </DraggableWrapper>

            <DraggableWrapper id="users" gridSize={{ cols: 1, rows: 1 }}>
              <UsersCard />
            </DraggableWrapper>

            <DraggableWrapper id="sales" gridSize={{ cols: 1, rows: 1 }}>
              <SalesCard />
            </DraggableWrapper>

            <DraggableWrapper id="performance" gridSize={{ cols: 1, rows: 1 }}>
              <PerformanceCard />
            </DraggableWrapper>

            <DraggableWrapper id="chart" gridSize={{ cols: 2, rows: 1 }}>
              <SimpleChart />
            </DraggableWrapper>
        </DraggableDashboard>
    </div>
  )

}

Installation

Install the Draggable Dashboard component using your preferred package manager.

npx shadcn@latest add https://rigidui.com/r/draggable-dashboard.json

Features

The Draggable Dashboard component is packed with powerful features designed to provide an exceptional user experience.

Drag & Drop

Intuitive drag and drop interface allows users to reorder dashboard components easily.

Grid Layout

Responsive grid system with customizable columns and flexible item sizing.

Lock/Unlock

Toggle between edit and view modes to prevent accidental changes to the layout.

Flexible Sizing

Components can span multiple columns and rows to create complex dashboard layouts.

State Persistence

Dashboard layout is automatically saved to localStorage and persists across page reloads and browser sessions.

Props

DraggableDashboard

PropTypeDefault
children
ReactNode
undefined
className?
string
''
showLockToggle?
boolean
true
showHandles?
boolean
true
gridCols?
number
3
gap?
number
6
defaultLocked?
boolean
false
onOrderChange?
(newOrder: string[]) => void
undefined
persistenceKey?
string
'draggable-dashboard-order'

DraggableWrapper

PropTypeDefault
id
string
undefined
children
ReactNode
undefined
gridSize?
{ cols: number, rows: number }
{ cols: 1, rows: 1 }
className?
string
''
isLocked?
boolean
false
showHandle?
boolean
true