Density
One attribute narrows the spacing scale to 0.8×. Spacing tightens; copy does not shrink, and a control keeps its target size.
A compact console is one attribute, and the scale behind it belongs to the package.
<html data-density="compact">It is read wherever it appears, not only on :root, so a single dense region inside a
comfortable page is expressible — put the attribute on that region. comfortable is the default
and is spelled out as a no-op, so a product toggling between the two writes a value in both
directions instead of removing an attribute.
| Run | State | Cost |
|---|---|---|
| run 128 | Merged | €1.08 |
| run 127 | Running | €0.42 |
| run 126 | Failed | €0.11 |
| Run | State | Cost |
|---|---|---|
| run 128 | Merged | €1.08 |
| run 127 | Running | €0.42 |
| run 126 | Failed | €0.11 |
Both panels above are the same markup, rendered twice, differing only in that attribute. If a claim about density needed different children to hold, it would not be a claim about density.
Why this is not a consumer's side channel
Every p-*, gap-*, m-*, h-* and size-* utility in Tailwind v4 is
calc(var(--spacing) * N). So one --spacing declaration at a consumer's root re-metrics every
component in this package by inheritance, at a metric the package has never looked at. That is
modification at a distance: the components change, the package cannot see it happen, and nothing
is wrong until someone takes a screenshot.
The lever ships here instead, with the cases a blind override gets wrong already answered.
Two rules decide what participates
Copy does not shrink. Type sizes come from --text-*, not from --spacing, so they are
untouched by construction rather than by anyone's care — which means the stance cannot be undone
by accident. A compact surface fits more rows; it never asks anyone to read smaller words.
A control's size is not a gap. Under a bare narrowing every field's h-10 becomes 32px, every
icon's size-4 becomes 12.8px, and the status chip's h-6 becomes 19px. None of those is
spacing: a control's height is a target size, an icon is content at optical parity with the
text beside it, and a chip's box is its own geometry.
Shorter controls are a different request
A dense form wants size="sm" — on Input, Textarea, NativeSelect, Button and
StatusPill. That is a decision about one form; density is a decision about a document, and the
two should not be the same switch.
How the exceptions work
The same custom property, re-declared locally. --spacing is inherited and every utility resolves
it at the element, so restoring it on a control restores every metric that control derives from
it — its height, its padding, its icon — while the layout around it keeps the tightened value.
One property, both answers, no second scale to keep in step.
| Restored on | Why |
|---|---|
svg | an icon is content, at optical parity with the type beside it |
input, select, textarea | a control's height is a target size — element selectors, so a consumer's own bare controls stay flush with ours |
[data-oc-density="fixed"] | the opt-in below |
data-oc-density="fixed" marks a subtree whose box is geometry rather than layout. The package
puts it on Button, StatusPill, DialogContent, SheetContent and PopoverContent; put it on
anything of your own that should hold its metric. It is a plain attribute on purpose — no prop, no
import, and it works on a <div>.
Where it lives
src/styles/density.css, imported by @oceanic-hub/brand-system/styles and inert until a
data-density attribute appears — so adopting this release changes nothing until you ask for it.
Reachable on its own as @oceanic-hub/brand-system/styles/density.
The full argument is in the doctrine: Density.
Core layer
The one doctrine every surface inherits: one colour-free token set with light and dark values, elevation by border, one radius scale, no shadow, no serif.
Composition & pairing map
What maps to what between Oceanic and shadcn, in both directions — plus the composition grammar, the colour substitutions, and the generation guard.