HomeGetting StartedColor SystemTypographySpacingIconographyLayoutInstallationUsageAngularBlazorReactSvelteVueThemingTypographyCustomizationCSS-Only ComponentsFormsIconsIllustrationsAccessibilityGlobal ConfigurationTailwind CSSSass LibraryForge MCP ServerDropdown OptionsFocus Indicator ClippingAll componentsButtonButton AreaChipFloating Action ButtonIcon ButtonSplit ButtonAutocompleteButton ToggleCalendarCheckboxChip FieldColor PickerDate PickerDate Range PickerFile PickerLabelRadioSelectSliderSwitchText FieldTime PickerApp BarApp LauncherDrawerMenuPaginatorSkip LinkStepperTabsView SwitcherAccordionApp LayoutCardDividerExpansion PanelScaffoldSplit ViewStackStructured CardToolbarBadgeBannerBusy IndicatorCircular ProgressDialogInline MessageLinear ProgressPage StateSkeletonToastTooltipAvatarIconKeyLabel ValueListMeterSecretTableTimelineTimestampTreeKeyboard ShortcutPopoverIntroductionColorTypographySpacingShapeBorderElevationLayeringAnimationUsageIcon LibraryBlocksRoadmapChangelogBlog

Stack

A layout utility that manages spacing and alignment of its immediate children along a single vertical or horizontal axis.

OneTwoThree

Usage

forge-stack lays out its immediate children along one axis through inline (horizontal instead of the default vertical), wrap, stretch, gap, alignment, and justify. It’s a thin, single-purpose abstraction over flex — reach for CSS Flexbox or Grid directly once a layout needs more than one axis or more complex behavior than the stack’s own properties cover.

It’s easy to overuse the stack component and end up with a lot of nested stacks, which hurts both performance and maintainability. Use it judiciously — for straightforward single-axis spacing — and reach for CSS Flexbox or Grid for anything more complex.

Rules

Do
Use a stack for simple, single-axis spacing between a handful of children.Set gap to a Forge spacing token instead of margins on individual children.Reach for CSS Flexbox or Grid once a layout needs more than one axis.
Don't
Don't nest more than a couple of stacks to build a complex layout — that's a sign to switch to Flexbox or Grid directly.Don't use a stack as a general-purpose container — it's a spacing utility, not a layout component with its own semantics.

Basic usage

Children stack vertically by default, spaced by gap.

A vertical stack with even spacing between children.

Vertical form

A vertical stack keeps form fields evenly spaced without hand-tuned margins between them.

A simple vertical form layout with even spacing between fields.

Nesting for multi-column layouts

Nest an inline stack inside a vertical one for a form with multiple columns or mixed spacing — keep nesting shallow, since this is exactly the pattern that gets unwieldy if it grows much further.

A more complex form layout using nested stacks for multiple columns.

The stack is a utility component that helps manage spacing and alignment of immediate children along a vertical or horizontal axis. Use stacks sparingly to avoid unnecessary DOM complexity, and prefer CSS flexbox or grid for more complex layouts.

import "@tylertech/forge/stack";
Properties
PropertyAttributeTypeDefaultDescription
inlineinlinebooleanfalseControls the direction of the stack.
wrapwrapbooleanfalseControls if items wrap to a new line in inline mode
stretchstretchbooleanfalseControls if items stretch and take up the maximum amount of space
gapgapStackGapSize | (string & {})"16"Controls the gap between the children within the stack. Accepts a CSS length, a unitless pixel number, or a spacing token size (`xxxs`, `xxs`, `xs`, `s`, `m`, `ml`, `l`, `xl`, `xxl`, `xxxl`) which maps to `--forge-spacing-*`.
alignmentalignmentStackAlignment"start"Controls the align-items property of a row or column
justifyjustifyStackAlignment"start"Controls the justify-content property of a row or column
Slots
NameDescription
(default)The default/unnamed slot for stack content.
CSS Parts
NameDescription
::part(root)The root container element.
CSS Custom Properties
NameDescription
--forge-stack-alignmentControls the align-items CSS property of the root stack element.
--forge-stack-justifyControls the justify-content CSS property of the root stack element.
--forge-stack-gapControls the gap between each child element within a stack.
--forge-stack-heightControls the height of the root stack element.
--forge-stack-stretchControls the flex shorthand property of a child element within the stack.

Accessibility documentation coming soon.

Loading Forge chat…