Skip to content

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

TypeScript

feat(Stack): default direction to vertical (#1945)

Cindy Zhangd5bd1312640f
diff --git a/apps/storybook/stories/Stack.stories.tsx b/apps/storybook/stories/Stack.stories.tsx
index 7d009c5e5e..775dcd2a0a 100644
--- a/apps/storybook/stories/Stack.stories.tsx
+++ b/apps/storybook/stories/Stack.stories.tsx
@@ -176,7 +176,6 @@ type Story = StoryObj<typeof XDSStack>;
export const Default: Story = {
args: {
- direction: 'vertical',
gap: 2,
children: null,
},
diff --git a/packages/core/src/Stack/XDSStack.test.tsx b/packages/core/src/Stack/XDSStack.test.tsx
index cb4f7aec4a..1e64718c1f 100644
--- a/packages/core/src/Stack/XDSStack.test.tsx
+++ b/packages/core/src/Stack/XDSStack.test.tsx
@@ -12,6 +12,16 @@ import {render, screen} from '@testing-library/react';
import {XDSStack} from './XDSStack';
describe('XDSStack', () => {
+ it('defaults to vertical direction', () => {
+ render(
+ <XDSStack data-testid="stack">
+ <div>Item 1</div>
+ <div>Item 2</div>
+ </XDSStack>,
+ );
+ expect(screen.getByTestId('stack')).toBeInTheDocument();
+ });
+
it('renders children correctly', () => {
render(
<XDSStack direction="vertical">
diff --git a/packages/core/src/Stack/XDSStack.tsx b/packages/core/src/Stack/XDSStack.tsx
index 7e619966b9..f5b3d7b2a0 100644
--- a/packages/core/src/Stack/XDSStack.tsx
+++ b/packages/core/src/Stack/XDSStack.tsx
@@ -53,8 +53,9 @@ export interface XDSStackProps extends XDSBaseProps<HTMLDivElement> {
* Direction of the stack layout.
* - `horizontal`: Items flow left-to-right (like XDSHStack)
* - `vertical`: Items flow top-to-bottom (like XDSVStack)
+ * @default 'vertical'
*/
- direction: StackDirection;
+ direction?: StackDirection;
/**
* Horizontal alignment of items.
@@ -157,7 +158,8 @@ export interface XDSStackProps extends XDSBaseProps<HTMLDivElement> {
* Unified stack component for arranging items in a horizontal or vertical layout.
*
* Replaces `XDSHStack` and `XDSVStack` with a single component that accepts
- * a required `direction` prop so the layout intent is always explicit.
+ * a `direction` prop. Defaults to `'vertical'` since most layouts stack
+ * top-to-bottom.
*
* The `hAlign` and `vAlign` props automatically map to the correct CSS axis
* based on the direction:
@@ -166,7 +168,7 @@ export interface XDSStackProps extends XDSBaseProps<HTMLDivElement> {
*
* @example
* ```
- * <XDSStack direction="vertical" gap={2}>
+ * <XDSStack gap={2}>
* <Item />
* <Item />
* </XDSStack>
@@ -177,7 +179,7 @@ export interface XDSStackProps extends XDSBaseProps<HTMLDivElement> {
* ```
*/
export function XDSStack({
- direction,
+ direction = 'vertical',
hAlign,
vAlign,
justify,