Section
The section component groups related content into clearly-defined thematic areas with consistent styling and structure. Use section to organize page content into logical blocks, each with its own heading and visual container.
Sections automatically adapt their styling based on nesting depth and adjust heading levels to maintain meaningful, accessible page hierarchies. For simple visual separation without headings, use divider.
Anchor to PropertiesProperties
Configure the following properties on the section component.
- Anchor to accessibilityLabelaccessibilityLabelaccessibilityLabelstringstringrequiredrequired
A label that describes the purpose or content of the component for assistive technologies like screen readers. Use this to provide additional context when the visible content alone doesn't clearly convey the component's purpose.
- Anchor to headingheadingheadingstringstringrequiredrequired
The heading text displayed at the top of the section. This heading provides a title for the section's content and automatically uses the appropriate semantic heading level (h2, h3, h4) based on nesting depth to maintain proper document structure.
- Anchor to paddingpaddingpadding"base" | "none""base" | "none"Default: 'base'Default: 'base'requiredrequired
The padding applied to all edges of the element.
base: applies padding that is appropriate for the element. Note that it might result in no padding if this is the right design decision in a particular context.none: removes all padding from the element. This can be useful when elements inside the section need to span to the edge of the section. For example, a full-width image. In this case, rely ons-boxwith a padding of 'base' to bring back the desired padding for the rest of the content.
Anchor to SlotsSlots
The section component supports slots for additional content placement within the component. Learn more about using slots.
- Anchor to childrenchildrenchildrenHTMLElementHTMLElement
The content displayed within the section component, which groups related elements together in a logical unit with an optional heading.
Anchor to ExamplesExamples
Anchor to Add a content section with a headingAdd a content section with a heading
Create a section with a heading to group related content. This example shows a basic section with a title and description text.
Preview
html
Anchor to Group form fields in a sectionGroup form fields in a section
Use a section with a heading and form fields to group related inputs. This example shows a customer information form with text and email fields inside a top-level section.
Preview
html
Anchor to Create nested sections with automatic visual hierarchyCreate nested sections with automatic visual hierarchy
Nest sections to create visual and semantic hierarchy that automatically adjusts heading levels and styling. This example shows three levels of nesting for order details, customer information, and a billing address.
Preview
html
Anchor to Add an accessibility label for screen readersAdd an accessibility label for screen readers
Use the accessibilityLabel property to provide screen readers with additional context beyond the visible heading. This example shows a payment summary section and a label describing the contents of the section.
Preview
html
Anchor to Remove padding for full-width contentRemove padding for full-width content
Set the padding property to none so that content like tables can extend to the section edges. This example shows a product table rendered full-width within a section.
Preview
html
Anchor to Best practicesBest practices
- Use to group related content: The component provides semantic structure and visual hierarchy for grouping related content. Each section should contain a cohesive set of information or controls that belong together.
- Provide meaningful headings: Section headings help merchants scan and navigate content. Write headings that clearly describe what's in the section rather than using vague labels.
- Nest thoughtfully: Nested sections create visual and semantic hierarchy, but excessive nesting creates overly complex structures. Limit nesting to 2-3 levels where the hierarchy is meaningful and helps merchants understand the content organization.
- Consider when to remove padding: Full-width content like tables or images might need to extend to section edges. Remove padding when the content design requires it, but ensure nested content within has appropriate spacing.
- Use accessibility labels when needed: When the visible heading doesn't fully convey the section's purpose to screen reader users, provide an accessibility label with additional context.
Anchor to LimitationsLimitations
- The component doesn't include expand/collapse functionality. If you need collapsible sections, you'll need to implement this using additional state management and accessibility attributes.
- Section headings automatically increment their semantic level based on nesting depth, but they stop at h4 for deeply nested sections. Content nested beyond three levels might have less clear document structure.