Layout & Containers
Section
A full-width band of a page: an optional eyebrow, heading and description above its content, inside a centred container.
Preview
Section titled “Preview”<nana-section
eyebrow="Pricing"
heading="One plan, every feature"
description="Pay for the units you manage. Add or remove them any month."
align="center"
spacing="sm"
>
<div style="display: flex; justify-content: center">
<nana-button>Start free trial</nana-button>
</div>
</nana-section> Pricing
One plan, every feature
Pay for the units you manage. Add or remove them any month.
Questions before you start?
<script lang="ts">
import { NanaSection } from '$lib/components/ui/section';
import { NanaButton } from '$lib/components/ui/button';
</script>
<div class="w-full overflow-hidden rounded-lg border border-line">
<NanaSection
eyebrow="Pricing"
heading="One plan, every feature"
description="Pay for the units you manage. Add or remove them any month."
align="center"
spacing="sm"
>
<div class="flex justify-center"><NanaButton>Start free trial</NanaButton></div>
</NanaSection>
<NanaSection tone="inverse" spacing="sm" heading="Questions before you start?" level={3}>
<NanaButton variant="secondary">Talk to us</NanaButton>
</NanaSection>
</div> Installation
Section titled “Installation”Install the package for a versioned dependency:
npm install @nana-tec/ui-componentsOr copy the source in and own it:
npx @nana-tec/ui add section --framework web-componentsnpx @nana-tec/ui add section --framework svelteLands 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.
Accessibility
Section titled “Accessibility”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.
Tone, spacing and width
Section titled “Tone, spacing and width”| Option | Values | What it changes |
|---|---|---|
tone | default, muted, inverse | The band’s background: the page surface, the muted surface, or the text colour with the surface colour on it |
spacing | none, sm, md, lg | Space above and below |
width | narrow, default, wide, full | How wide the container grows |
align | start, center | Alignment 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
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
align | align | SectionAlign | 'start' | Alignment of the header |
description | description | string | '' | Text under the heading |
eyebrow | eyebrow | string | '' | Short label above the heading |
heading | heading | string | '' | The heading; also names the section as a region |
level | level | SectionLevel | 2 | Heading level, so the section sits correctly in the page outline |
spacing | spacing | SectionSpacing | 'md' | Space above and below the content |
tone | tone | SectionTone | 'default' | Background and text colour of the band |
width | width | SectionWidth | 'default' | How wide the container grows |
Slots
| Slot | Description |
|---|---|
(default) | The section's content |
CSS parts
| Part | Description |
|---|---|
::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
| Property | Description |
|---|---|
--nana-section-bg | Background colour |
--nana-section-color | Text colour |
--nana-section-padding | Space above and below the content |
--nana-section-max-width | Width of the container |
--nana-section-gutter | Space either side of the container |
NanaSection
| Prop | Type | Default |
|---|---|---|
id | string | uid('nana-section') |
tone | SectionTone | 'default' |
spacing | SectionSpacing | 'md' |
width | SectionWidth | 'default' |
align | SectionAlign | 'start' |
level | SectionLevel | 2 |
eyebrow | Text | |
heading | Text | |
description | Text | |
children | Snippet |
Also accepts Omit<HTMLAttributes<HTMLElement>, 'class' | 'id'>.