Skip to content
Cloaked Design SystemLayout

HStack

A horizontal flex row with a token-scale gap, cross-axis alignment, main-axis distribution, wrap, and scroll options.

Implementation preview
COMPLETE STORYBOOK REFERENCE

Every example. In one place.

Explore every named example, including states, compositions, and theme variants.

6 stories
SELECTED EXAMPLE

Playground

Open controls
Playground selectedOpen canvas
Example sourcepackages/design-system/src/components/layout/HStack/HStack.stories.tsxExport Playground

Implementation preview Local Storybook build 0.2.0-preview.1. Source specification status does not approve this runtime.

Stories + source JSON ↗

Local specification source status: preview. Implementation preview pending sign-off.

A horizontal flex row with a token-scale gap, cross-axis alignment, main-axis distribution, wrap, and scroll options.

Design-owned component contract ↗Version 0.2.0-preview.1 · Implementation preview pending sign-off
Implementation API 1 entry point · source-derived preview

Read the actual callable API and preserve its composition constraints. Each union branch is a complete alternative; props marked forbidden cannot be supplied.

import { HStack } from '@cloakedinc/design-system';
HStackStackOwnProps

packages/design-system/src/components/layout/HStack/HStack.tsx:14

PropTypePresenceNotes
gap0 | 4 | 8 | 12 | 16 | 20 | 24 | 32 | 40 | 48 | 56 | 64 | 72 | 80 | 96 | 120 | 240 | undefinedOptionalSpace between children, in `--cds-space-*` steps.
alignStackAlign | undefinedOptionalCross-axis alignment (`align-items`).
justifyStackJustify | undefinedOptionalMain-axis distribution (`justify-content`).
wrapboolean | undefinedOptionalReflow children onto new lines on overflow, where `scroll` keeps them on one line.
scrollboolean | undefinedOptionalTurn the stack into a swipeable overflow strip on the main axis (HStack scrolls horizontally, VStack vertically) and hide the scrollbar. For carousels, set `scroll-snap-align` on the children.
asReact.ElementType<any, keyof React.JSX.IntrinsicElements> | undefinedOptionalRendered element. Defaults to `div`.
classNamestring | undefinedOptional
styleReact.CSSProperties | undefinedOptional
childrenReact.ReactNodeOptional
testIdstring | undefinedOptionalOptional test selector, placed on the `as` element.
idstring | undefinedOptionalDOM id for aria relationships such as `aria-describedby`.
padding0 | 4 | 8 | 12 | 16 | 20 | 24 | 32 | 40 | 48 | 56 | 64 | 72 | 80 | 96 | 120 | 240 | undefinedOptionalPadding on all four sides.
paddingX0 | 4 | 8 | 12 | 16 | 20 | 24 | 32 | 40 | 48 | 56 | 64 | 72 | 80 | 96 | 120 | 240 | undefinedOptionalHorizontal padding (left + right). Overrides `padding` on the X axis.
paddingY0 | 4 | 8 | 12 | 16 | 20 | 24 | 32 | 40 | 48 | 56 | 64 | 72 | 80 | 96 | 120 | 240 | undefinedOptionalVertical padding (top + bottom). Overrides `padding` on the Y axis.
paddingTop0 | 4 | 8 | 12 | 16 | 20 | 24 | 32 | 40 | 48 | 56 | 64 | 72 | 80 | 96 | 120 | 240 | undefinedOptionalTop padding. Overrides `paddingY` and `padding`.
paddingRight0 | 4 | 8 | 12 | 16 | 20 | 24 | 32 | 40 | 48 | 56 | 64 | 72 | 80 | 96 | 120 | 240 | undefinedOptionalRight padding. Overrides `paddingX` and `padding`.
paddingBottom0 | 4 | 8 | 12 | 16 | 20 | 24 | 32 | 40 | 48 | 56 | 64 | 72 | 80 | 96 | 120 | 240 | undefinedOptionalBottom padding. Overrides `paddingY` and `padding`.
paddingLeft0 | 4 | 8 | 12 | 16 | 20 | 24 | 32 | 40 | 48 | 56 | 64 | 72 | 80 | 96 | 120 | 240 | undefinedOptionalLeft padding. Overrides `paddingX` and `padding`.

Only explicit destructured parameter initializers are extracted. Other runtime defaults remain in implementation source.

Overview

Horizontal flex row with a token-scale gap — the default replacement for hand-rolled display:flex; flex-direction:row wrappers.

When to use

Reach for HStack when items sit side by side in a single row — an icon beside a label, a title with a trailing action, a footer's paired buttons. align is the cross (vertical) axis and justify the main (horizontal) axis, so justify="between" pins the first and last child to the row edges.

  • Stacking elements top to bottom instead? Use VStack.
  • Laying out equal-width tiles that wrap into a fixed column count? Use Grid.
  • Row that overflows and should swipe? Use scroll for a plain overflow strip, or Carousel for snapping one-per-view paging.

Component specification

$schema../../../specs/component-spec.schema.json
Parts
Id
root
Label
Root
Description
Flex row container. Structural: it lays out children and paints no surface of its own.
Required
true
Allowed Design Choices
Variants
Row
Label
Row
Description
The single horizontal flex layout.
Sizes
Alignments
Start
Label
Start
Center
Label
Center
End
Label
End
Stretch
Label
Stretch
Baseline
Label
Baseline
Justifications
Start
Label
Start
Center
Label
Center
End
Label
End
Between
Label
Between
Around
Label
Around
Evenly
Label
Evenly
Variants
Id
row
Label
Row
Description
Horizontal flex container.
Platforms
  • ios
  • android
  • web
SizesNone specified
Measurements
Id
stack-gap
Label
Row gap
Kind
example-only
Token
--cds-space-12
Value
12
Unit
px
Applies To
  • root
Notes
Representative value: gap is author-configurable and accepts any step on the spacing scale. 12 is the value rendered and verified by the Playground story.
Layout
Alignment
align sets the cross (vertical) axis; justify sets the main (horizontal) axis.
Flow
Children flow left to right and may wrap or scroll on overflow.
Notes
  • Use VStack for a column, Grid for equal-width tiles, and scroll or Carousel for a swipe strip.
Typography And Color
Typography
Label
Inherited
Description
HStack sets no type; children own their text. Ramp noted for parity.
Token
--cds-type-body-size
Colors
Label
Transparent
Description
HStack paints no background; the surface behind shows through.
Token
--cds-bg-page
States
Id
default
Label
Default
Description
Static row that flexes to its children.
Id
wrap
Label
Wrapped
Description
Children wrap onto additional rows on overflow.
Id
scroll
Label
Scroll
Description
The row becomes a horizontal overflow strip with a hidden scrollbar.
Behavior
Label
Token gap
Description
gap uses the spacing scale; avoid hand-rolled flex wrappers.
Label
Padding
Description
Padding props map to the spacing scale per edge.
Accessibility
Label
Presentational
Description
HStack is a layout container and adds no roles; order follows DOM order.
Label
Focus order
Description
Reordering visually via justify does not change tab order.
Content Adaptation
Label
Wrap vs scroll
Description
Choose wrap to reflow onto new rows or scroll to keep a single overflow strip.
Label
Distribution
Description
between, around, and evenly need free space to distribute children.
Motion Haptics
Motion
Label
None
Description
HStack does not animate layout changes on its own.
Haptics
Label
None
Description
A layout container requests no haptics.
Platform DifferencesNone specified
Implementation preview

This design-owned implementation is ready to try and review. It does not establish product approval. Imported specifications retain their original review status.

Inspect version 0.2.0-preview.1