Skip to content
UI
On this page

Layout and typography

Choose a layout or text component. Use its native semantics to build a readable page.

Choose a component · Style with StyleX · Enforce usage with lint

Choose a primitive

Start with Box when you need a wrapper. Use Stack for vertical groups and HStack for horizontal groups. Use Flex for custom alignment and Grid for columns. Container limits the width of page content and centers it. Use AspectRatio to reserve space for media. Use List and ListItem for ordered or unordered lists. Use Text and Heading for semantic text instead of a generic Box. Use TanStack Router Link for application navigation. Registry Link is optional. Select a component below to see a live preview. Copy its source as necessary.

The global reset sets border-box sizing and zero minimum inline size for all elements and pseudo-elements. Box adds no padding, border, or background. Existing layout spacing stays unchanged.

Text uses the sans font token and foreground color token. Its defaults are 1rem text, normal weight, 1.5 line height, and zero margins. Heading uses the heading font token, weight 400, and 1.25 line height. Heading has zero margins. Default sizes are h1 2.25rem, h2 1.5rem, h3 1.25rem, h4 1.125rem, h5 1rem, and h6 0.875rem. Sizes follow the rendered native tag, including callbacks and custom components. Other tags use the h2 size. Use xstyle to override typography.

Em, Mark, and Highlight inherit surrounding font size, font family, weight, and line height. Strong marks important text with weight 600. Figcaption provides a muted caption for a figure. Blockquote keeps its border, italic style, muted color, and spacing. Prose keeps its readable width and 1.7 line height.

  • Box: Uses div by default. The render prop selects a semantic element with tag-specific events and refs. The global reset sets box sizing and minimum inline size.
  • Flex: Flex layout. Set direction and alignment with xstyle.
  • Stack: Column flex layout with four spacing units between children.
  • HStack: Row flex layout with centered cross-axis alignment and four spacing units between children.
  • VStack: Column flex layout with four spacing units between children.
  • Grid: Grid layout. Set columns and rows with xstyle.
  • Center: Flex layout centered on both axes.
  • Container: Centers a fluid page wrapper with a maximum width of 90rem. Use fluid for full width. Use xstyle to change maximum width and padding.
  • Absolute Center: Center content within a positioned parent.
  • Aspect Ratio: Reserve space with a width-to-height ratio. The default is 16:9. Invalid ratios use the default.
  • Bleed: Extend content into a parent's inline padding.
  • Float: Position content over a parent's corner.
  • Wrap: Arranges items in rows that wrap.
  • Link: Native anchor with href, target, rel, download, ref, and native keyboard behavior.
  • Text: Native paragraph with token-based typography defaults and xstyle overrides.
  • Blockquote: Long-form quotation.
  • Em: Emphasized text.
  • Strong: Important text.
  • Figcaption: Caption inside a figure.
  • List: Unordered list by default. Use ListItem for each item. Use render={<ol />} for an ordered list.
  • Highlight: Highlight matching words.
  • Mark: Marked text.
  • Pre: Preformatted text with preserved whitespace and horizontal scrolling.
  • Prose: Readable long-form content.
  • Heading: Uses h2 by default. The render prop selects h1 through h6 with different default sizes.

Native semantics

Box uses div by default. Pass a native element or custom component through render. Put element-specific attributes, events, and refs on that element. Use xstyle for styling.

Heading uses h2 by default. Use render={<h1 />} through render={<h6 />} to select the semantic heading level. Alternatively, use a render callback that spreads the supplied props.

Link uses native navigation by default. Use TanStack Router Link directly for application navigation. You can use native anchors and framework links. You do not need to wrap them in registry Link. If you use registry Link, pass a framework Link through render to keep framework navigation.

List uses ul by default. Use render={<ol start={3} reversed />} for a reversed ordered list. Set value on ListItem to change an ordered item's number.

Place Strong inside text to mark importance. Place Figcaption first or last inside a figure. Use Box render={<figure />} to keep figure semantics.

AspectRatio uses ratio={16 / 9} by default. Zero, negative, and non-finite ratios use the default. Use xstyle to change aspectRatio. Keep content within the reserved space.

Semantic components

Live layout examples

Open these examples to compare alignment, spacing, responsive layout, and native semantics. Use the controls to check keyboard focus, refs, and form submission. Open live layout examples in the browser.

Show live layout examples

Layout primitives

Semantic content

Third-level heading

Fourth-level heading

Fifth-level heading
Sixth-level heading

Default third level

Callback heading

Custom heading
Non-heading render

Text content keeps its native p element.

Layout primitives keep document semantics explicit.

Go to destinationRead docs
OneTwo
يمينيسار
Responsive layout
Vertical oneVertical two
Horizontal oneHorizontal two
Overridden layout
Stack oneStack two
Grid oneGrid two
Centered
Constrained content
Fluid content
Middle
Corner
RTL middle
RTL top
Bleeding content
OneTwoThree

Not submitted

Not inspected

Destination

Next: style these components with StyleX.