Section
Renders a `<section>` and works out the right heading level for the headings inside it. Use so nesting a component never breaks the page outline.
compliant
- Overview
- Props
The Section component is a semantic wrapper that automatically manages heading levels within nested sections. By default it renders a <section> HTML element on the Web platform, but can render <article>, <aside>, or <nav> using the tag prop. It provides a context that increments the heading level for any Heading components used inside.
Usage​
Section Title
Automatic Heading Level Management​
When you nest Section components, the heading level is automatically incremented. This ensures proper document structure without manually tracking heading levels.
Main Section
Nested Section
Deeply Nested Section
In the example above:
- The outer
Sectionsets heading level toh1 - The first nested
Sectionincrements toh2 - The deeply nested
Sectionincrements toh3
Using Different HTML Sectioning Elements​
The tag prop is only used on the web platform. On React Native, the Section component always renders a View regardless of the tag value, as native platforms don't have semantic HTML elements.
Use the tag prop to render different HTML sectioning elements while maintaining automatic heading level management:
Page Title
Article Section
Self-contained content using tag="article"
Nav Section
Navigation content using tag="nav"
| Value | HTML Element | Use Case |
|---|---|---|
section | <section> | Generic standalone section of a document that doesn't have a more specific semantic element to represent it (default). MDN |
article | <article> | Self-contained composition intended to be independently distributable or reusable (e.g., blog post, comment, forum post). MDN |
aside | <aside> | Content indirectly related to the main content (e.g., sidebars, pull quotes, advertising, related links). MDN |
nav | <nav> | Section providing navigation links (e.g., menus, tables of contents, indexes). MDN |
Accessibility​
The Section component helps maintain proper heading hierarchy, which is essential for:
- Screen readers: Users can navigate through the document using heading shortcuts
- Document outline: Creates a logical structure that assistive technologies can interpret
- WCAG compliance: Aligns with WCAG 2.1 guideline 1.3.1 for proper information structure
More details in the dedicated section Headings.
Do​
Use Section to structure your content and let heading levels be managed automatically:
Article Title
Introduction paragraph... Content for this section... More content...First Section
Second Section
Don't​
Don't manually manage heading levels when you can use Section:
Article Title
Introduction paragraph...
First Section
Content for this section...
Second Section
More content...
Playground​
murray and murray/mobile.Section props
| Name | Type | Default Value | Description | Usage count |
|---|---|---|---|---|
| initialLevel | HeadingLevelundefined | |||
| sx | StackStyleundefined | |||
| tag | 5 possibilities"article""aside""nav""section"undefined | section | Controls the output tag on web {@see https://developer.mozilla.org/en-US/docs/Web/HTML/Element} |
Style API​
Use sx for one-off adjustments. It accepts these style keys:
Each can be overridden per breakpoint with: