Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/stack-spacing-options.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': minor
---

**Stack**: Add `tight` (4px) and `cozy` (12px) spacing values to `gap` and `padding` props. Add `paddingBlock` and `paddingInline` props for directional padding control.
14 changes: 12 additions & 2 deletions packages/react/src/Stack/Stack.docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"props": [
{
"name": "gap",
"type": "'none' | 'condensed' | 'normal' | 'spacious' | ResponsiveValue<'none' | 'condensed' | 'normal' | 'spacious'>",
"type": "'none' | 'tight' | 'condensed' | 'cozy' | 'normal' | 'spacious' | ResponsiveValue<'none' | 'tight' | 'condensed' | 'cozy' | 'normal' | 'spacious'>",
"description": "Specify the gap between children elements in the stack."
},
{
Expand All @@ -33,9 +33,19 @@
},
{
"name": "padding",
"type": "'none' | 'condensed' | 'normal' | 'spacious' | ResponsiveValue<'none' | 'condensed' | 'normal' | 'spacious'>",
"type": "'none' | 'tight' | 'condensed' | 'cozy' | 'normal' | 'spacious' | ResponsiveValue<'none' | 'tight' | 'condensed' | 'cozy' | 'normal' | 'spacious'>",
"description": "Specify the padding of the stack container."
},
{
"name": "paddingBlock",
"type": "'none' | 'tight' | 'condensed' | 'cozy' | 'normal' | 'spacious' | ResponsiveValue<'none' | 'tight' | 'condensed' | 'cozy' | 'normal' | 'spacious'>",
"description": "Specify the block (vertical) padding of the stack container. Overrides the block axis of padding when both are set."
},
{
"name": "paddingInline",
"type": "'none' | 'tight' | 'condensed' | 'cozy' | 'normal' | 'spacious' | ResponsiveValue<'none' | 'tight' | 'condensed' | 'cozy' | 'normal' | 'spacious'>",
"description": "Specify the inline (horizontal) padding of the stack container. Overrides the inline axis of padding when both are set."
},
{
"name": "className",
"type": "string"
Expand Down
60 changes: 60 additions & 0 deletions packages/react/src/Stack/Stack.features.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,66 @@ export default {
component: Stack,
} as Meta<typeof Stack>

const Placeholder = ({label}: {label: string}) => (
<div
style={{
padding: 'var(--base-size-8) var(--base-size-16)',
backgroundColor: 'var(--bgColor-accent-muted)',
border: '1px solid var(--borderColor-accent-muted)',
borderRadius: 'var(--borderRadius-medium)',
fontSize: 'var(--text-body-size-small)',
}}
>
{label}
</div>
)

export const GapScale = () => (
<Stack gap="spacious">
{(['none', 'tight', 'condensed', 'cozy', 'normal', 'spacious'] as const).map(gap => (
<Stack key={gap}>
<span style={{fontSize: 'var(--text-body-size-small)', color: 'var(--fgColor-muted)'}}>
gap=&quot;{gap}&quot;
</span>
<Stack direction="horizontal" gap={gap}>
<Placeholder label="A" />
<Placeholder label="B" />
<Placeholder label="C" />
</Stack>
</Stack>
))}
</Stack>
)

export const DirectionalPadding = () => (
<Stack gap="normal">
<Stack padding="normal" style={{backgroundColor: 'var(--bgColor-muted)'}}>
<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>
Comment on lines +44 to +51
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot generated this review using guidance from repository custom instructions.
</Stack>
)

export const PaddingScale = () => (
<Stack gap="spacious">
{(['none', 'tight', 'condensed', 'cozy', 'normal', 'spacious'] as const).map(padding => (
<Stack key={padding}>
<span style={{fontSize: 'var(--text-body-size-small)', color: 'var(--fgColor-muted)'}}>
padding=&quot;{padding}&quot;
</span>
<Stack padding={padding} style={{backgroundColor: 'var(--bgColor-muted)'}}>
<Placeholder label="Content" />
</Stack>
</Stack>
))}
</Stack>
)

export const ShrinkingStackItems = () => (
<div style={{maxWidth: '200px', padding: 'var(--base-size-8)'}}>
<Stack direction="horizontal" gap="condensed">
Expand Down
Loading
Loading