Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

feat(core): BottomSheet publishes container padding, like Dialog (#6883)

Xinzi Zhou031021b81088
diff --git a/.changeset/bottom-sheet-container-padding.md b/.changeset/bottom-sheet-container-padding.md
new file mode 100644
index 0000000000..4b26a59eb9
--- /dev/null
+++ b/.changeset/bottom-sheet-container-padding.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[feat] BottomSheet is a container, like Dialog. A new `padding` prop takes a spacing step, and a theme's `padding` on `bottom-sheet` now pads the sheet's content box through container tokens instead of padding the panel. The padded content box publishes its inset, so a Section that is the sheet's only child, and bleed children such as Table and Divider, align against it. With neither set, the content box stays unpadded as before.
+
+@imdreamrunner
diff --git a/apps/storybook/stories/BottomSheet.stories.tsx b/apps/storybook/stories/BottomSheet.stories.tsx
index 9245f75f14..af6319b2a0 100644
--- a/apps/storybook/stories/BottomSheet.stories.tsx
+++ b/apps/storybook/stories/BottomSheet.stories.tsx
@@ -120,6 +120,45 @@ export const TextOnlyFitting: Story = {
},
};
+/**
+ * Content placed directly in a sheet with `padding`. The sheet pads it like
+ * Dialog, and a full-bleed Divider reaches the sheet's edges because the
+ * content box publishes its inset. Without `padding` (or a theme's
+ * bottom-sheet padding) the content box stays unpadded.
+ */
+export const ContainerPadding: Story = {
+ args: {
+ isOpen: true,
+ label: 'Order summary',
+ height: 'hug',
+ padding: 4,
+ children: (
+ <VStack gap={4}>
+ <Heading level={2}>Order summary</Heading>
+ <Text>
+ This content has no wrapper of its own. The sheet supplies the inset,
+ exactly as Dialog does.
+ </Text>
+ <Divider isFullBleed />
+ <Text color="secondary">
+ The divider above escapes the inset and spans the sheet.
+ </Text>
+ </VStack>
+ ),
+ },
+ render: args => {
+ const standaloneArgs = args as StandaloneBottomSheetStoryProps;
+ const [isOpen, setIsOpen] = useState(true);
+ return (
+ <BottomSheet
+ {...standaloneArgs}
+ isOpen={isOpen}
+ onOpenChange={setIsOpen}
+ />
+ );
+ },
+};
+
interface CommentFormValues {
title: string;
author: string;
diff --git a/docs/pr-assets/6883/container-padding-390.png b/docs/pr-assets/6883/container-padding-390.png
new file mode 100644
index 0000000000..dec81ec395
Binary files /dev/null and b/docs/pr-assets/6883/container-padding-390.png differ
diff --git a/packages/cli/assets/docs/theme.doc.mjs b/packages/cli/assets/docs/theme.doc.mjs
index c9b8a769d2..e2c84b9eaa 100644
--- a/packages/cli/assets/docs/theme.doc.mjs
+++ b/packages/cli/assets/docs/theme.doc.mjs
@@ -400,7 +400,7 @@ const brandTheme = defineTheme({
code: `components: {
// Standard CSS properties are expanded automatically.
// borderRadius also sets the internal radius var for concentric math.
- // padding on container components (card, section, dialog) expands to layout tokens.
+ // padding on container components (card, section, dialog, bottom-sheet) expands to layout tokens.
card: {
base: { borderRadius: '20px', padding: '24px' },
},
diff --git a/packages/core/src/BottomSheet/BottomSheet.doc.mjs b/packages/core/src/BottomSheet/BottomSheet.doc.mjs
index 7aa3f82197..1d193a1f28 100644
--- a/packages/core/src/BottomSheet/BottomSheet.doc.mjs
+++ b/packages/core/src/BottomSheet/BottomSheet.doc.mjs
@@ -19,7 +19,7 @@ const anatomy = [
name: 'Content area',
required: true,
description:
- 'Scrollable area that presents the caller-provided sheet content.',
+ 'Scrollable container that presents the caller-provided sheet content, padded when padding or a theme sets it.',
},
{
name: 'Handle',
@@ -90,10 +90,12 @@ export const docs = {
},
},
theming: {
+ container: true,
targets: [{className: 'astryx-bottom-sheet', visualProps: []}],
+ derived: [{property: 'padding', expand: 'container'}],
},
description:
- "A mobile touch sheet that rises from the bottom edge, with animated entrance and exit, a grab handle, optional drag-to-resize snap points, and purpose-controlled dismissal. A standalone sheet owns a native <dialog>; inside BottomSheetSwitcher it renders a panel in the switcher's shared dialog. In both modes, ref and shared DOM props target the visual panel <div>.",
+ "A mobile touch sheet that rises from the bottom edge, with animated entrance and exit, a grab handle, optional drag-to-resize snap points, and purpose-controlled dismissal. Like Dialog, it is a container: set padding (or a theme's bottom-sheet padding) and a lone Section child or bleed children such as Table and Divider align against that inset. By default the content area has no padding. A standalone sheet owns a native <dialog>; inside BottomSheetSwitcher it renders a panel in the switcher's shared dialog. In both modes, ref and shared DOM props target the visual panel <div>.",
props: [
{
name: 'isOpen',
@@ -140,6 +142,12 @@ export const docs = {
"Sheet content in a scrollable area. The named body is keyboard reachable while overflowing. Forward Tab entry may move directly to the first native link or button; input controls, composite widgets, and nested scroll areas retain the body stop. Shift+Tab from a delegated first child skips the body. Fitting content adds no body stop. The internal observed content box preserves block flow and percentage heights. If it includes a text-entry control that can bring up the mobile keyboard, use height='tall' and keep the sheet fully expanded while editing.",
required: true,
},
+ {
+ name: 'padding',
+ type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',
+ description:
+ 'Internal padding of the sheet content using the spacing scale, matching Dialog. When omitted, uses the theme default for bottom sheets: no padding unless the theme sets padding on bottom-sheet. A lone Section child escapes the padding, and bleed children such as Table and Divider compensate against it.',
+ },
{
name: 'height',
type: "'hug' | 'capped' | 'tall' | number | string",
@@ -312,7 +320,7 @@ export const docs = {
/** @type {import('@astryxdesign/cli/authoring').ComponentTranslationDoc} */
export const docsDense = {
description:
- 'mobile touch sheet rising from the bottom edge (native <dialog>): grab handle, opt-in transform-based drag-to-resize snap points (snapPoints: viewport fraction, percent or px length), scrolling area resizes to the snapped visible height on release (a peek stop, a quarter of the sheet or less, keeps the full height and slides instead), Dialog-aligned dismissal purpose (info/form/required), purpose-gated swipe-to-dismiss, fully-expanded Tall visual-viewport mobile-keyboard handling, named height scale, modal (default) or non-modal (hasScrim={false}) presentation',
+ 'mobile touch sheet rising from the bottom edge (native <dialog>): grab handle, opt-in transform-based drag-to-resize snap points (snapPoints: viewport fraction, percent or px length), scrolling area resizes to the snapped visible height on release (a peek stop, a quarter of the sheet or less, keeps the full height and slides instead), Dialog-aligned dismissal purpose (info/form/required), purpose-gated swipe-to-dismiss, fully-expanded Tall visual-viewport mobile-keyboard handling, named height scale, Dialog-like container padding (padding prop or theme bottom-sheet padding; none by default), modal (default) or non-modal (hasScrim={false}) presentation',
usage: {
anatomy,
description:
diff --git a/packages/core/src/BottomSheet/BottomSheet.test.tsx b/packages/core/src/BottomSheet/BottomSheet.test.tsx
index b0bc934e0a..3a553d10e3 100644
--- a/packages/core/src/BottomSheet/BottomSheet.test.tsx
+++ b/packages/core/src/BottomSheet/BottomSheet.test.tsx
@@ -2441,4 +2441,39 @@ describe('BottomSheet', () => {
);
});
});
+
+ describe('container padding', () => {
+ it('passes padding to the content box of a standalone sheet', () => {
+ render(
+ <BottomSheet isOpen onOpenChange={() => {}} label="Filters" padding={0}>
+ <span data-testid="sheet-child">Content</span>
+ </BottomSheet>,
+ );
+ const box = screen.getByTestId('sheet-child').parentElement!;
+ expect(
+ getComputedStyle(box).getPropertyValue(
+ '--container-padding-inline-start',
+ ),
+ ).toBe('var(--spacing-0)');
+ expect(getSheet().hasAttribute('padding')).toBe(false);
+ });
+
+ it('passes padding to the content box of a switcher sheet', () => {
+ render(
+ <BottomSheetSwitcher
+ activeSheet="details"
+ onActiveSheetChange={() => {}}>
+ <BottomSheet sheetId="details" label="Details" padding={2}>
+ <span data-testid="switcher-child">Content</span>
+ </BottomSheet>
+ </BottomSheetSwitcher>,
+ );
+ const box = screen.getByTestId('switcher-child').parentElement!;
+ expect(
+ getComputedStyle(box).getPropertyValue(
+ '--container-padding-inline-start',
+ ),
+ ).toBe('var(--spacing-2)');
+ });
+ });
});
diff --git a/packages/core/src/BottomSheet/BottomSheet.tsx b/packages/core/src/BottomSheet/BottomSheet.tsx
index 04cbe37307..8cd2514120 100644
--- a/packages/core/src/BottomSheet/BottomSheet.tsx
+++ b/packages/core/src/BottomSheet/BottomSheet.tsx
@@ -11,8 +11,8 @@
* BottomSheet selects one of two focused hosts. A standalone host owns its
* native dialog lifecycle; a switcher item participates in the parent's shared
* dialog and transition state machine. Both render the same BottomSheetPanel,
- * which owns sheet presentation, gestures, mobile-keyboard accommodation, and
- * motion completion.
+ * which owns sheet presentation, content padding, gestures, mobile-keyboard
+ * accommodation, and motion completion.
*
* SYNC: When modified, update these files to stay in sync:
* - /packages/core/src/BottomSheet/BottomSheetPanel.tsx
@@ -38,6 +38,7 @@ import {
import * as stylex from '@stylexjs/stylex';
import type {BaseProps} from '../BaseProps';
import type {DialogPurpose} from '../Dialog';
+import type {SpacingStep} from '../utils/types';
import {colorVars, durationVars, easeVars} from '../theme/tokens.stylex';
import {useDevWarning, useScrollLock} from '../hooks';
import {isImeKeyEvent} from '../utils';
@@ -138,6 +139,16 @@ interface BottomSheetSharedProps extends BaseProps<HTMLDivElement> {
/** Sheet content, rendered below the grab handle in a scrollable area. */
children: ReactNode;
+ /**
+ * Internal padding of the sheet content using the spacing scale, matching
+ * Dialog. Accepts numeric spacing steps: 0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 8, 10.
+ * When omitted, uses the theme default for bottom sheets: no padding unless
+ * the theme sets `padding` on `bottom-sheet`. The content box is a
+ * container: a Section that is its only child escapes the padding, and bleed
+ * children such as Table and Divider compensate against it.
+ */
+ padding?: SpacingStep;
+
/** Height budget or custom CSS length. Only fully expanded Tall is keyboard-aware. @default 'capped' */
height?: BottomSheetHeight | number | string;
diff --git a/packages/core/src/BottomSheet/BottomSheetPanel.test.tsx b/packages/core/src/BottomSheet/BottomSheetPanel.test.tsx
index 826c2910aa..d16577122d 100644
--- a/packages/core/src/BottomSheet/BottomSheetPanel.test.tsx
+++ b/packages/core/src/BottomSheet/BottomSheetPanel.test.tsx
@@ -3,7 +3,8 @@
/**
* @file BottomSheetPanel.test.tsx
* @input Uses vitest, Testing Library, BottomSheetPanel
- * @output Tests the shared sheet surface motion and keyboard scroll contracts
+ * @output Tests the shared sheet surface motion, keyboard scroll, and container
+ * padding contracts
* @position Internal presentation tests shared by standalone and switcher modes
*/
@@ -404,4 +405,94 @@ describe('BottomSheetPanel', () => {
);
expect(restingRules).not.toContain('cubic-bezier(.3,0,.6,.6)');
});
+
+ describe('container padding', () => {
+ // StyleX lowers the block edges to their physical properties.
+ const EDGES = [
+ ['inline-start', 'padding-inline-start'],
+ ['inline-end', 'padding-inline-end'],
+ ['block-start', 'padding-top'],
+ ['block-end', 'padding-bottom'],
+ ] as const;
+
+ function renderWithPadding(padding?: 0 | 2) {
+ render(
+ <BottomSheetPanel
+ label="Sheet details"
+ state={{kind: 'open', entering: false}}
+ height="hug"
+ padding={padding}
+ onDismiss={() => {}}
+ onScrimOpacity={() => {}}>
+ <span data-testid="sheet-child">Panel content</span>
+ </BottomSheetPanel>,
+ );
+ // The content box is the child's parent: the observed box inside the
+ // scrolling body, not the body itself.
+ return getComputedStyle(screen.getByTestId('sheet-child').parentElement!);
+ }
+
+ it('keeps the released unpadded default and publishes the theme chain', () => {
+ const computed = renderWithPadding();
+ for (const [edge, property] of EDGES) {
+ const published = computed
+ .getPropertyValue(`--container-padding-${edge}`)
+ .replace(/\s+/g, '');
+ expect(published, edge).toContain(
+ `var(--astryx-bottom-sheet-padding-${edge}`,
+ );
+ // No theme padding resolves to no inset, as before the sheet was a
+ // container.
+ expect(published, edge).toContain(
+ 'var(--astryx-bottom-sheet-padding,0px)',
+ );
+ // Applied padding reads the published value, so bleed children
+ // subtract exactly the inset they sit in.
+ expect(computed.getPropertyValue(property), edge).toBe(
+ `var(--container-padding-${edge})`,
+ );
+ }
+ // The Layout insets have no terminal value: unthemed, they stay invalid
+ // and a Layout inside the sheet keeps its own default padding.
+ for (const name of [
+ '--layout-padding-outer-x',
+ '--layout-padding-outer-y',
+ '--layout-padding-inner-x',
+ '--layout-padding-inner-y',
+ ]) {
+ const value = computed.getPropertyValue(name).replace(/\s+/g, '');
+ expect(value, name).toContain('var(--astryx-bottom-sheet-padding)');
+ expect(value, name).not.toMatch(/0px|--spacing-/);
+ }
+ });
+
+ it.each([0, 2] as const)(
+ 'applies and publishes an explicit padding step (%s)',
+ padding => {
+ const computed = renderWithPadding(padding);
+ const expected = `var(--spacing-${padding})`;
+ for (const [edge, property] of EDGES) {
+ expect(
+ computed.getPropertyValue(`--container-padding-${edge}`),
+ edge,
+ ).toBe(expected);
+ expect(computed.getPropertyValue(property), edge).toBe(expected);
+ }
+ expect(computed.getPropertyValue('--layout-padding-inner-x')).toBe(
+ expected,
+ );
+ },
+ );
+
+ it('keeps the panel itself unpadded and free of a padding attribute', () => {
+ renderWithPadding(2);
+ const panel = getPanel();
+ expect(panel.hasAttribute('padding')).toBe(false);
+ expect(
+ getComputedStyle(panel).getPropertyValue(
+ '--container-padding-inline-start',
+ ),
+ ).toBe('0px');
+ });
+ });
});
diff --git a/packages/core/src/BottomSheet/BottomSheetPanel.tsx b/packages/core/src/BottomSheet/BottomSheetPanel.tsx
index dfd7ddba37..8f7cd21f2d 100644
--- a/packages/core/src/BottomSheet/BottomSheetPanel.tsx
+++ b/packages/core/src/BottomSheet/BottomSheetPanel.tsx
@@ -4,14 +4,15 @@
/**
* @file BottomSheetPanel.tsx
- * @input Uses React, StyleX, theme tokens, text/provider boundaries, sheet gestures, shared scroll behavior, and the host label
+ * @input Uses React, StyleX, theme tokens, text/provider boundaries, container padding, sheet gestures, shared scroll behavior, and the host label
* @output Internal BottomSheetPanel with a keyboard-reachable scrolling body and motion-state types
* @position Shared presentation layer for standalone and switcher BottomSheets
*
* This component owns everything intrinsic to a sheet surface: height budgets,
- * drag and snap gestures, the handle and scrolling body, motion styles, and
- * transition completion. It owns the body's keyboard access; dialog focus
- * entry/return, inert state, and switcher registration belong to the host.
+ * drag and snap gestures, the handle and scrolling body, the content box's
+ * container padding, motion styles, and transition completion. It owns the
+ * body's keyboard access; dialog focus entry/return, inert state, and switcher
+ * registration belong to the host.
*
* SYNC: When modified, update these files to stay in sync:
* - /packages/core/src/BottomSheet/BottomSheet.tsx
@@ -19,6 +20,7 @@
* - /packages/core/src/BottomSheet/snapOffsets.ts
* - /packages/core/src/BottomSheet/useMobileKeyboard.ts
* - /packages/core/src/BottomSheet/useSheetGestures.ts
+ * - /packages/core/src/Layout/container.stylex.ts (bottom-sheet padding chain)
*/
import {
@@ -49,7 +51,17 @@ import {mergeProps, themeProps} from '../utils';
import {focusOutlineStyles} from '../utils/focusOutline.stylex';
import {layerTextReset} from '../Layer/layerTextReset.stylex';
import {LayerContentBoundary} from '../Layer/layerScopedContext';
-import {overlayPaddingReset} from '../Layout/padding.stylex';
+import {container} from '../Layout/container.stylex';
+import type {SpacingToken} from '../Layout/container.stylex';
+import {
+ containerPaddingBlockEndVarStyles,
+ containerPaddingBlockStartVarStyles,
+ containerPaddingInlineVarStyles,
+ overlayPaddingReset,
+ paddingStyles,
+ spacingStepToToken,
+} from '../Layout/padding.stylex';
+import type {SpacingStep} from '../utils/types';
import {
isValidSnapPoint,
resolveSnapPoints,
@@ -240,6 +252,9 @@ const styles = stylex.create({
// Preserve the body's block formatting (including margin/float isolation)
// and its definite percentage-height basis. min-content lets this real
// observed box grow with async content beyond a fixed-height viewport.
+ // This box is also the sheet's container: it carries the padding and
+ // publishes it, so a lone Section child escapes it exactly as in Dialog.
+ // Unpadded unless the prop or the theme sets padding.
display: 'flow-root',
boxSizing: 'border-box',
height: '100%',
@@ -284,6 +299,11 @@ interface BottomSheetPanelProps extends BaseProps<HTMLDivElement> {
/** Existing host name, reused for the keyboard scrolling group. */
label: string;
children: ReactNode;
+ /**
+ * Content padding on the spacing scale. Omitted, the content box reads the
+ * theme's bottom-sheet padding, else none (the released default).
+ */
+ padding?: SpacingStep;
snapPoints?: ReadonlyArray<BottomSheetSnapPoint>;
isSwipeDismissAllowed?: boolean;
/** Whether the host has locked page scrolling (a modal, scrim-backed sheet). */
@@ -411,6 +431,7 @@ export function BottomSheetPanel({
height,
label,
children,
+ padding,
snapPoints,
className,
style,
@@ -602,6 +623,13 @@ export function BottomSheetPanel({
};
}, [motion]);
+ // Same lowering as Dialog: with no padding prop the content box reads the
+ // theme's --astryx-bottom-sheet-padding chain (no padding when unset), else
+ // the explicit step.
+ const usesThemePadding = padding == null;
+ const effectivePadding = padding ?? 4;
+ const paddingToken = spacingStepToToken[effectivePadding] as SpacingToken;
+
const isNamedHeight = typeof height === 'string' && height in HEIGHT_BUDGETS;
const budget = isNamedHeight
? HEIGHT_BUDGETS[height as BottomSheetHeight]
@@ -700,7 +728,34 @@ export function BottomSheetPanel({
: {},
),
})}>
- <div {...getContentProps<HTMLDivElement>(stylex.props(styles.content))}>
+ <div
+ {...getContentProps<HTMLDivElement>(
+ stylex.props(
+ styles.content,
+ ...container(
+ usesThemePadding
+ ? {useThemeDefault: 'bottom-sheet'}
+ : {
+ paddingInnerX: paddingToken,
+ paddingInnerY: paddingToken,
+ paddingOuterX: paddingToken,
+ paddingOuterY: paddingToken,
+ },
+ ),
+ !usesThemePadding &&
+ effectivePadding !== 4 &&
+ paddingStyles[effectivePadding],
+ !usesThemePadding &&
+ effectivePadding !== 4 &&
+ containerPaddingInlineVarStyles[effectivePadding],
+ !usesThemePadding &&
+ effectivePadding !== 4 &&
+ containerPaddingBlockStartVarStyles[effectivePadding],
+ !usesThemePadding &&
+ effectivePadding !== 4 &&
+ containerPaddingBlockEndVarStyles[effectivePadding],
+ ),
+ )}>
<LayerContentBoundary>{children}</LayerContentBoundary>
</div>
</div>
diff --git a/packages/core/src/Layout/container.stylex.ts b/packages/core/src/Layout/container.stylex.ts
index a0de41fe97..18b57c5977 100644
--- a/packages/core/src/Layout/container.stylex.ts
+++ b/packages/core/src/Layout/container.stylex.ts
@@ -4,7 +4,7 @@
* @file container.stylex.ts
* @input Uses @stylexjs/stylex, spacing from theme
* @output StyleX utility for layout container styling
- * @position Layout utility; used by Card, Section components
+ * @position Layout utility; used by Card, Section, Dialog, and BottomSheet
*
* ## Public API for themes
*
@@ -18,13 +18,16 @@
* --astryx-card-padding-block-end
*
* Read order per level: `var(--astryx-…, <next level>)`, terminating at
- * `--spacing-4`. Same pattern for section and dialog.
+ * `--spacing-4`. Same pattern for section and dialog. Bottom-sheet keeps its
+ * released unpadded default: its edges terminate at 0px and its Layout insets
+ * at no value, so an unthemed sheet changes nothing for descendants.
*
* ```ts
* components: {
* card: { base: { padding: '20px' } }, // → --astryx-card-padding: 20px
* section: { base: { padding: '12px 20px' } }, // → directional tokens
* dialog: { base: { padding: '16px' } },
+ * 'bottom-sheet': { base: { padding: '16px' } },
* }
* ```
*
@@ -72,7 +75,7 @@ const baseStyles = stylex.create({
/**
* Component-scoped padding tokens.
*
- * Each container component (card, section, dialog) has public CSS custom
+ * Each container component (card, section, dialog, bottom-sheet) has public CSS custom
* properties that themes can set. The pipeline emits the `--astryx-*` names,
* which the component reads via `var(--astryx-…, …)`:
*
@@ -130,6 +133,25 @@ const dialogInlineEnd = `var(--astryx-dialog-padding-inline-end, ${dialogInline}
const dialogBlockStart = `var(--astryx-dialog-padding-block-start, ${dialogShorthand})`;
const dialogBlockEnd = `var(--astryx-dialog-padding-block-end, ${dialogShorthand})`;
+// Bottom sheet padding chains: --astryx-* then the next specificity level.
+// Unlike card/section/dialog, the sheet's released default is no padding, so
+// the edge chains terminate at 0px. The Layout inset chains have NO terminal
+// value: with no theme padding they are invalid at computed-value time, which
+// leaves the overlay reset in force and lets a Layout inside the sheet fall
+// back to its own default, exactly as before the sheet was a container. Built
+// as chained const strings (no function calls) so StyleX can statically
+// analyze them; see naming.ts for the prefix policy.
+const bottomSheetThemeShorthand = 'var(--astryx-bottom-sheet-padding)';
+const bottomSheetThemeInline = `var(--astryx-bottom-sheet-padding-inline, ${bottomSheetThemeShorthand})`;
+const bottomSheetThemeInlineStart = `var(--astryx-bottom-sheet-padding-inline-start, ${bottomSheetThemeInline})`;
+const bottomSheetThemeBlockStart = `var(--astryx-bottom-sheet-padding-block-start, ${bottomSheetThemeShorthand})`;
+const bottomSheetShorthand = 'var(--astryx-bottom-sheet-padding, 0px)';
+const bottomSheetInline = `var(--astryx-bottom-sheet-padding-inline, ${bottomSheetShorthand})`;
+const bottomSheetInlineStart = `var(--astryx-bottom-sheet-padding-inline-start, ${bottomSheetInline})`;
+const bottomSheetInlineEnd = `var(--astryx-bottom-sheet-padding-inline-end, ${bottomSheetInline})`;
+const bottomSheetBlockStart = `var(--astryx-bottom-sheet-padding-block-start, ${bottomSheetShorthand})`;
+const bottomSheetBlockEnd = `var(--astryx-bottom-sheet-padding-block-end, ${bottomSheetShorthand})`;
+
const cardDefaultPaddingStyles = stylex.create({
containerPaddingInlineStart: {
'--container-padding-inline-start': cardInlineStart,
@@ -211,6 +233,33 @@ const dialogDefaultPaddingStyles = stylex.create({
},
});
+const bottomSheetDefaultPaddingStyles = stylex.create({
+ containerPaddingInlineStart: {
+ '--container-padding-inline-start': bottomSheetInlineStart,
+ },
+ containerPaddingInlineEnd: {
+ '--container-padding-inline-end': bottomSheetInlineEnd,
+ },
+ containerPaddingBlockStart: {
+ '--container-padding-block-start': bottomSheetBlockStart,
+ },
+ containerPaddingBlockEnd: {
+ '--container-padding-block-end': bottomSheetBlockEnd,
+ },
+ layoutPaddingOuterX: {
+ '--layout-padding-outer-x': bottomSheetThemeInlineStart,
+ },
+ layoutPaddingOuterY: {
+ '--layout-padding-outer-y': bottomSheetThemeBlockStart,
+ },
+ layoutPaddingInnerX: {
+ '--layout-padding-inner-x': bottomSheetThemeInlineStart,
+ },
+ layoutPaddingInnerY: {
+ '--layout-padding-inner-y': bottomSheetThemeBlockStart,
+ },
+});
+
/**
* Map from component name to its theme default padding styles.
* Each component reads from its own public CSS custom property.
@@ -219,6 +268,7 @@ const themeDefaultStyles = {
card: cardDefaultPaddingStyles,
section: sectionDefaultPaddingStyles,
dialog: dialogDefaultPaddingStyles,
+ 'bottom-sheet': bottomSheetDefaultPaddingStyles,
};
export type ContainerComponent = keyof typeof themeDefaultStyles;
@@ -426,7 +476,8 @@ export interface ContainerOptions {
paddingInnerY?: SpacingToken;
/**
- * When set to a component name ('card' | 'section'), internal layout
+ * When set to a component name ('card' | 'section' | 'dialog' |
+ * 'bottom-sheet'), internal layout
* padding variables cascade from the component-specific public CSS
* container tokens (set by theme pipeline from `padding` shorthand)
* instead of being set to explicit spacing token values.
@@ -434,7 +485,8 @@ export interface ContainerOptions {
* This allows themes to override container padding via component-specific
* public CSS custom properties without touching internal vars.
*
- * Used by Card and Section when no explicit padding prop is provided.
+ * Used by Card, Section, Dialog, and BottomSheet when no explicit padding
+ * prop is provided.
* @default undefined (uses explicit spacing token values)
*/
useThemeDefault?: ContainerComponent;
diff --git a/packages/core/src/theme/defineTheme.test.ts b/packages/core/src/theme/defineTheme.test.ts
index 74ea3a5774..bd9363ef7b 100644
--- a/packages/core/src/theme/defineTheme.test.ts
+++ b/packages/core/src/theme/defineTheme.test.ts
@@ -1045,6 +1045,24 @@ describe('container padding mapping', () => {
expect(css).toContain('--astryx-dialog-padding-block-start: 24px');
});
+ it('maps bottom-sheet padding to its container tokens', () => {
+ const theme = defineTheme({
+ name: 'test',
+ components: {
+ 'bottom-sheet': {
+ base: {padding: '24px 20px'},
+ },
+ },
+ });
+ const css = generateThemeTestCSS(theme);
+ expect(css).toContain('--astryx-bottom-sheet-padding-inline: 20px');
+ expect(css).toContain('--astryx-bottom-sheet-padding-block-start: 24px');
+ expect(css).toContain('--astryx-bottom-sheet-padding-block-end: 24px');
+ // The panel is the overlay boundary; the value reaches the content box
+ // through the token, never as padding on the panel itself.
+ expect(css).not.toMatch(/(^|[\s{;])padding:\s*24px 20px/);
+ });
+
it('does NOT map padding on non-container components', () => {
const theme = defineTheme({
name: 'test',
diff --git a/packages/core/src/theme/derivedVarRegistry.test.ts b/packages/core/src/theme/derivedVarRegistry.test.ts
index bcbfb77013..ea421a4918 100644
--- a/packages/core/src/theme/derivedVarRegistry.test.ts
+++ b/packages/core/src/theme/derivedVarRegistry.test.ts
@@ -215,6 +215,7 @@ function discoverComponents(): ComponentInfo[] {
const DIR_TO_REGISTRY_KEY: Record<string, string> = {
Avatar: 'avatar',
Banner: 'banner',
+ BottomSheet: 'bottom-sheet',
Button: 'button',
Card: 'card',
Chat: 'chat',
diff --git a/packages/core/src/theme/derivedVarRegistry.ts b/packages/core/src/theme/derivedVarRegistry.ts
index dddb65bdb2..b6e9841a33 100644
--- a/packages/core/src/theme/derivedVarRegistry.ts
+++ b/packages/core/src/theme/derivedVarRegistry.ts
@@ -45,6 +45,7 @@ export interface DerivedVarEntry {
export const derivedVarRegistry: Record<string, DerivedVarEntry[]> = {
avatar: [{property: 'borderRadius', vars: ['--_avatar-radius']}],
banner: [{property: 'borderRadius', vars: ['--_banner-radius']}],
+ 'bottom-sheet': [{property: 'padding', expand: 'container'}],
button: [{property: 'borderRadius', vars: ['--_button-radius']}],
card: [
{property: 'borderRadius', vars: ['--_card-radius']},