layout-text
Typographic content container with vertical rhythm. Provides intelligent spacing between paragraphs, headings, lists, and other block elements.
Attributes
| Attribute | Values | Default | Description |
|---|---|---|---|
| layout-text has no configurable attributes. It applies consistent typographic spacing automatically. | |||
How It Works
The layout-text element creates a container optimized for long-form reading content. It:
- Sets a maximum line width of 65ch (characters) for optimal readability
- Applies consistent vertical spacing between block elements
- Uses larger margins before major headings (proximity principle)
- Tightens spacing after headings so they associate with their content
- Provides extra breathing room around figures and code blocks
Live Example
Basic layout-text usage
<layout-text> <h2>Article Title</h2> <p>First paragraph of content...</p> <p>Second paragraph continues...</p> <h3>Section Heading</h3> <p>Content for this section...</p> <ul> <li>List item</li> <li>Another item</li> </ul> <blockquote> <p>A notable quote...</p> </blockquote></layout-text>
Spacing Rules
The prose element applies different spacing based on element types:
| Context | Spacing | Rationale |
|---|---|---|
| Default (between elements) | var(--size-m) |
Standard paragraph spacing |
| Before h2 | var(--size-2xl) |
Major section break |
| Before h3 | var(--size-xl) |
Subsection break |
| Before h4/h5/h6 | var(--size-l) |
Minor section break |
| After any heading | var(--size-s) |
Associates heading with content |
| Between consecutive lists | var(--size-s) |
Groups related lists |
| Before/after figures and pre | var(--size-l) |
Extra breathing room for media |
Usage Examples
Blog Post
Blog post with centered layout
<layout-center data-layout-max="narrow"> <article> <layout-text> <h1>Getting Started with Web Components</h1> <p class="lead">Learn how to build reusable HTML elements.</p> <p>Web Components are built on web standards...</p> <h2>Why Web Components?</h2> <ul> <li>Work everywhere HTML works</li> <li>Don't require a build step</li> </ul> </layout-text> </article></layout-center>
Documentation Page
With layout-center for Page Layout
Centered article layout
<layout-center data-layout-max="narrow"> <layout-text> <h2>Centered Article</h2> <p>Combining layout-text with layout-center creates an optimal reading experience.</p> <p>This pattern is common for blog posts, documentation, and long-form content.</p> </layout-text></layout-center>
Best Practices
- Use for long-form content only - layout-text is designed for articles, documentation, and similar content. Don't use it for UI layouts.
- Combine with layout-center - For page layouts, wrap layout-text in a layout-center to constrain width.
- Semantic HTML - The spacing rules work best with proper semantic markup (h2 before h3, etc.).
- Avoid nesting layout elements - layout-stack, layout-grid, and similar elements inside prose may have unexpected spacing.
Related
<layout-center>— Horizontally centered container<layout-stack>— Vertical stacking layout<layout-card>— Card container