Skip to content
Nana UI

Layout & Containers

Section

A full-width band of a page: an optional eyebrow, heading and description above its content, inside a centred container.

View .md Download
Start free trial

Pricing

One plan, every feature

Pay for the units you manage. Add or remove them any month.

Questions before you start?

Install the package for a versioned dependency:

npm install @nana-tec/ui-components

Or copy the source in and own it:

npx @nana-tec/ui add section --framework web-components
npx @nana-tec/ui add section --framework svelte

Lands in src/lib/components/ui/section/ as NanaSection.svelte, with its tones, spacing and widths in styles/section.ts beside it. Requires Tailwind v4.

Import the autoloader once, in your app's entry point. Every <nana-*> tag then works anywhere, and each component downloads only the first time a page uses it:

import "@nana-tec/ui-components/autoloader";
import "@nana-tec/ui-components/theme";

The second line gives every component the Nana look and the design tokens behind it. Leave it out to style the components entirely yourself.

Import a component directly when it must be ready at once: on screen at first paint, or when you call its methods straight away. The two mix freely:

import "@nana-tec/ui-components/section";

Copied in with npx @nana-tec/ui add section? Import your project's own @/lib/nana-ui/autoloader.js once instead; the CLI keeps it up to date.

<nana-section eyebrow="Features" heading="Everything you need to launch" align="center">
<p>Your content.</p>
</nana-section>

The eyebrow, heading and description are attributes; everything else goes in the default slot.

<script lang="ts">
import { NanaSection } from '$lib/components/ui/section';
</script>
<NanaSection id="features" eyebrow="Features" heading="Everything you need to launch">
<p>Your content.</p>
</NanaSection>
<NanaSection tone="inverse">
{#snippet heading()}Built for <em>teams</em>{/snippet}
<p>Pass a snippet when the heading needs markup.</p>
</NanaSection>

eyebrow, heading and description each take a string or a snippet. Pass id to link to the section, as in #features.

A section with a heading is a landmark region named by that heading, so screen reader users can jump to it. Without a heading it is a plain section and names nothing. The heading is an h2; set level to 3 or 4 when the section sits inside another one, so the page outline stays in order.

OptionValuesWhat it changes
tonedefault, muted, inverseThe band’s background: the page surface, the muted surface, or the text colour with the surface colour on it
spacingnone, sm, md, lgSpace above and below
widthnarrow, default, wide, fullHow wide the container grows
alignstart, centerAlignment of the header

inverse swaps the theme’s text and surface colours, so on a light theme it is a dark band and on a dark theme a light one.

Properties

PropertyAttributeTypeDefaultDescription
alignalignSectionAlign'start'Alignment of the header
descriptiondescriptionstring''Text under the heading
eyebroweyebrowstring''Short label above the heading
headingheadingstring''The heading; also names the section as a region
levellevelSectionLevel2Heading level, so the section sits correctly in the page outline
spacingspacingSectionSpacing'md'Space above and below the content
tonetoneSectionTone'default'Background and text colour of the band
widthwidthSectionWidth'default'How wide the container grows

Slots

SlotDescription
(default)The section's content

CSS parts

PartDescription
::part(base)The <section> element
::part(container)The centred, width-limited wrapper
::part(header)The eyebrow, heading and description
::part(eyebrow)The short label above the heading
::part(heading)The heading
::part(description)The text under the heading
::part(content)The wrapper around the slotted content

CSS custom properties

PropertyDescription
--nana-section-bgBackground colour
--nana-section-colorText colour
--nana-section-paddingSpace above and below the content
--nana-section-max-widthWidth of the container
--nana-section-gutterSpace either side of the container

NanaSection

PropTypeDefault
idstringuid('nana-section')
toneSectionTone'default'
spacingSectionSpacing'md'
widthSectionWidth'default'
alignSectionAlign'start'
levelSectionLevel2
eyebrowText
headingText
descriptionText
childrenSnippet

Also accepts Omit<HTMLAttributes<HTMLElement>, 'class' | 'id'>.