feat(Stack): add tight/cozy spacing values and directional padding props#7697
feat(Stack): add tight/cozy spacing values and directional padding props#7697hectahertz wants to merge 3 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: 5d77814 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
There was a problem hiding this comment.
Pull request overview
Adds additional spacing options and directional padding controls to Stack, expanding the ergonomics of layout spacing without requiring utility classes/custom CSS.
Changes:
- Extend
Stackgap/paddingscales with new values:tight(4px) andcozy(12px). - Add
paddingBlockandpaddingInlineprops (including responsive support) and emit corresponding data attributes. - Switch internal padding styling from
paddingshorthand topadding-block/padding-inlinelonghands, plus add new CSS selectors and Storybook feature stories.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/react/src/Stack/Stack.tsx | Extends spacing union types; adds paddingBlock/paddingInline props and data attributes. |
| packages/react/src/Stack/Stack.module.css | Adds tight/cozy spacing rules; introduces block/inline padding rules and responsive variants; moves to logical longhands. |
| packages/react/src/Stack/tests/Stack.test.tsx | Expands coverage for new scale values and new directional padding props (attribute assertions). |
| packages/react/src/Stack/Stack.features.stories.tsx | Adds feature stories for visual verification of new spacing scales and directional padding behavior. |
| packages/react/src/Stack/Stack.docs.json | Updates prop type strings and documents new props. |
| .changeset/stack-spacing-options.md | Adds changeset for a minor release of @primer/react. |
| <Placeholder label='padding="normal" (all sides)' /> | ||
| </Stack> | ||
| <Stack padding="normal" paddingInline="spacious" style={{backgroundColor: 'var(--bgColor-muted)'}}> | ||
| <Placeholder label='padding="normal" paddingInline="spacious"' /> | ||
| </Stack> | ||
| <Stack paddingBlock="condensed" paddingInline="spacious" style={{backgroundColor: 'var(--bgColor-muted)'}}> | ||
| <Placeholder label='paddingBlock="condensed" paddingInline="spacious"' /> | ||
| </Stack> |
There was a problem hiding this comment.
JSX uses single-quoted attribute values for label here (e.g. label='padding="normal" …'), which is inconsistent with the repo’s Prettier/JSX formatting and will likely be rewritten by npx prettier --write. Please reformat these to the standard JSX attribute style (e.g. use double quotes with escaping or a {...} string literal) and run Prettier on the file.
|
cc @HiroAgustin @dfosco, this addresses your requests for more Stack spacing options and consistent padding overrides from the thread. Would love your feedback! |
|
@hectahertz From what you described here this looks great and addresses all of my points from the thread! 🙌 |
|
This is great! Funnily enough: https://github.com/github/github-ui/pull/16820/changes#r2988457348 On top of this it would be nice to expand the |
Closes github/primer#6466
Adds two new spacing values (
tightat 4px,cozyat 12px) to thegapandpaddingscales, filling holes in the spacing ramp that were pushing devs toward utility classes or CSS modules. Also addspaddingBlockandpaddingInlineprops for per-axis padding control, and switches the CSS internals frompaddingshorthand topadding-block+padding-inlinelonghands so external overrides don't get clobbered.New spacing scale:
nonetightcondensedcozynormalspaciousDirectional padding:
paddingBlockandpaddingInlineaccept the same scale aspaddingand override their respective axis.padding="normal" paddingInline="spacious"sets block padding to 16px and inline padding to 24px.Changelog
New
gapandpaddingprops now accept'tight'(4px) and'cozy'(12px) valuespaddingBlockprop for block-axis (vertical) padding controlpaddingInlineprop for inline-axis (horizontal) padding controlChanged
paddingprop CSS internals switched frompaddingshorthand topadding-block+padding-inlinelonghands for predictable override behaviorRemoved
N/A
Rollout strategy
Testing & Reviewing
Components/Stack/Features/GapScale,PaddingScale, andDirectionalPaddingpaddingprop behavior is unchanged (backward compatible, same visual output)paddingBlock/paddingInlineoverride the corresponding axis ofpaddingwhen both are setMerge checklist