Components / More
Section
A full-width band of a page: a background, space above and below, and the content in the page column. Stack Sections to build a landing or documentation page that scrolls as a document.
When to useLink to "When to use"
- The parts of a landing page: hero, features, pricing, a call to action, each its own band.
- Alternating backgrounds on a long documentation page, to group related content.
Use something else when:
- you only need the page column, with no background or vertical rhythm: Container
- you want a bordered box inside the column: Card
- you are building an app frame with a side navigation: AppShell
UsageLink to "Usage"
import { Heading, Section, SiteFooter, SiteHeader } from "@arshad-shah/cynosure";
<SiteHeader brand="Acme" nav={nav} />
<main id="main">
<Section as="header">…hero…</Section>
<Section variant="soft" id="features" aria-labelledby="features-heading">
<Heading id="features-heading">Features</Heading>
</Section>
<Section variant="accent" size="md">…</Section>
</main>
<SiteFooter columns={columns} />Width and full bleedLink to "Width and full bleed"
A Section fills its parent's width. For bands from edge to edge of the window, place Sections at the top level of the page (or directly in main), not inside a Container: each brings its own Container for the content. size sets that column's width; contained={false} drops it.
PaddingLink to "Padding"
paddingBlock takes a space token. The default is the --cy-section-padding-block token, twice space 10.
PropsLink to "Props"
| Prop | What it does | Type | Default |
|---|---|---|---|
variant | The band's background: plain (none, the page shows through), surface, soft (a quiet tint) or accent (a soft tint of the accent colour). Text colours stay readable on each. Default "plain". | "plain" | "accent" | "soft" | "surface" | "plain" |
paddingBlock | Space token for the padding above and below the content. Default: the --cy-section-padding-block token. | Space | the `--cy-section-padding-block` token |
contained | Put the content in a centred Container (the page column). false lets it fill the band. Default true. | boolean | true |
size | Widest the inner Container gets (its size). Ignored when contained is false. Default "lg". | "sm" | "md" | "lg" | "full" | "xl" | "lg" |
as | The element rendered. A section is a region landmark only when it has a name (aria-labelledby or aria-label). Default "section". | "div" | "section" | "article" | "aside" | "header" | "footer" | "section" |
id | Set on the root element: the target of in-page links such as #pricing. | string | |
aria-labelledby | Names the section, usually the id of its heading. | string | |
aria-label | Names the section when it has no visible heading. | string | |
role | An ARIA role for the root, when the element's own role is not the right one. | AriaRole | |
className | Added to the root element, for layout. | string | |
style | Layout only. Restyle through --cy-section-* tokens. | CSSProperties | |
children | The section's content. | ReactNode | |
data-testid | Set on the root element, for tests. | string |
Generated from the type definitions in @arshad-shah/cynosure 0.5.0.
Behaviour and accessibilityLink to "Behaviour and accessibility"
Section has no keyboard behaviour of its own.
- Landmarks: a
sectionis a region landmark only when it has a name: passaria-labelledbywith the id of its heading.as="aside"is a complementary landmark.role,aria-labelandidare set on the root. - In-page links:
idmakes the Section the target of a link such as#pricing. - Colours: text keeps the ink colour on every variant. In forced-colours mode, bands with a background get a line above and below instead.
- Nesting: a nested Section gets its own default padding.
TouchLink to "Touch"
Nothing pressable of its own; what you put in keeps its own hit areas.
ThemingLink to "Theming"
| Token | What it sets | Default |
|---|---|---|
--cy-section-padding-block | Padding above and below when paddingBlock is not set | calc(var(--cy-space-10) * 2) |
--cy-section-surface | Background of variant="surface" | --cy-color-surface |
--cy-section-soft | Background of variant="soft" | --cy-color-soft |
--cy-section-accent | Background of variant="accent" | --cy-color-accent-soft |
createTheme({ components: { section: { paddingBlock: "6rem" } } });RelatedLink to "Related"
Container · SiteHeader · SiteFooter · PageHeader · Card
These examples run Cynosure 0.5.0 (commit 50ce30b), the version on npm.