Density Toggle

Toggle group that switches between compact and comfortable density, reporting the choice to your handler. Pairs with data tables and dense list views.

src/registry/ui/density-toggle.tsx/r/density-toggle.json

Installation#

bash
npx shadcn@latest add @minidev/density-toggle

MiniDev UI is in the shadcn registry directory, so the short form works with no setup. Older CLI versions can use the full URL: npx shadcn@latest add https://ui.minidev.pro/r/density-toggle.json

Usage#

tsx
import { DensityToggle } from "@/components/ui/density-toggle"

export function Example() {
  return (
    <DensityToggle value={density} onChange={setDensity} />
  )
}

API reference#

DensityToggle props
PropTypeDefault
value"compact" | "comfortable""comfortable"
onChange(value: "compact" | "comfortable") => void-
classNamestring-

Dependencies#

npm

React only

Examples#

All data table components