Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
One-time setup that gathers your project's design context and saves it to CLAUDE.md for future sessions.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
reference/layout.md
1Space is the most underused design tool. Find the layout's actual problem (monotone spacing, weak hierarchy, identical card grids, the centered-stack default) and fix the structure, not the surface.23---45## Register67Brand: asymmetric compositions, fluid spacing with `clamp()`, intentional grid-breaking for emphasis. Rhythm through contrast: tight groupings paired with generous separations.89Product: predictable grids, consistent densities, familiar navigation patterns. Responsive behavior is structural (collapse sidebar, responsive table), not fluid typography. Consistency IS an affordance.1011---1213## Assess Current Layout1415Analyze what's weak about the current spatial design:16171. **Spacing**:18- Is spacing consistent or arbitrary? (Random padding/margin values)19- Is all spacing the same? (Equal padding everywhere = no rhythm)20- Are related elements grouped tightly, with generous space between groups?21222. **Visual hierarchy**:23- Apply the squint test: blur your (metaphorical) eyes. Can you still identify the most important element, second most important, and clear groupings?24- Is hierarchy achieved effectively? (Space and weight alone can be enough; is the current approach working?)25- Does whitespace guide the eye to what matters?26273. **Grid & structure**:28- Is there a clear underlying structure, or does the layout feel random?29- Are identical card grids used everywhere? (Icon + heading + text, repeated endlessly)30- Is everything centered? (Left-aligned with asymmetric layouts feels more designed, but not a hard and fast rule)31324. **Rhythm & variety**:33- Does the layout have visual rhythm? (Alternating tight/generous spacing)34- Is every section structured the same way? (Monotonous repetition)35- Are there intentional moments of surprise or emphasis?36375. **Density**:38- Is the layout too cramped? (Not enough breathing room)39- Is the layout too sparse? (Excessive whitespace without purpose)40- Does density match the content type? (Data-dense UIs need tighter spacing; marketing pages need more air)4142**CRITICAL**: Layout problems are often the root cause of interfaces feeling "off" even when colors and fonts are fine. Space is a design material; use it with intention.4344## Plan Layout Improvements4546Consult the [spatial design reference](spatial-design.md) for detailed guidance on grids, rhythm, and container queries.4748Create a systematic plan:4950- **Spacing system**: Use a consistent scale (a framework's built-in scale like Tailwind's, rem-based tokens, or a custom system). The specific values matter less than consistency.51- **Hierarchy strategy**: How will space communicate importance?52- **Layout approach**: What structure fits the content? Flex for 1D, Grid for 2D, named areas for complex page layouts.53- **Rhythm**: Where should spacing be tight vs generous?5455## Improve Layout Systematically5657### Establish a Spacing System5859- Use a consistent spacing scale (framework scales like Tailwind, rem-based tokens, or a custom scale all work). What matters is that values come from a defined set, not arbitrary numbers.60- Name tokens semantically if using custom properties: `--space-xs` through `--space-xl`, not `--spacing-8`61- Use `gap` for sibling spacing instead of margins; eliminates margin collapse hacks62- Apply `clamp()` for fluid spacing that breathes on larger screens6364### Create Visual Rhythm6566- **Tight grouping** for related elements (8-12px between siblings)67- **Generous separation** between distinct sections (48-96px)68- **Varied spacing** within sections (not every row needs the same gap)69- **Asymmetric compositions**: break the predictable centered-content pattern when it makes sense7071### Choose the Right Layout Tool7273- **Use Flexbox for 1D layouts**: Rows of items, nav bars, button groups, card contents, most component internals. Flex is simpler and more appropriate for the majority of layout tasks.74- **Use Grid for 2D layouts**: Page-level structure, dashboards, data-dense interfaces, anything where rows AND columns need coordinated control.75- **Don't default to Grid** when Flexbox with `flex-wrap` would be simpler and more flexible.76- Use `repeat(auto-fit, minmax(280px, 1fr))` for responsive grids without breakpoints.77- Use named grid areas (`grid-template-areas`) for complex page layouts; redefine at breakpoints.7879### Break Card Grid Monotony8081- Don't default to card grids for everything; spacing and alignment create visual grouping naturally82- Use cards only when content is truly distinct and actionable. Never nest cards inside cards83- Vary card sizes, span columns, or mix cards with non-card content to break repetition8485### Strengthen Visual Hierarchy8687- Use the fewest dimensions needed for clear hierarchy. Space alone can be enough; generous whitespace around an element draws the eye. Some of the most polished designs achieve rhythm with just space and weight. Add color or size contrast only when simpler means aren't sufficient.88- Be aware of reading flow: in LTR languages, the eye naturally scans top-left to bottom-right, but primary action placement depends on context (e.g., bottom-right in dialogs, top in navigation).89- Create clear content groupings through proximity and separation.9091### Manage Depth & Elevation9293- Create a semantic z-index scale (dropdown → sticky → modal-backdrop → modal → toast → tooltip)94- Build a consistent shadow scale (sm → md → lg → xl); shadows should be subtle95- Use elevation to reinforce hierarchy, not as decoration9697### Optical Adjustments9899- If an icon looks visually off-center despite being geometrically centered, nudge it. But only if you're confident it actually looks wrong. Don't adjust speculatively.100101**NEVER**:102- Use arbitrary spacing values outside your scale103- Make all spacing equal (variety creates hierarchy)104- Wrap everything in cards (not everything needs a container)105- Nest cards inside cards (use spacing and dividers for hierarchy within)106- Use identical card grids everywhere (icon + heading + text, repeated)107- Center everything (left-aligned with asymmetry feels more designed)108- Default to the hero metric layout (big number, small label, stats, gradient) as a template. If showing real user data, a prominent metric can work, but it should display actual data, not decorative numbers.109- Default to CSS Grid when Flexbox would be simpler; use the simplest tool for the job110- Use arbitrary z-index values (999, 9999); build a semantic scale111112## Verify Layout Improvements113114- **Squint test**: Can you identify primary, secondary, and groupings with blurred vision?115- **Rhythm**: Does the page have a satisfying beat of tight and generous spacing?116- **Hierarchy**: Is the most important content obvious within 2 seconds?117- **Breathing room**: Does the layout feel comfortable, not cramped or wasteful?118- **Consistency**: Is the spacing system applied uniformly?119- **Responsiveness**: Does the layout adapt gracefully across screen sizes?120121When the rhythm and hierarchy land, hand off to `$impeccable polish` for the final pass.122123## Live-mode signature params124125Each variant MUST declare a `density` param. Drive all spacing tokens in the variant's scoped CSS through `calc(var(--p-density, 1) * <base>)`: paddings, gaps, column widths. Users slide from airy to packed and see layout re-breathe with no regeneration.126127```json128{"id":"density","kind":"range","min":0.6,"max":1.4,"step":0.05,"default":1,"label":"Density"}129```130131For variants whose topology genuinely changes (stacked vs. side-by-side, grid vs. bento), use a `steps` param whose scoped CSS branches via `:scope[data-p-structure="X"]`. One structure param + one density param is a powerful combo; resist adding a third.132133```json134{"id":"structure","kind":"steps","default":"grid","label":"Structure","options":[135{"value":"stacked","label":"Stacked"},136{"value":"grid","label":"Grid"},137{"value":"bento","label":"Bento"}138]}139```140141See `reference/live.md` for the full params contract.142