An open source design system that's fully customizable and agent ready
TypeScript
feat(core): per-edge padding — paddingBlockStart/End and paddingInlineStart/End on Section, Stack and Center (#5224)
Xinzi Zhoua4ba1c663124
diff --git a/.changeset/section-stack-center-block-edge-padding.md b/.changeset/section-stack-center-block-edge-padding.mdnew file mode 100644index 0000000000..8a8a787ff7--- /dev/null+++ b/.changeset/section-stack-center-block-edge-padding.md@@ -0,0 +1,24 @@+---+'@astryxdesign/core': patch+---++[feat] `Section`, `Stack` (with `HStack` / `VStack`) and `Center` accept a padding prop for each of the four edges — `paddingBlockStart`, `paddingBlockEnd`, `paddingInlineStart` and `paddingInlineEnd` — so an edge can take its own spacing step without an `xstyle` escape hatch. `Section` also gains the `paddingInline` axis prop it was missing, so all three components now expose the same seven-prop set.++Each prop takes the same spacing scale as `padding`, and resolution is most-specific-wins, per edge:++> edge prop → axis prop (`paddingInline` / `paddingBlock`) → `padding`++An edge prop changes its own edge and leaves the other three alone.++```tsx+<Section padding={6} paddingBlockStart={2}>…</Section> // tight top, 24px elsewhere+<Stack padding={4} paddingInlineEnd={0}>…</Stack> // flush trailing edge+```++The inline props are logical, so `paddingInlineStart` is the left edge in LTR and the right edge in RTL.++On `Section` the matching `--container-padding-*` custom property moves with the prop, so bleed children (`Table`, `Divider`, a nested `Section`) keep compensating against the padding actually applied.++Existing code is unaffected: `padding`, `paddingInline` and `paddingBlock` behave exactly as before, and their generated class output is unchanged.++@imdreamrunnerdiff --git a/apps/storybook/stories/Center.stories.tsx b/apps/storybook/stories/Center.stories.tsxindex a64d42d384..b65bc5ccda 100644--- a/apps/storybook/stories/Center.stories.tsx+++ b/apps/storybook/stories/Center.stories.tsx@@ -89,11 +89,35 @@ const meta: Meta<typeof Center> = {description:'Inline (horizontal) padding; overrides padding on that axis',},+ paddingInlineStart: {+ control: 'select',+ options: [0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 8, 10],+ description:+ 'Inline-start (left in LTR) padding; overrides paddingInline/padding on that edge',+ },+ paddingInlineEnd: {+ control: 'select',+ options: [0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 8, 10],+ description:+ 'Inline-end (right in LTR) padding; overrides paddingInline/padding on that edge',+ },paddingBlock: {control: 'select',options: [0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 8, 10],description: 'Block (vertical) padding; overrides padding on that axis',},+ paddingBlockStart: {+ control: 'select',+ options: [0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 8, 10],+ description:+ 'Block-start (top) padding; overrides paddingBlock/padding on that edge',+ },+ paddingBlockEnd: {+ control: 'select',+ options: [0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 8, 10],+ description:+ 'Block-end (bottom) padding; overrides paddingBlock/padding on that edge',+ },},};@@ -240,6 +264,27 @@ export const Padding: Story = {),};+export const PaddingPerEdge: Story = {+ args: {+ axis: 'both',+ width: '100%',+ height: 200,+ padding: 6,+ paddingBlockEnd: 0,+ paddingInlineStart: 2,+ children: null,+ },+ render: args => (+ <Section variant="muted" width="100%">+ <Center {...args} xstyle={styles.paddingOutline}>+ <div {...stylex.props(styles.fillArea)}>+ <Box>Roomy above, flush below — only the block-end edge moved</Box>+ </div>+ </Center>+ </Section>+ ),+};+export const AllAxisModes: Story = {args: {children: null,diff --git a/apps/storybook/stories/Section.stories.tsx b/apps/storybook/stories/Section.stories.tsxindex 473ded8f78..400b2168e6 100644--- a/apps/storybook/stories/Section.stories.tsx+++ b/apps/storybook/stories/Section.stories.tsx@@ -189,8 +189,8 @@ export const PageLayout: Story = {<VStack gap={2}><h3 {...stylex.props(styles.text)}>Main Content</h3><p {...stylex.props(styles.text, styles.textSecondary)}>- This demonstrates how Layout can be used to create page- layouts with header, sidebar, and content areas.+ This demonstrates how Layout can be used to create page layouts+ with header, sidebar, and content areas.</p></VStack></LayoutContent>@@ -266,3 +266,83 @@ export const NestedPaddingInheritance: Story = {</div>),};++export const AsymmetricPadding: Story = {+ render: () => (+ <div {...stylex.props(styles.storyWrapper)}>+ <div>+ <h4 {...stylex.props(styles.heading)}>padding=6 (all edges 24px)</h4>+ <Section variant="muted" width={350} padding={6}>+ <p {...stylex.props(styles.text)}>+ The baseline: every edge takes the same spacing step.+ </p>+ </Section>+ </div>+ <div>+ <h4 {...stylex.props(styles.heading)}>+ padding=6 + paddingBlockStart=2 (tight above)+ </h4>+ <Section variant="muted" width={350} padding={6} paddingBlockStart={2}>+ <p {...stylex.props(styles.text)}>+ Only the top edge moves to 8px. Both inline edges and the bottom+ edge stay at 24px — the shape you want under a sticky header.+ </p>+ </Section>+ </div>+ <div>+ <h4 {...stylex.props(styles.heading)}>+ padding=6 + paddingBlockEnd=0 (flush bottom)+ </h4>+ <Section variant="muted" width={350} padding={6} paddingBlockEnd={0}>+ <p {...stylex.props(styles.text)}>+ The bottom edge goes to 0 so content can sit flush against a+ following section, with the inline inset preserved.+ </p>+ </Section>+ </div>+ <div>+ <h4 {...stylex.props(styles.heading)}>+ paddingBlock=6 + paddingBlockEnd=1 (edge beats axis)+ </h4>+ <Section+ variant="muted"+ width={350}+ paddingBlock={6}+ paddingBlockEnd={1}>+ <p {...stylex.props(styles.text)}>+ paddingBlockEnd wins over paddingBlock on its own edge: 24px top,+ 4px bottom, inline padding from the theme default.+ </p>+ </Section>+ </div>+ <div>+ <h4 {...stylex.props(styles.heading)}>+ padding=6 + paddingInlineStart=2 (tight leading edge)+ </h4>+ <Section variant="muted" width={350} padding={6} paddingInlineStart={2}>+ <p {...stylex.props(styles.text)}>+ Only the inline-start edge moves to 8px — the left edge in LTR, the+ right edge in RTL. The other three stay at 24px.+ </p>+ </Section>+ </div>+ <div>+ <h4 {...stylex.props(styles.heading)}>+ one prop per edge (1 / 2 / 3 / 4)+ </h4>+ <Section+ variant="muted"+ width={350}+ paddingInlineStart={1}+ paddingInlineEnd={2}+ paddingBlockStart={3}+ paddingBlockEnd={4}>+ <p {...stylex.props(styles.text)}>+ All four edges resolved independently: 4px leading, 8px trailing,+ 12px top, 16px bottom.+ </p>+ </Section>+ </div>+ </div>+ ),+};diff --git a/apps/storybook/stories/Stack.stories.tsx b/apps/storybook/stories/Stack.stories.tsxindex c42764e448..ba038cb7c6 100644--- a/apps/storybook/stories/Stack.stories.tsx+++ b/apps/storybook/stories/Stack.stories.tsx@@ -144,11 +144,35 @@ const meta: Meta<typeof Stack> = {description:'Inline (horizontal) padding; overrides padding on that axis',},+ paddingInlineStart: {+ control: 'select',+ options: [0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 8, 10],+ description:+ 'Inline-start (left in LTR) padding; overrides paddingInline/padding on that edge',+ },+ paddingInlineEnd: {+ control: 'select',+ options: [0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 8, 10],+ description:+ 'Inline-end (right in LTR) padding; overrides paddingInline/padding on that edge',+ },paddingBlock: {control: 'select',options: [0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 8, 10],description: 'Block (vertical) padding; overrides padding on that axis',},+ paddingBlockStart: {+ control: 'select',+ options: [0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 8, 10],+ description:+ 'Block-start (top) padding; overrides paddingBlock/padding on that edge',+ },+ paddingBlockEnd: {+ control: 'select',+ options: [0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 8, 10],+ description:+ 'Block-end (bottom) padding; overrides paddingBlock/padding on that edge',+ },isScrollable: {control: 'boolean',description: 'Enables scrollable overflow (overflow: auto)',@@ -702,6 +726,22 @@ export const PaddingPerAxis: Story = {),};+export const PaddingPerEdge: Story = {+ args: {+ gap: 2,+ padding: 6,+ paddingBlockStart: 1,+ paddingInlineEnd: 2,+ },+ render: args => (+ <Stack {...args} xstyle={styles.container}>+ <Box>Item 1</Box>+ <Box>Item 2</Box>+ <Box>Item 3</Box>+ </Stack>+ ),+};+// ============================================================================// Scrollable — overflow: auto via the isScrollable prop// ============================================================================diff --git a/packages/core/src/Center/Center.doc.mjs b/packages/core/src/Center/Center.doc.mjsindex 46a88c2616..3f8217f3a3 100644--- a/packages/core/src/Center/Center.doc.mjs+++ b/packages/core/src/Center/Center.doc.mjs@@ -48,12 +48,36 @@ export const docs = {description:'Inline (horizontal) padding, using the spacing scale. Overrides padding on the inline axis when both are set.',},+ {+ name: 'paddingInlineStart',+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',+ description:+ 'Inline-start padding, using the spacing scale (left in LTR, right in RTL). Overrides paddingInline and padding on that edge only.',+ },+ {+ name: 'paddingInlineEnd',+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',+ description:+ 'Inline-end padding, using the spacing scale (right in LTR, left in RTL). Overrides paddingInline and padding on that edge only.',+ },{name: 'paddingBlock',type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',description:'Block (vertical) padding, using the spacing scale. Overrides padding on the block axis when both are set.',},+ {+ name: 'paddingBlockStart',+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',+ description:+ 'Block-start (top) padding, using the spacing scale. Overrides paddingBlock and padding on that edge only.',+ },+ {+ name: 'paddingBlockEnd',+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',+ description:+ 'Block-end (bottom) padding, using the spacing scale. Overrides paddingBlock and padding on that edge only.',+ },{name: 'isInline',type: 'boolean',@@ -124,11 +148,31 @@ export const docsZh = {type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',description: '行内(水平)内边距,使用间距刻度。两者同时设置时在行内轴上覆盖 padding。',},+ {+ name: 'paddingInlineStart',+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',+ description: '行内起始内边距,使用间距刻度(LTR 中为左侧,RTL 中为右侧)。仅在该边上覆盖 paddingInline 和 padding。',+ },+ {+ name: 'paddingInlineEnd',+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',+ description: '行内结束内边距,使用间距刻度(LTR 中为右侧,RTL 中为左侧)。仅在该边上覆盖 paddingInline 和 padding。',+ },{name: 'paddingBlock',type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',description: '块(垂直)内边距,使用间距刻度。两者同时设置时在块轴上覆盖 padding。',},+ {+ name: 'paddingBlockStart',+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',+ description: '块起始(顶部)内边距,使用间距刻度。仅在该边上覆盖 paddingBlock 和 padding。',+ },+ {+ name: 'paddingBlockEnd',+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',+ description: '块结束(底部)内边距,使用间距刻度。仅在该边上覆盖 paddingBlock 和 padding。',+ },{name: 'isInline', type: 'boolean', description: '使用 inline-flex(适用于文本/图标)。', default: 'false'},{name: 'children', type: 'ReactNode', description: '要居中的内容。'},{@@ -171,7 +215,11 @@ export const docsDense = {padding:'inner padding on all sides (spacing step: 0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 8, 10)',paddingInline: 'inline (horizontal) padding; overrides padding on that axis',+ paddingInlineStart: 'inline-start padding (left in LTR); overrides paddingInline/padding on that edge',+ paddingInlineEnd: 'inline-end padding (right in LTR); overrides paddingInline/padding on that edge',paddingBlock: 'block (vertical) padding; overrides padding on that axis',+ paddingBlockStart: 'block-start (top) padding; overrides paddingBlock/padding on that edge',+ paddingBlockEnd: 'block-end (bottom) padding; overrides paddingBlock/padding on that edge',isInline: 'use inline-flex for text/icons',children: 'content to center',xstyle: 'StyleX styles for layout (margins, positioning, sizing); must be stylex.create() value',diff --git a/packages/core/src/Center/Center.test.tsx b/packages/core/src/Center/Center.test.tsxindex b95d84cbf1..a6a58ddee8 100644--- a/packages/core/src/Center/Center.test.tsx+++ b/packages/core/src/Center/Center.test.tsx@@ -13,6 +13,22 @@ import {describe, it, expect, vi} from 'vitest';import {render, screen} from '@testing-library/react';import {Center} from './Center';+/**+ * The functional class output, as an order-insensitive set. StyleX's dev+ * runtime also emits readable debug classes naming the style object a+ * declaration came from ("padding__paddingBlockStyles.2"); those record+ * provenance rather than applied CSS and survive even when the declaration+ * they name loses a merge, so they are dropped here.+ */+function classSet(el: HTMLElement): Set<string> {+ return new Set(+ el.className+ .split(' ')+ .filter(Boolean)+ .filter(c => !c.includes('__') && !c.includes('.')),+ );+}+describe('Center', () => {it('renders and centers children (both axes by default)', () => {render(@@ -207,4 +223,146 @@ describe('Center', () => {const element = screen.getByTestId('center');expect(element.tagName).toBe('DIV');});++ it('applies a class when paddingBlockStart is set on its own', () => {+ const {rerender} = render(+ <Center data-testid="center">+ <div>Content</div>+ </Center>,+ );+ const baseline = screen.getByTestId('center').className;+ rerender(+ <Center paddingBlockStart={2} data-testid="center">+ <div>Content</div>+ </Center>,+ );+ expect(screen.getByTestId('center').className).not.toBe(baseline);+ });++ it('lets paddingBlockStart/paddingBlockEnd override only their own edge', () => {+ // padding={4} + paddingBlockStart={2} must equal spelling every edge out:+ // both inline edges and the block-end edge stay at 4.+ const {rerender} = render(+ <Center padding={4} paddingBlockStart={2} data-testid="center">+ <div>Content</div>+ </Center>,+ );+ const perEdge = classSet(screen.getByTestId('center'));+ rerender(+ <Center+ paddingInline={4}+ paddingBlockStart={2}+ paddingBlockEnd={4}+ data-testid="center">+ <div>Content</div>+ </Center>,+ );+ expect(perEdge).toEqual(classSet(screen.getByTestId('center')));+ });++ it('gives paddingBlockEnd precedence over paddingBlock', () => {+ const {rerender} = render(+ <Center paddingBlock={6} paddingBlockEnd={0} data-testid="center">+ <div>Content</div>+ </Center>,+ );+ const overridden = classSet(screen.getByTestId('center'));+ rerender(+ <Center paddingBlockStart={6} paddingBlockEnd={0} data-testid="center">+ <div>Content</div>+ </Center>,+ );+ expect(overridden).toEqual(classSet(screen.getByTestId('center')));+ });++ it('leaves padding/paddingBlock output unchanged when no edge prop is set', () => {+ const {rerender} = render(+ <Center padding={3} data-testid="center">+ <div>Content</div>+ </Center>,+ );+ const uniform = classSet(screen.getByTestId('center'));+ rerender(+ <Center paddingInline={3} paddingBlock={3} data-testid="center">+ <div>Content</div>+ </Center>,+ );+ expect(uniform).toEqual(classSet(screen.getByTestId('center')));+ });++ it('applies a class when paddingInlineStart is set on its own', () => {+ const {rerender} = render(+ <Center data-testid="center">+ <div>Content</div>+ </Center>,+ );+ const baseline = screen.getByTestId('center').className;+ rerender(+ <Center paddingInlineStart={2} data-testid="center">+ <div>Content</div>+ </Center>,+ );+ expect(screen.getByTestId('center').className).not.toBe(baseline);+ });++ it('lets paddingInlineStart/paddingInlineEnd override only their own edge', () => {+ const {rerender} = render(+ <Center padding={4} paddingInlineStart={2} data-testid="center">+ <div>Content</div>+ </Center>,+ );+ const perEdge = classSet(screen.getByTestId('center'));+ rerender(+ <Center+ paddingInlineStart={2}+ paddingInlineEnd={4}+ paddingBlock={4}+ data-testid="center">+ <div>Content</div>+ </Center>,+ );+ expect(perEdge).toEqual(classSet(screen.getByTestId('center')));+ });++ it('gives paddingInlineEnd precedence over paddingInline', () => {+ const {rerender} = render(+ <Center paddingInline={6} paddingInlineEnd={0} data-testid="center">+ <div>Content</div>+ </Center>,+ );+ const overridden = classSet(screen.getByTestId('center'));+ rerender(+ <Center paddingInlineStart={6} paddingInlineEnd={0} data-testid="center">+ <div>Content</div>+ </Center>,+ );+ expect(overridden).toEqual(classSet(screen.getByTestId('center')));+ });++ it('resolves all four edges independently', () => {+ // One prop per edge, each a different step: the four-edge spelling and the+ // shorthand-plus-overrides spelling must agree.+ const {rerender} = render(+ <Center+ paddingInlineStart={1}+ paddingInlineEnd={2}+ paddingBlockStart={3}+ paddingBlockEnd={4}+ data-testid="center">+ <div>Content</div>+ </Center>,+ );+ const explicit = classSet(screen.getByTestId('center'));+ rerender(+ <Center+ padding={4}+ paddingInlineStart={1}+ paddingInlineEnd={2}+ paddingBlockStart={3}+ data-testid="center">+ <div>Content</div>+ </Center>,+ );+ expect(explicit).toEqual(classSet(screen.getByTestId('center')));+ });});diff --git a/packages/core/src/Center/Center.tsx b/packages/core/src/Center/Center.tsxindex 0061a9476a..69f26693a9 100644--- a/packages/core/src/Center/Center.tsx+++ b/packages/core/src/Center/Center.tsx@@ -18,8 +18,10 @@ import type {BaseProps} from '../BaseProps';import * as stylex from '@stylexjs/stylex';import type {SizeValue, SpacingStep} from '../utils/types';import {- paddingInlineStyles,- paddingBlockStyles,+ paddingInlineStartStyles,+ paddingInlineEndStyles,+ paddingBlockStartStyles,+ paddingBlockEndStyles,} from '../Layout/padding.stylex';import {mergeProps} from '../utils';import {themeProps} from '../utils/themeProps';@@ -106,12 +108,38 @@ export interface CenterProps extends BaseProps<HTMLDivElement> {*/paddingInline?: SpacingStep;+ /**+ * Inline-start padding, using the spacing scale. Logical: the left edge in+ * LTR, the right edge in RTL.+ * Overrides `paddingInline` and `padding` on that edge only.+ */+ paddingInlineStart?: SpacingStep;++ /**+ * Inline-end padding, using the spacing scale. Logical: the right edge in+ * LTR, the left edge in RTL.+ * Overrides `paddingInline` and `padding` on that edge only.+ */+ paddingInlineEnd?: SpacingStep;+/*** Block (vertical) padding, using the spacing scale.* Overrides `padding` on the block axis when both are set.*/paddingBlock?: SpacingStep;+ /**+ * Block-start (top) padding, using the spacing scale.+ * Overrides `paddingBlock` and `padding` on that edge only.+ */+ paddingBlockStart?: SpacingStep;++ /**+ * Block-end (bottom) padding, using the spacing scale.+ * Overrides `paddingBlock` and `padding` on that edge only.+ */+ paddingBlockEnd?: SpacingStep;+/*** Whether to make the container inline-flex (useful for text/icons).* @default false@@ -145,7 +173,11 @@ export function Center({minHeight,padding,paddingInline,+ paddingInlineStart,+ paddingInlineEnd,paddingBlock,+ paddingBlockStart,+ paddingBlockEnd,isInline = false,children,xstyle,@@ -154,10 +186,14 @@ export function Center({ref,...props}: CenterProps) {- // Resolve padding to per-axis values: `padding` sets both axes; `paddingInline`- // / `paddingBlock` take precedence on their own axis when provided.- const resolvedPaddingInline = paddingInline ?? padding;- const resolvedPaddingBlock = paddingBlock ?? padding;+ // Resolve padding to per-edge values. Most specific wins, per edge:+ // edge prop -> axis prop -> `padding`.+ const resolvedPaddingInlineStart =+ paddingInlineStart ?? paddingInline ?? padding;+ const resolvedPaddingInlineEnd = paddingInlineEnd ?? paddingInline ?? padding;+ const resolvedPaddingBlockStart =+ paddingBlockStart ?? paddingBlock ?? padding;+ const resolvedPaddingBlockEnd = paddingBlockEnd ?? paddingBlock ?? padding;const stylexProps = mergeProps(themeProps('center', {axis}),@@ -171,9 +207,14 @@ export function Center({maxWidth ?? null,minHeight ?? null,),- resolvedPaddingInline != null &&- paddingInlineStyles[resolvedPaddingInline],- resolvedPaddingBlock != null && paddingBlockStyles[resolvedPaddingBlock],+ resolvedPaddingInlineStart != null &&+ paddingInlineStartStyles[resolvedPaddingInlineStart],+ resolvedPaddingInlineEnd != null &&+ paddingInlineEndStyles[resolvedPaddingInlineEnd],+ resolvedPaddingBlockStart != null &&+ paddingBlockStartStyles[resolvedPaddingBlockStart],+ resolvedPaddingBlockEnd != null &&+ paddingBlockEndStyles[resolvedPaddingBlockEnd],xstyle,),className,diff --git a/packages/core/src/Layout/padding.stylex.ts b/packages/core/src/Layout/padding.stylex.tsindex 59e41b8957..35442e100d 100644--- a/packages/core/src/Layout/padding.stylex.ts+++ b/packages/core/src/Layout/padding.stylex.ts@@ -325,6 +325,120 @@ export const paddingBlockStyles = stylex.create({},});+/**+ * Inline-start-only padding override styles.+ * Use when a component needs to override the inline-start edge independently+ * of inline-end. Logical, so it follows the writing direction (left in LTR,+ * right in RTL).+ */+export const paddingInlineStartStyles = stylex.create({+ 0: {paddingInlineStart: spacingVars['--spacing-0']},+ 0.5: {paddingInlineStart: spacingVars['--spacing-0-5']},+ 1: {paddingInlineStart: spacingVars['--spacing-1']},+ 1.5: {paddingInlineStart: spacingVars['--spacing-1-5']},+ 2: {paddingInlineStart: spacingVars['--spacing-2']},+ 3: {paddingInlineStart: spacingVars['--spacing-3']},+ 4: {paddingInlineStart: spacingVars['--spacing-4']},+ 5: {paddingInlineStart: spacingVars['--spacing-5']},+ 6: {paddingInlineStart: spacingVars['--spacing-6']},+ 8: {paddingInlineStart: spacingVars['--spacing-8']},+ 10: {paddingInlineStart: spacingVars['--spacing-10']},+});++/**+ * Inline-end-only padding override styles.+ * The inline-end counterpart of paddingInlineStartStyles.+ */+export const paddingInlineEndStyles = stylex.create({+ 0: {paddingInlineEnd: spacingVars['--spacing-0']},+ 0.5: {paddingInlineEnd: spacingVars['--spacing-0-5']},+ 1: {paddingInlineEnd: spacingVars['--spacing-1']},+ 1.5: {paddingInlineEnd: spacingVars['--spacing-1-5']},+ 2: {paddingInlineEnd: spacingVars['--spacing-2']},+ 3: {paddingInlineEnd: spacingVars['--spacing-3']},+ 4: {paddingInlineEnd: spacingVars['--spacing-4']},+ 5: {paddingInlineEnd: spacingVars['--spacing-5']},+ 6: {paddingInlineEnd: spacingVars['--spacing-6']},+ 8: {paddingInlineEnd: spacingVars['--spacing-8']},+ 10: {paddingInlineEnd: spacingVars['--spacing-10']},+});++/**+ * Container padding inline-start CSS variable style, set independently of+ * inline-end so a per-edge override keeps edge-compensating children (Card,+ * Divider, a nested Section) compensating against the padding actually+ * applied on that edge.+ */+export const containerPaddingInlineStartVarStyles = stylex.create({+ 0: {'--container-padding-inline-start': spacingVars['--spacing-0']},+ 0.5: {'--container-padding-inline-start': spacingVars['--spacing-0-5']},+ 1: {'--container-padding-inline-start': spacingVars['--spacing-1']},+ 1.5: {'--container-padding-inline-start': spacingVars['--spacing-1-5']},+ 2: {'--container-padding-inline-start': spacingVars['--spacing-2']},+ 3: {'--container-padding-inline-start': spacingVars['--spacing-3']},+ 4: {'--container-padding-inline-start': spacingVars['--spacing-4']},+ 5: {'--container-padding-inline-start': spacingVars['--spacing-5']},+ 6: {'--container-padding-inline-start': spacingVars['--spacing-6']},+ 8: {'--container-padding-inline-start': spacingVars['--spacing-8']},+ 10: {'--container-padding-inline-start': spacingVars['--spacing-10']},+});++/**+ * Container padding inline-end CSS variable style, the counterpart of+ * containerPaddingInlineStartVarStyles.+ */+export const containerPaddingInlineEndVarStyles = stylex.create({+ 0: {'--container-padding-inline-end': spacingVars['--spacing-0']},+ 0.5: {'--container-padding-inline-end': spacingVars['--spacing-0-5']},+ 1: {'--container-padding-inline-end': spacingVars['--spacing-1']},+ 1.5: {'--container-padding-inline-end': spacingVars['--spacing-1-5']},+ 2: {'--container-padding-inline-end': spacingVars['--spacing-2']},+ 3: {'--container-padding-inline-end': spacingVars['--spacing-3']},+ 4: {'--container-padding-inline-end': spacingVars['--spacing-4']},+ 5: {'--container-padding-inline-end': spacingVars['--spacing-5']},+ 6: {'--container-padding-inline-end': spacingVars['--spacing-6']},+ 8: {'--container-padding-inline-end': spacingVars['--spacing-8']},+ 10: {'--container-padding-inline-end': spacingVars['--spacing-10']},+});++/**+ * Block-start-only padding override styles.+ * Use when a component needs to override the block-start (top) edge+ * independently of block-end — e.g. a section that sits under a sticky+ * header and needs less padding above than below.+ */+export const paddingBlockStartStyles = stylex.create({+ 0: {paddingBlockStart: spacingVars['--spacing-0']},+ 0.5: {paddingBlockStart: spacingVars['--spacing-0-5']},+ 1: {paddingBlockStart: spacingVars['--spacing-1']},+ 1.5: {paddingBlockStart: spacingVars['--spacing-1-5']},+ 2: {paddingBlockStart: spacingVars['--spacing-2']},+ 3: {paddingBlockStart: spacingVars['--spacing-3']},+ 4: {paddingBlockStart: spacingVars['--spacing-4']},+ 5: {paddingBlockStart: spacingVars['--spacing-5']},+ 6: {paddingBlockStart: spacingVars['--spacing-6']},+ 8: {paddingBlockStart: spacingVars['--spacing-8']},+ 10: {paddingBlockStart: spacingVars['--spacing-10']},+});++/**+ * Block-end-only padding override styles.+ * The block-end counterpart of paddingBlockStartStyles.+ */+export const paddingBlockEndStyles = stylex.create({+ 0: {paddingBlockEnd: spacingVars['--spacing-0']},+ 0.5: {paddingBlockEnd: spacingVars['--spacing-0-5']},+ 1: {paddingBlockEnd: spacingVars['--spacing-1']},+ 1.5: {paddingBlockEnd: spacingVars['--spacing-1-5']},+ 2: {paddingBlockEnd: spacingVars['--spacing-2']},+ 3: {paddingBlockEnd: spacingVars['--spacing-3']},+ 4: {paddingBlockEnd: spacingVars['--spacing-4']},+ 5: {paddingBlockEnd: spacingVars['--spacing-5']},+ 6: {paddingBlockEnd: spacingVars['--spacing-6']},+ 8: {paddingBlockEnd: spacingVars['--spacing-8']},+ 10: {paddingBlockEnd: spacingVars['--spacing-10']},+});+/*** Propagation styles for --astryx-section-padding.* When a parent section sets explicit padding, this propagates the valuediff --git a/packages/core/src/Section/Section.doc.mjs b/packages/core/src/Section/Section.doc.mjsindex 8c278433dc..260226d2c5 100644--- a/packages/core/src/Section/Section.doc.mjs+++ b/packages/core/src/Section/Section.doc.mjs@@ -53,11 +53,36 @@ export const docs = {description: 'Internal padding using the spacing scale (0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 8, 10). Use padding={0} for edge-to-edge content.',default: '4',},+ {+ name: 'paddingInline',+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',+ description: 'Inline (horizontal) padding override. Overrides only the inline-axis padding while preserving block padding from `padding` or the container theme default. Accepts the spacing scale (0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 8, 10).',+ },+ {+ name: 'paddingInlineStart',+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',+ description: 'Inline-start padding override (left in LTR, right in RTL). Overrides paddingInline and padding on that edge only.',+ },+ {+ name: 'paddingInlineEnd',+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',+ description: 'Inline-end padding override (right in LTR, left in RTL). Overrides paddingInline and padding on that edge only.',+ },{name: 'paddingBlock',type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',description: 'Block (vertical) padding override. Overrides only the block-axis padding while preserving inline padding from `padding` or the container theme default. Accepts the spacing scale (0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 8, 10).',},+ {+ name: 'paddingBlockStart',+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',+ description: 'Block-start (top) padding, using the spacing scale. Overrides paddingBlock and padding on that edge only.',+ },+ {+ name: 'paddingBlockEnd',+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',+ description: 'Block-end (bottom) padding, using the spacing scale. Overrides paddingBlock and padding on that edge only.',+ },{name: 'xstyle',type: 'StyleXStyles',@@ -135,11 +160,36 @@ export const docsZh = {description: '使用间距比例的内部内边距(0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 8, 10)。使用 padding={0} 实现全宽内容。',default: '4',},+ {+ name: 'paddingInline',+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',+ description: '行内(水平)方向内边距覆盖。仅覆盖行内轴内边距,同时保留来自 padding 或容器主题默认值的块内边距。使用间距比例(0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 8, 10)。',+ },+ {+ name: 'paddingInlineStart',+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',+ description: '行内起始内边距覆盖(LTR 中为左侧,RTL 中为右侧)。仅在该边上覆盖 paddingInline 和 padding。',+ },+ {+ name: 'paddingInlineEnd',+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',+ description: '行内结束内边距覆盖(LTR 中为右侧,RTL 中为左侧)。仅在该边上覆盖 paddingInline 和 padding。',+ },{name: 'paddingBlock',type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',description: '块(垂直)方向内边距覆盖。仅覆盖块轴内边距,同时保留来自 padding 或容器主题默认值的行内内边距。使用间距比例(0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 8, 10)。',},+ {+ name: 'paddingBlockStart',+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',+ description: '块起始(顶部)内边距,使用间距刻度。仅在该边上覆盖 paddingBlock 和 padding。',+ },+ {+ name: 'paddingBlockEnd',+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',+ description: '块结束(底部)内边距,使用间距刻度。仅在该边上覆盖 paddingBlock 和 padding。',+ },{name: 'xstyle',type: 'StyleXStyles',@@ -192,7 +242,12 @@ export const docsDense = {children: 'Content rendered inside section.',dividers: 'Which sides of section have divider borders.',padding: 'Internal padding via spacing scale; 0 for edge-to-edge content.',+ paddingInline: 'Inline-axis padding override; preserves block padding from padding/theme.',+ paddingInlineStart: 'Inline-start (left in LTR) padding override; wins over paddingInline/padding on that edge.',+ paddingInlineEnd: 'Inline-end (right in LTR) padding override; wins over paddingInline/padding on that edge.',paddingBlock: 'Block-axis padding override; preserves inline padding from padding/theme.',+ paddingBlockStart: 'Block-start (top) padding override; wins over paddingBlock/padding on that edge.',+ paddingBlockEnd: 'Block-end (bottom) padding override; wins over paddingBlock/padding on that edge.',xstyle: 'StyleX styles for layout customization; must be stylex.create() value.',},};diff --git a/packages/core/src/Section/Section.test.tsx b/packages/core/src/Section/Section.test.tsxindex 4058abf062..24e8534a13 100644--- a/packages/core/src/Section/Section.test.tsx+++ b/packages/core/src/Section/Section.test.tsx@@ -4,6 +4,22 @@ import {describe, it, expect} from 'vitest';import {render, screen} from '@testing-library/react';import {Section} from './Section';+/**+ * The functional class output, as an order-insensitive set. StyleX's dev+ * runtime also emits readable debug classes naming the style object a+ * declaration came from ("padding__paddingBlockStyles.2"); those record+ * provenance rather than applied CSS and survive even when the declaration+ * they name loses a merge, so they are dropped here.+ */+function classSet(el: HTMLElement): Set<string> {+ return new Set(+ el.className+ .split(' ')+ .filter(Boolean)+ .filter(c => !c.includes('__') && !c.includes('.')),+ );+}+describe('Section', () => {it('renders with default props', () => {const {container} = render(<Section>Default section</Section>);@@ -176,4 +192,173 @@ describe('Section', () => {expect(screen.getByTestId('inner')).toBeInTheDocument();expect(screen.getByText('Inner')).toBeInTheDocument();});++ it('applies a class when paddingBlockStart is set on its own', () => {+ const {container, rerender} = render(<Section>Content</Section>);+ const baseline = (+ container.firstElementChild!.firstElementChild as HTMLElement+ ).className;+ rerender(<Section paddingBlockStart={2}>Content</Section>);+ const withEdge = (+ container.firstElementChild!.firstElementChild as HTMLElement+ ).className;+ expect(withEdge).not.toBe(baseline);+ });++ it('treats paddingBlock as the two edge props set to the same step', () => {+ const {container, rerender} = render(+ <Section paddingBlock={2}>Content</Section>,+ );+ const axis = classSet(+ container.firstElementChild!.firstElementChild as HTMLElement,+ );+ rerender(+ <Section paddingBlockStart={2} paddingBlockEnd={2}>+ Content+ </Section>,+ );+ expect(axis).toEqual(+ classSet(container.firstElementChild!.firstElementChild as HTMLElement),+ );+ });++ it('gives paddingBlockEnd precedence over paddingBlock', () => {+ const {container, rerender} = render(+ <Section paddingBlock={2} paddingBlockEnd={8}>+ Content+ </Section>,+ );+ const overridden = classSet(+ container.firstElementChild!.firstElementChild as HTMLElement,+ );+ rerender(+ <Section paddingBlockStart={2} paddingBlockEnd={8}>+ Content+ </Section>,+ );+ expect(overridden).toEqual(+ classSet(container.firstElementChild!.firstElementChild as HTMLElement),+ );+ });++ it('keeps inline padding when only a block edge is overridden', () => {+ // padding={6} sets all four edges; paddingBlockStart={0} may only move the+ // top edge, so the inline classes must survive unchanged.+ const {container, rerender} = render(+ <Section padding={6}>Content</Section>,+ );+ const uniform = classSet(+ container.firstElementChild!.firstElementChild as HTMLElement,+ );+ rerender(+ <Section padding={6} paddingBlockStart={0}>+ Content+ </Section>,+ );+ const overridden = classSet(+ container.firstElementChild!.firstElementChild as HTMLElement,+ );+ // Everything the uniform render dropped is block-start related.+ const removed = [...uniform].filter(c => !overridden.has(c));+ const added = [...overridden].filter(c => !uniform.has(c));+ expect(removed.length).toBeGreaterThan(0);+ expect(added.length).toBeGreaterThan(0);+ // The inline-axis classes are shared by both renders.+ expect(uniform.size - removed.length).toBeGreaterThan(0);+ });++ it('applies a class when paddingInlineStart is set on its own', () => {+ const {container, rerender} = render(<Section>Content</Section>);+ const baseline = (+ container.firstElementChild!.firstElementChild as HTMLElement+ ).className;+ rerender(<Section paddingInlineStart={2}>Content</Section>);+ expect(+ (container.firstElementChild!.firstElementChild as HTMLElement).className,+ ).not.toBe(baseline);+ });++ it('treats paddingInline as the two inline edge props set to the same step', () => {+ const {container, rerender} = render(+ <Section paddingInline={2}>Content</Section>,+ );+ const axis = classSet(+ container.firstElementChild!.firstElementChild as HTMLElement,+ );+ rerender(+ <Section paddingInlineStart={2} paddingInlineEnd={2}>+ Content+ </Section>,+ );+ expect(axis).toEqual(+ classSet(container.firstElementChild!.firstElementChild as HTMLElement),+ );+ });++ it('gives paddingInlineEnd precedence over paddingInline', () => {+ const {container, rerender} = render(+ <Section paddingInline={2} paddingInlineEnd={8}>+ Content+ </Section>,+ );+ const overridden = classSet(+ container.firstElementChild!.firstElementChild as HTMLElement,+ );+ rerender(+ <Section paddingInlineStart={2} paddingInlineEnd={8}>+ Content+ </Section>,+ );+ expect(overridden).toEqual(+ classSet(container.firstElementChild!.firstElementChild as HTMLElement),+ );+ });++ it('keeps block padding when only an inline edge is overridden', () => {+ const {container, rerender} = render(+ <Section padding={6}>Content</Section>,+ );+ const uniform = classSet(+ container.firstElementChild!.firstElementChild as HTMLElement,+ );+ rerender(+ <Section padding={6} paddingInlineStart={0}>+ Content+ </Section>,+ );+ const overridden = classSet(+ container.firstElementChild!.firstElementChild as HTMLElement,+ );+ const removed = [...uniform].filter(c => !overridden.has(c));+ const added = [...overridden].filter(c => !uniform.has(c));+ expect(removed.length).toBeGreaterThan(0);+ expect(added.length).toBeGreaterThan(0);+ // The block-axis classes survive the inline-edge override.+ expect(uniform.size - removed.length).toBeGreaterThan(0);+ });++ it('moves the inline container vars with a per-edge override', () => {+ // Section drives --container-padding-inline-start/end for bleed children.+ // A per-edge override must move only the matching var, so a nested Section+ // or a bleeding Divider compensates against the real padding.+ const {container, rerender} = render(+ <Section padding={6} paddingInlineStart={2}>+ Content+ </Section>,+ );+ const startOverride = classSet(+ container.firstElementChild!.firstElementChild as HTMLElement,+ );+ rerender(+ <Section padding={6} paddingInlineEnd={2}>+ Content+ </Section>,+ );+ const endOverride = classSet(+ container.firstElementChild!.firstElementChild as HTMLElement,+ );+ // Overriding opposite edges by the same step must not produce identical+ // output — each edge carries its own padding class and its own var class.+ expect(startOverride).not.toEqual(endOverride);+ });});diff --git a/packages/core/src/Section/Section.tsx b/packages/core/src/Section/Section.tsxindex 3cc3b19197..65d38e5931 100644--- a/packages/core/src/Section/Section.tsx+++ b/packages/core/src/Section/Section.tsx@@ -21,8 +21,15 @@ import {container} from '../Layout/container.stylex';import type {SpacingToken} from '../Layout/container.stylex';import {paddingStyles,+ paddingInlineStyles,+ paddingInlineStartStyles,+ paddingInlineEndStyles,paddingBlockStyles,+ paddingBlockStartStyles,+ paddingBlockEndStyles,containerPaddingInlineVarStyles,+ containerPaddingInlineStartVarStyles,+ containerPaddingInlineEndVarStyles,containerPaddingBlockStartVarStyles,containerPaddingBlockEndVarStyles,sectionPaddingPropagationStyles,@@ -175,6 +182,27 @@ export interface SectionProps extends BaseProps<HTMLElement> {* @default 4 (16px)*/padding?: SpacingStep;+ /**+ * Inline (horizontal) padding override. When set, overrides only the inline+ * axis padding while preserving block padding from `padding` or the+ * container theme default.+ * Accepts numeric spacing steps: 0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 8, 10.+ */+ paddingInline?: SpacingStep;+ /**+ * Inline-start padding override. Logical: the left edge in LTR, the right+ * edge in RTL. Takes precedence over `paddingInline` and `padding` on that+ * edge only; every other edge is left alone.+ * Accepts numeric spacing steps: 0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 8, 10.+ */+ paddingInlineStart?: SpacingStep;+ /**+ * Inline-end padding override. Logical: the right edge in LTR, the left+ * edge in RTL. Takes precedence over `paddingInline` and `padding` on that+ * edge only; every other edge is left alone.+ * Accepts numeric spacing steps: 0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 8, 10.+ */+ paddingInlineEnd?: SpacingStep;/*** Block (vertical) padding override. When set, overrides only the block* axis padding while preserving inline padding from `padding` or the@@ -182,6 +210,20 @@ export interface SectionProps extends BaseProps<HTMLElement> {* Accepts numeric spacing steps: 0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 8, 10.*/paddingBlock?: SpacingStep;+ /**+ * Block-start (top) padding override. Takes precedence over `paddingBlock`+ * and `padding` on that edge only; the block-end edge and both inline edges+ * are left alone.+ * Accepts numeric spacing steps: 0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 8, 10.+ */+ paddingBlockStart?: SpacingStep;+ /**+ * Block-end (bottom) padding override. Takes precedence over `paddingBlock`+ * and `padding` on that edge only; the block-start edge and both inline+ * edges are left alone.+ * Accepts numeric spacing steps: 0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 8, 10.+ */+ paddingBlockEnd?: SpacingStep;}/**@@ -211,7 +253,12 @@ export function Section({children,dividers,padding,+ paddingInline,+ paddingInlineStart,+ paddingInlineEnd,paddingBlock,+ paddingBlockStart,+ paddingBlockEnd,xstyle,className,style,@@ -275,11 +322,33 @@ export function Section({containerPaddingBlockEndVarStyles[effectivePadding],!useThemeDefault &§ionPaddingPropagationStyles[effectivePadding],+ paddingInline != null && paddingInlineStyles[paddingInline],+ paddingInline != null &&+ containerPaddingInlineVarStyles[paddingInline],paddingBlock != null && paddingBlockStyles[paddingBlock],paddingBlock != null &&containerPaddingBlockStartVarStyles[paddingBlock],paddingBlock != null &&containerPaddingBlockEndVarStyles[paddingBlock],+ // Per-edge overrides come last so they win over `paddingBlock`+ // and `padding` on their own edge. The matching container var is+ // updated alongside so bleed children (Table, Divider, nested+ // Section) compensate against the padding actually applied.+ paddingBlockStart != null &&+ paddingBlockStartStyles[paddingBlockStart],+ paddingBlockStart != null &&+ containerPaddingBlockStartVarStyles[paddingBlockStart],+ paddingBlockEnd != null && paddingBlockEndStyles[paddingBlockEnd],+ paddingBlockEnd != null &&+ containerPaddingBlockEndVarStyles[paddingBlockEnd],+ paddingInlineStart != null &&+ paddingInlineStartStyles[paddingInlineStart],+ paddingInlineStart != null &&+ containerPaddingInlineStartVarStyles[paddingInlineStart],+ paddingInlineEnd != null &&+ paddingInlineEndStyles[paddingInlineEnd],+ paddingInlineEnd != null &&+ containerPaddingInlineEndVarStyles[paddingInlineEnd],variantStyles[variant],dividers?.includes('top') && dividerStyles.top,dividers?.includes('bottom') && dividerStyles.bottom,diff --git a/packages/core/src/Stack/Stack.doc.mjs b/packages/core/src/Stack/Stack.doc.mjsindex 6f168cbd98..bd140d60b7 100644--- a/packages/core/src/Stack/Stack.doc.mjs+++ b/packages/core/src/Stack/Stack.doc.mjs@@ -46,12 +46,36 @@ export const docs = {description:'Inline (horizontal) padding. Overrides padding on the inline axis when both are set.',},+ {+ name: 'paddingInlineStart',+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',+ description:+ 'Inline-start padding, using the spacing scale (left in LTR, right in RTL). Overrides paddingInline and padding on that edge only.',+ },+ {+ name: 'paddingInlineEnd',+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',+ description:+ 'Inline-end padding, using the spacing scale (right in LTR, left in RTL). Overrides paddingInline and padding on that edge only.',+ },{name: 'paddingBlock',type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',description:'Block (vertical) padding. Overrides padding on the block axis when both are set.',},+ {+ name: 'paddingBlockStart',+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',+ description:+ 'Block-start (top) padding, using the spacing scale. Overrides paddingBlock and padding on that edge only.',+ },+ {+ name: 'paddingBlockEnd',+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',+ description:+ 'Block-end (bottom) padding, using the spacing scale. Overrides paddingBlock and padding on that edge only.',+ },{name: 'isScrollable',type: 'boolean',@@ -150,12 +174,36 @@ export const docs = {description:'Inline (horizontal) padding, using the spacing scale. Overrides padding on the inline axis when both are set.',},+ {+ name: 'paddingInlineStart',+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',+ description:+ 'Inline-start padding, using the spacing scale (left in LTR, right in RTL). Overrides paddingInline and padding on that edge only.',+ },+ {+ name: 'paddingInlineEnd',+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',+ description:+ 'Inline-end padding, using the spacing scale (right in LTR, left in RTL). Overrides paddingInline and padding on that edge only.',+ },{name: 'paddingBlock',type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',description:'Block (vertical) padding, using the spacing scale. Overrides padding on the block axis when both are set.',},+ {+ name: 'paddingBlockStart',+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',+ description:+ 'Block-start (top) padding, using the spacing scale. Overrides paddingBlock and padding on that edge only.',+ },+ {+ name: 'paddingBlockEnd',+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',+ description:+ 'Block-end (bottom) padding, using the spacing scale. Overrides paddingBlock and padding on that edge only.',+ },{name: 'isScrollable',type: 'boolean',@@ -253,12 +301,36 @@ export const docs = {description:'Inline (horizontal) padding, using the spacing scale. Overrides padding on the inline axis when both are set.',},+ {+ name: 'paddingInlineStart',+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',+ description:+ 'Inline-start padding, using the spacing scale (left in LTR, right in RTL). Overrides paddingInline and padding on that edge only.',+ },+ {+ name: 'paddingInlineEnd',+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',+ description:+ 'Inline-end padding, using the spacing scale (right in LTR, left in RTL). Overrides paddingInline and padding on that edge only.',+ },{name: 'paddingBlock',type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',description:'Block (vertical) padding, using the spacing scale. Overrides padding on the block axis when both are set.',},+ {+ name: 'paddingBlockStart',+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',+ description:+ 'Block-start (top) padding, using the spacing scale. Overrides paddingBlock and padding on that edge only.',+ },+ {+ name: 'paddingBlockEnd',+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',+ description:+ 'Block-end (bottom) padding, using the spacing scale. Overrides paddingBlock and padding on that edge only.',+ },{name: 'isScrollable',type: 'boolean',diff --git a/packages/core/src/Stack/Stack.test.tsx b/packages/core/src/Stack/Stack.test.tsxindex 4cc13b955e..4f49ce65b8 100644--- a/packages/core/src/Stack/Stack.test.tsx+++ b/packages/core/src/Stack/Stack.test.tsx@@ -13,6 +13,22 @@ import {describe, it, expect, vi} from 'vitest';import {render, screen} from '@testing-library/react';import {Stack} from './Stack';+/**+ * The functional class output, as an order-insensitive set. StyleX's dev+ * runtime also emits readable debug classes naming the style object a+ * declaration came from ("padding__paddingBlockStyles.2"); those record+ * provenance rather than applied CSS and survive even when the declaration+ * they name loses a merge, so they are dropped here.+ */+function classSet(el: HTMLElement): Set<string> {+ return new Set(+ el.className+ .split(' ')+ .filter(Boolean)+ .filter(c => !c.includes('__') && !c.includes('.')),+ );+}+describe('Stack', () => {it('defaults to vertical direction', () => {render(@@ -314,4 +330,144 @@ describe('Stack', () => {const withScroll = screen.getByTestId('stack').className;expect(withScroll).not.toBe(withoutScroll);});++ it('applies a class when paddingBlockStart is set on its own', () => {+ const {rerender} = render(+ <Stack data-testid="stack">+ <div>Content</div>+ </Stack>,+ );+ const baseline = screen.getByTestId('stack').className;+ rerender(+ <Stack paddingBlockStart={2} data-testid="stack">+ <div>Content</div>+ </Stack>,+ );+ expect(screen.getByTestId('stack').className).not.toBe(baseline);+ });++ it('lets paddingBlockStart/paddingBlockEnd override only their own edge', () => {+ const {rerender} = render(+ <Stack padding={4} paddingBlockStart={2} data-testid="stack">+ <div>Content</div>+ </Stack>,+ );+ const perEdge = classSet(screen.getByTestId('stack'));+ rerender(+ <Stack+ paddingInline={4}+ paddingBlockStart={2}+ paddingBlockEnd={4}+ data-testid="stack">+ <div>Content</div>+ </Stack>,+ );+ expect(perEdge).toEqual(classSet(screen.getByTestId('stack')));+ });++ it('gives paddingBlockEnd precedence over paddingBlock', () => {+ const {rerender} = render(+ <Stack paddingBlock={6} paddingBlockEnd={0} data-testid="stack">+ <div>Content</div>+ </Stack>,+ );+ const overridden = classSet(screen.getByTestId('stack'));+ rerender(+ <Stack paddingBlockStart={6} paddingBlockEnd={0} data-testid="stack">+ <div>Content</div>+ </Stack>,+ );+ expect(overridden).toEqual(classSet(screen.getByTestId('stack')));+ });++ it('leaves padding/paddingBlock output unchanged when no edge prop is set', () => {+ const {rerender} = render(+ <Stack padding={3} data-testid="stack">+ <div>Content</div>+ </Stack>,+ );+ const uniform = classSet(screen.getByTestId('stack'));+ rerender(+ <Stack paddingInline={3} paddingBlock={3} data-testid="stack">+ <div>Content</div>+ </Stack>,+ );+ expect(uniform).toEqual(classSet(screen.getByTestId('stack')));+ });++ it('applies a class when paddingInlineStart is set on its own', () => {+ const {rerender} = render(+ <Stack data-testid="stack">+ <div>Content</div>+ </Stack>,+ );+ const baseline = screen.getByTestId('stack').className;+ rerender(+ <Stack paddingInlineStart={2} data-testid="stack">+ <div>Content</div>+ </Stack>,+ );+ expect(screen.getByTestId('stack').className).not.toBe(baseline);+ });++ it('lets paddingInlineStart/paddingInlineEnd override only their own edge', () => {+ const {rerender} = render(+ <Stack padding={4} paddingInlineStart={2} data-testid="stack">+ <div>Content</div>+ </Stack>,+ );+ const perEdge = classSet(screen.getByTestId('stack'));+ rerender(+ <Stack+ paddingInlineStart={2}+ paddingInlineEnd={4}+ paddingBlock={4}+ data-testid="stack">+ <div>Content</div>+ </Stack>,+ );+ expect(perEdge).toEqual(classSet(screen.getByTestId('stack')));+ });++ it('gives paddingInlineEnd precedence over paddingInline', () => {+ const {rerender} = render(+ <Stack paddingInline={6} paddingInlineEnd={0} data-testid="stack">+ <div>Content</div>+ </Stack>,+ );+ const overridden = classSet(screen.getByTestId('stack'));+ rerender(+ <Stack paddingInlineStart={6} paddingInlineEnd={0} data-testid="stack">+ <div>Content</div>+ </Stack>,+ );+ expect(overridden).toEqual(classSet(screen.getByTestId('stack')));+ });++ it('resolves all four edges independently', () => {+ // One prop per edge, each a different step: the four-edge spelling and the+ // shorthand-plus-overrides spelling must agree.+ const {rerender} = render(+ <Stack+ paddingInlineStart={1}+ paddingInlineEnd={2}+ paddingBlockStart={3}+ paddingBlockEnd={4}+ data-testid="stack">+ <div>Content</div>+ </Stack>,+ );+ const explicit = classSet(screen.getByTestId('stack'));+ rerender(+ <Stack+ padding={4}+ paddingInlineStart={1}+ paddingInlineEnd={2}+ paddingBlockStart={3}+ data-testid="stack">+ <div>Content</div>+ </Stack>,+ );+ expect(explicit).toEqual(classSet(screen.getByTestId('stack')));+ });});diff --git a/packages/core/src/Stack/Stack.tsx b/packages/core/src/Stack/Stack.tsxindex f9a85bdcea..553666039c 100644--- a/packages/core/src/Stack/Stack.tsx+++ b/packages/core/src/Stack/Stack.tsx@@ -25,8 +25,10 @@ import {} from './stack.stylex';import type {SizeValue} from '../utils/types';import {- paddingInlineStyles,- paddingBlockStyles,+ paddingInlineStartStyles,+ paddingInlineEndStyles,+ paddingBlockStartStyles,+ paddingBlockEndStyles,} from '../Layout/padding.stylex';import {mergeProps} from '../utils';import {themeProps} from '../utils/themeProps';@@ -140,12 +142,38 @@ export interface StackProps extends BaseProps<HTMLElement> {*/paddingInline?: SpacingStep;+ /**+ * Inline-start padding, using the spacing scale. Logical: the left edge in+ * LTR, the right edge in RTL.+ * Overrides `paddingInline` and `padding` on that edge only.+ */+ paddingInlineStart?: SpacingStep;++ /**+ * Inline-end padding, using the spacing scale. Logical: the right edge in+ * LTR, the left edge in RTL.+ * Overrides `paddingInline` and `padding` on that edge only.+ */+ paddingInlineEnd?: SpacingStep;+/*** Block (vertical) padding, using the spacing scale.* Overrides `padding` on the block axis when both are set.*/paddingBlock?: SpacingStep;+ /**+ * Block-start (top) padding, using the spacing scale.+ * Overrides `paddingBlock` and `padding` on that edge only.+ */+ paddingBlockStart?: SpacingStep;++ /**+ * Block-end (bottom) padding, using the spacing scale.+ * Overrides `paddingBlock` and `padding` on that edge only.+ */+ paddingBlockEnd?: SpacingStep;+/*** Enables scrollable overflow (`overflow: auto`) for the stack.*@@ -211,7 +239,11 @@ export function Stack({gap,padding,paddingInline,+ paddingInlineStart,+ paddingInlineEnd,paddingBlock,+ paddingBlockStart,+ paddingBlockEnd,isScrollable,width,height,@@ -242,10 +274,14 @@ export function Stack({? (resolvedVAlign as StackCrossAlignment | undefined): (resolvedHAlign as StackCrossAlignment | undefined);- // Resolve padding to per-axis values: `padding` sets both axes; `paddingInline`- // / `paddingBlock` take precedence on their own axis when provided.- const resolvedPaddingInline = paddingInline ?? padding;- const resolvedPaddingBlock = paddingBlock ?? padding;+ // Resolve padding to per-edge values. Most specific wins, per edge:+ // edge prop -> axis prop -> `padding`.+ const resolvedPaddingInlineStart =+ paddingInlineStart ?? paddingInline ?? padding;+ const resolvedPaddingInlineEnd = paddingInlineEnd ?? paddingInline ?? padding;+ const resolvedPaddingBlockStart =+ paddingBlockStart ?? paddingBlock ?? padding;+ const resolvedPaddingBlockEnd = paddingBlockEnd ?? paddingBlock ?? padding;const stylexProps = stylex.props(...stack({@@ -255,8 +291,14 @@ export function Stack({gap,wrap,}),- resolvedPaddingInline != null && paddingInlineStyles[resolvedPaddingInline],- resolvedPaddingBlock != null && paddingBlockStyles[resolvedPaddingBlock],+ resolvedPaddingInlineStart != null &&+ paddingInlineStartStyles[resolvedPaddingInlineStart],+ resolvedPaddingInlineEnd != null &&+ paddingInlineEndStyles[resolvedPaddingInlineEnd],+ resolvedPaddingBlockStart != null &&+ paddingBlockStartStyles[resolvedPaddingBlockStart],+ resolvedPaddingBlockEnd != null &&+ paddingBlockEndStyles[resolvedPaddingBlockEnd],isScrollable && overflowStyles.scrollable,xstyle,);