Density-scaled spatial tokens for DaisyUI 5.
This package provides:
- Fluid spacing tokens (
--space-xs→--space-xl) driven by viewport width. - A single global density control (
--spacing-density) to tighten or loosen UI rhythm. - DaisyUI component spacing overrides mapped to those tokens.
npm install @pagehub/daisyui-spatialPeer dependency:
daisyui >= 5.0.0
Import DaisyUI first, then spatial:
@import "daisyui";
@import "@pagehub/daisyui-spatial";Set density globally:
:root {
--spacing-density: 1; /* default */
}Suggested ranges:
0.25minimal1default2.5ultra-spacious
The package exports @theme inline tokens that map to utility classes:
py-space-xl,gap-space-md,px-space-smpx-container-x,gap-section,gap-containerrounded-box,rounded-field,rounded-selector
For best results, define these variables in your host theme/system:
--container-padding-x--container-padding-y--section-gap--container-gap--content-width--radius-box--radius-field--radius-selector
If these are missing, classes that rely on them may collapse to empty computed values.
The stylesheet remaps spacing on common DaisyUI primitives, including:
btn,card-body,hero-content,navbar,footerinput,select,textarea,alert,modal-boxmenu,tabs,toast,progress,chat-bubble, and more
All overrides are designed to scale with --spacing-density.
Run package tests:
pnpm --filter @pagehub/daisyui-spatial testThese tests verify token presence, density scaling contract, and key selector coverage.