Skip to Content

Text

Provides a readable text container with typography-oriented defaults. It can also apply appropriate spacing between headings, paragraphs, and other text elements.

By default, Text is width-aware: its children are constrained to a readable line length based on --unitone--measure. That default is useful for prose, but it means Text is not a neutral width wrapper.

When not to use it as the outer width wrapper

If the visible width of a section should be controlled by a surrounding primitive such as Container, Layers, Center, or Decorator, avoid placing Text directly in that width-defining position unless you intentionally want the section to collapse to the readable measure.

This is especially important for:

  • hero copy
  • wide callout text
  • promotional panels
  • layered overlays

In those cases, let the outer primitive own the visual width first, then place Text inside that wrapper only when you need heading/paragraph rhythm.

Bad for wide hero copy:

<div data-unitone-layout="container"> <div data-unitone-layout="text -gap">...</div> </div>

If you want to match the width of the parent element, specify the max width prop.

<div data-unitone-layout="container"> <div data-unitone-layout="text -gap" style="--unitone--max-width: 100%">...</div> </div>

Usage

Lorem Lorem ipsum dolor sit amet

Lorem Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cill

Lorem Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cill

Lorem Lorem ipsum dolor sit amet

Lorem Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cill

<div data-unitone-layout="text -gap"> <h2>Lorem Lorem ipsum dolor sit amet</h2> <p>Lorem Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cill</p> <p>Lorem Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cill</p> <h3>Lorem Lorem ipsum dolor sit amet</h3> <p>Lorem Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cill</p> </div>

Props

HTML -gap / JSX applyGap

Automatically apply appropriate gap.

<div data-unitone-layout="text -gap"> ... </div>

HTML -gutters:{variation} / JSX gutters={variation}

Gutters.

Can be set from -3 to 7. For variations 2 and above, clamp is used to adjust the margins so that they do not become too large on small screens. If it is 1 or more, adding s will shrink it to size -1 on mobile. (e.g. 1s) If it is 2 or more, adding m will shrink it to size 1 on mobile. (e.g. 2m)

<div data-unitone-layout="text -gutters:1 -gap"> ... </div>

HTML --unitone--max-width / JSX maxWidth={value}

max-width of the child element.

<div data-unitone-layout="text -gap" style="--unitone--max-width: 400px"> ... </div>

HTML -column / JSX column

Column width.

--unitone--column-width specifies the ideal width of the column.

<div data-unitone-layout="text -column" style="--unitone--column-width: 200px"> ... </div>

HTML -container-type:{value} / JSX containerType={value}

Establishes the Text as a query container for its descendants.

Currently supported values are:

  • inline-size
<div data-unitone-layout="text -container-type:inline-size"> <div>...</div> </div>

HTML -responsive-context:{value} / JSX responsiveContext={value}

Sets the responsive context for descendants to container, the only supported value. It does not affect the Text element itself. Use responsiveContext="container" together with containerType="inline-size" on this element (HTML: -responsive-context:container -container-type:inline-size). The default is viewport-based behavior, and there is no viewport override inside a container context. The context becomes active only when both markers are on the same element. If containerType="inline-size" is omitted, responsiveContext="container" is ignored and the existing responsive context remains active. See Responsive context utilities for examples.

Deprecated HTML -fluid-reference:{value} / JSX fluidReference={value}

Deprecated. Use responsiveContext="container" on an ancestor instead.

Uses a query container’s inline size as the reference for fluid typography, spacing, padding, and gutters.

Currently supported values are:

  • cqw

Place the Text inside an ancestor with container-type: inline-size.

<div data-unitone-layout="text -container-type:inline-size"> <div data-unitone-layout="text -fluid-reference:cqw"> ... </div> </div>
Last updated on