Overview
All page content sits in sections. A section is a section.nds-content-section. Its wrapper groups the head (a title and a description), an optional action, an optional image and the body. The section sets the page gutter, the space above and below, and the background. Sections need no JavaScript.
Pick another component when:
- the content is a group inside a section, with no background of its own: Block
- the section shows an outcome, such as a page not found: Status Section
- the content is one item in a set: Cards
- the content folds open and closed: Accordion
Markup
Variants
The standard action goes right after the head. The float action goes first in the head: .nds-section-action:first-child is the float action. Primary, Gradient and Neutral write one change on the section: the data-theme words.
| Group | Option | Markup | On element | Use |
|---|---|---|---|---|
| Structure | Standard (default) (id: standard) | — | — | A wrapper that holds the head and the body. Start here |
| Structure | Title icon (id: icon) | canon #section-icon |
— | A featured icon before the title text. Wrap the text in a <span> |
| Structure | Horizontal (id: horizontal) | canon #section-horizontal |
— | The head beside the body on a desktop. The action goes in the head, after the description |
| Structure | Stacked (id: stacked) (hint: Several titled parts in one section) | canon #section-stacked |
— | Several wrappers in one section, on one background |
| Structure | Profile (id: profile) | canon #section-profile |
— | A person: a photo in nds-section-image, the name as the title, the role, a contact action and the details in a definition list |
| Structure | Breakout (id: breakout) (hint: A body that runs to the section edges) | canon #section-breakout |
— | A body after the wrapper, with nds-breakout, that runs one page gutter past the content on each side: to the screen edge up to the max width. Beside a side menu it stays in the content column. For a swiper or a wide image |
| Action | None (default) | — | — | No action |
| Action | Standard (not: horizontal, stacked, profile, breakout) | canon #section-action |
.nds-section-head (after) |
Beside the head on a desktop. On a phone it takes its own row, and each button is full width |
| Action | Float (not: horizontal, stacked, profile, breakout) (hint: In the end corner of the head, beside the title) | canon #section-float-action |
.nds-section-head (start) |
In the head, first. It sits in the end corner, and the title and the description wrap around it |
| Action | Dual (not: horizontal, stacked, profile, breakout) (hint: A float action and a standard action together) | canon #section-float-action |
.nds-section-head (start) |
A float action and a standard action. The standard action then takes its own row |
| Action | Dual (not: horizontal, stacked, profile, breakout) (hint: A float action and a standard action together) | canon #section-action-secondary |
.nds-section-head (after) |
A float action and a standard action. The standard action then takes its own row |
| Float action (any) | Icon only on phones (not: horizontal, stacked, profile, breakout) | [data-hidden="sm sr"] |
.nds-section-action:first-child .nds-btn > .nds-label |
Hides the button labels below 600px, and each button goes square. Each button needs an icon. The label stays as the accessible name |
| Float action (any) | Own row on phones (not: horizontal, stacked, profile, breakout) | .nds-wrap |
.nds-section-action:first-child |
Moves the float action under the description below 600px |
| Image | Image (not: horizontal, stacked, profile) | canon #section-image |
.nds-section-wrapper (start) |
A small image before the head. Set its size with width and height. The head centers on it. For a person, use an avatar: see Profile |
| Layout | Center | .nds-center |
.nds-content-section:not(.nds-horizontal) |
Centers the head, the action and the body |
| Color | Default (default) | — | — | The page background |
| Color | Primary | [data-theme="dark oncolor primary"] |
.nds-content-section |
A deep primary background, for one section that must stand out. The components inside take their on-color looks |
| Color | Gradient | [data-theme="dark oncolor primary gradient"] |
.nds-content-section |
A gradient from deep primary to primary. The components inside take their on-color looks |
| Color | Neutral | [data-theme="dark neutral"] |
.nds-content-section |
A dark neutral background. The components inside take their dark-mode colors |
| Color | Brand | [data-theme="primary"] |
.nds-content-section |
A light brand tint with an inset shadow. primary without dark is the tint, in light and dark mode |
| Color | Ghost (hint: No background, border or shadow) | .nds-ghost |
.nds-content-section |
No background, border or shadow, in every layout |
Behavior
No Wrapper
A section with no action and no image can leave out nds-section-wrapper: its nds-section-head and nds-section-body then sit straight in the section. It looks the same as a section with a wrapper.
Horizontal Layout
nds-horizontal on the section makes the wrapper a grid of two columns at 960px and wider: the head, then the body. Below 960px the wrapper stacks again. Add nds-grid to the wrapper to set the column widths with --max-track: see Grid.
Stacked Wrappers
Each nds-section-wrapper after the first starts a new titled block, with --section-wrapper-gap above it. The blocks share the section background. In card view they are one card, and with stripes they are one stripe. Both are set on the page, not on the section: see Page Layout.
Breakout
A body with nds-breakout cancels the section’s side padding, so its content runs to the section edges. Put it after the wrapper, as a direct child of the section, not inside the wrapper. nds-full-width on an element in a section goes further, to the edges of the screen. The two differ where the section is narrower than the screen, such as beside a side menu.
Standard Action
A nds-section-action after the head sits beside it on a desktop, at the top. Below 600px it takes its own row, and each button is full width. In the body, at any depth, its buttons are full width below 600px too. As a direct child of the body, it keeps 32px of space above and below it, as a block does.
Float Action
A nds-section-action that is the first child of the head floats to the end corner. The title and the description wrap around it, so it takes no row of its own. The buttons stack in a column and share one width. In a centered or horizontal section it does not float: it goes under the description. Write data-hidden="sm sr" on each button’s label to show only the icons below 600px, where each button goes square, or add nds-wrap to move it under the description there.
Dual Action
A section can hold a float action and a standard action. The standard action then takes its own row on every screen, under the head.
Image
A nds-section-image before the head holds a small image, a logo, an illustration or an avatar. It sits beside the head, and the head centers on it. When the head would get narrower than 13rem, the image moves above it, and a wide image shrinks to fit the section. An avatar in it is 120px, and 80px below 600px.
Center
nds-center stacks the wrapper in one column and centers the head, the action and the body. A title icon goes above the title and is 48px.
Background Colors
The fill words in data-theme paint a dark background, and the section text takes the on-color text colors. dark oncolor primary paints deep primary and dark oncolor primary gradient paints the gradient: the buttons, fields and other components inside take their on-color looks. See Color Areas. dark neutral paints dark neutral: the components take their dark-mode colors. See Dark Areas. primary without dark paints the light brand tint with an inset shadow, and the components keep their colors. The classes nds-primary, nds-gradient-primary, nds-neutral and nds-brand still paint the same backgrounds but are deprecated and go in v3. The gradient runs at -45deg, and at 45deg on an LTR page. A section with a background color is never striped: see Page Layout.
Built-in Features
-
Progressive Structure
Start with a head and a body. Add an action, an image or a breakout body only when the content needs one.
-
Layout Aware
The page layout sets the section spacing. A desktop page with no side column gets more space above and below each section, and card view shows each section as a card.
-
Fluid Typography
The title and the subtitle sizes scale between phone and desktop. The title, subtitle and description stop at 720px wide, for a readable line length.
-
High Contrast
In high contrast mode every section, including a colored one, takes the high contrast background and text colors.
-
Off-Screen Sections
While the page loads, the browser skips the style and layout of a section that is not near the screen. It draws them later, one at a time, when it is idle or when the page scrolls near one. After it first draws, the section stays a normal section. The first two sections and a Side Info section always draw.
Best Practices
- Put each distinct part of a page in its own section, in
nds-content. - Do not put a section inside a section. Use a block to divide a section body. Stack wrappers when each part needs its own title.
- Stack wrappers only in card view or on a striped page, where the parts must share one surface.
- Leave a stacked section without
nds-flexand--gap. The section already spaces its wrappers, so a gap doubles every break. Set--section-wrapper-gapto change the space. - Use a horizontal section where a short text and an image sit side by side, such as a feature or a call to action.
- Put a picture in
nds-section-image, before the head: a photo, an avatar, a logo, a cover or an illustration. A picture never goes in the title. - Put an icon that marks the title in the title: a featured icon with
nds-section-icon, before the text. Only a status section puts an icon before the head. - Striping counts sections, not wrappers. When you merge sections into one, check the stripes of the sections below it.
- Use a float action for a secondary action when the head has room. Use a standard action for a main call to action.
- Use a section action only for an action on that section’s content. Put an action for the whole page, such as a link back to a list, in its own section. Put the section action in the head or right after it; put it in the body only when it acts on the content just above it.
- Give each button whose label has
data-hiddenan icon. Without one, the button is empty on a phone. - Use a background color on one section at a time. Two dark sections in a row read as one block.
- Use a breakout body for a swiper or a wide image, not for text.
- Use
nds-fullon a title or a description only for short text. Long lines are hard to read. - Put two or more parts of a section body in a grid, a flex or a block. The section body is a plain block, so it puts no space between its children.
- In your own
ResizeObserver, change the height of a section’s content only after the section hasdata-nds-drawn. Before that, the browser reports a “ResizeObserver loop” error. - Right after the page shows, a
scrollIntoView()call of yours can stop short of a far section. A link to#idon the same page always scrolls to the right place.
API
Other Classes
| Class | Element | Effect |
|---|---|---|
nds-section-subtitle |
A <p> in .nds-section-head, after the title |
A line under the title, larger than the description |
nds-section-brief |
A <p> in .nds-section-head |
One short line in semibold. The hero uses it |
nds-section-meta |
A <div> in .nds-section-head |
A row that holds a nds-section-tags and a nds-section-rating. The hero uses it |
nds-full |
.nds-section-title, .nds-section-subtitle or .nds-section-description |
Removes the 720px width limit |
nds-full-width |
Any element in a section | Runs to the edges of the screen, past the section padding |
nds-section-icon |
A featured icon in .nds-section-title, before the text. In a status section, an element before .nds-section-head |
In the title, an icon that grows with the title. In a status section, the box that holds the feedback chip |
CSS Custom Properties
Set these on .nds-content-section. The block title properties are on the Block page.
| Property | Default | Controls |
|---|---|---|
--section-bg |
var(--background-default) |
Background color. A color class changes the default |
--section-shadow |
none |
Shadow |
--section-border |
none |
Border |
--section-border-radius |
0 |
Corner radius |
--section-title-color |
var(--text-display) |
Title color |
--section-subtitle-color |
var(--text-secondary-paragraph) |
Subtitle color |
--section-description-color |
var(--text-primary-paragraph) |
Description color |
--section-text-color |
inherit |
Text color of everything else in the section |
--section-padding-block |
var(--spacing-5xl) |
Top and bottom padding. On a desktop page with no side column, the layout sets it to var(--spacing-7xl) |
--section-padding-block-start |
var(--section-padding-block) |
Top padding |
--section-padding-block-end |
var(--section-padding-block) |
Bottom padding |
--section-margin-block-start |
0 |
Top margin |
--section-margin-block-end |
0 |
Bottom margin |
--section-col-gap |
var(--spacing-xl) |
Gap between the image, the head and the action. Also the space around a float action |
--section-row-gap |
var(--spacing-4xl) |
Gap between the rows of a wrapper |
--section-wrapper-gap |
var(--spacing-6xl) |
Space above each stacked wrapper |
--section-title-FS |
var(--typo-display-clamp-md-FS) |
Title font size. Card view uses var(--typo-display-clamp-sm-FS) |
--section-title-LH |
var(--typo-display-clamp-md-LH) |
Title line height |
--section-title-MB |
var(--typo-display-clamp-md-MB) |
Space under the title |
--section-icon-size |
var(--section-title-FS), 48px when centered |
Height of the title icon |
--section-subtitle-FS |
var(--typo-text-clamp-lg-FS) |
Subtitle font size |
--section-subtitle-LH |
var(--typo-text-clamp-lg-LH) |
Subtitle line height |
--section-subtitle-MB |
var(--section-title-MB) |
Space under the subtitle |
--section-description-FS |
var(--typo-text-lg-FS) |
Description font size |
--section-description-LH |
var(--typo-text-lg-LH) |
Description line height |
--section-description-MB |
var(--spacing-2xl) |
Space under the description |
--gradient-angle |
-45deg, 45deg on an LTR page |
Direction of a gradient background: data-theme="… primary gradient" or nds-gradient-primary |
--gap |
var(--spacing-6xl) |
Gap between the columns of a horizontal section |
JavaScript
Sections have no methods or events. The core script writes data-nds-drawn on a section the first time the browser draws it. Do not set it yourself.