LayoutSection
Searchastronomic.dev# Section For each band of a page, so every part of the page has the same space above and below, on the page or on a light gray band. Static: no JavaScript. ## Usage ```astro import Section from "@astronomic-dev/ui/components/Section.astro"; ``` ## Examples ### Page bands Each Section has the section space above and below. Two page sections sit one section space apart; a band (tone="surface-2") pads both sides. ```astro --- import Button from "@astronomic-dev/ui/components/Button.astro"; import Container from "@astronomic-dev/ui/components/Container.astro"; import Field from "@astronomic-dev/ui/components/Field.astro"; import Input from "@astronomic-dev/ui/components/Input.astro"; import Section from "@astronomic-dev/ui/components/Section.astro"; --- <div> <Section aria-labelledby="section-services" data-section-sample="services"> <Container size="md"> <h3 id="section-services" class="m-0 text-2xl font-semibold">Services</h3> <p class="m-0 mt-2 text-muted">Brand identity, websites and design support.</p> </Container> </Section> <Section as="div" tone="surface-2" data-section-sample="band"> <Container size="md"> <h3 class="m-0 text-2xl font-semibold">Newsletter</h3> <p class="m-0 mt-2 text-muted">A band: tone="surface-2", the light page fill.</p> <div class="mt-5 flex flex-wrap items-end gap-3"> <Field label="Email" for="section-band-email"> <Input id="section-band-email" name="email" type="email" autocomplete="email" /> </Field> <Button variant="secondary" type="button">Subscribe</Button> </div> </Container> </Section> <Section aria-labelledby="section-work" data-section-sample="work"> <Container size="md"> <h3 id="section-work" class="m-0 text-2xl font-semibold">Work</h3> <p class="m-0 mt-2 text-muted">A page section after the band pads both sides.</p> </Container> </Section> <Section as="div" data-section-sample="about"> <Container size="md"> <p class="m-0 text-muted">A page section right after a page section: one section space between them, not two.</p> </Container> </Section> </div> ``` ## Props ### Section | Prop | Type | Default | Description | | --- | --- | --- | --- | | `as` | `HTMLTag` | `"section"` | The element to render, such as div or article. | | `tone` | `"page" \| "surface-2"` | `"page"` | The surface the section sits on. `surface-2` is the light page fill, a band; text, Buttons and the focus ring stay the page's. A page section right after a page section drops its top padding. For a filled band use `tone`: a fill set through `class` loses its top padding after another Section. | | `class` | `string` | None | More classes, merged with cn(), so yours win on conflicts. | | Slot | Description | | --- | --- | | `default` | The content, usually a Container. | Any other attribute goes on the rendered element. ## Accessibility - Renders a <section>. With no name it is not a landmark, so it adds nothing for a screen reader. - Pass aria-labelledby with the id of its heading to make it a region landmark. Do that only for the few bands a reader would jump to. - Use as="div" when the band is only spacing, with no heading of its own.
Section
FreeFor each band of a page, so every part of the page has the same space above and below, on the page or on a light gray band.
- File
- Section.astro
- Group
- Layout
- Kind
- Static: no JavaScript
- Examples
- 1
Examples
Drag the orange handle to set the width. Frames get real breakpoints.
- Static
- Interactive
- Framed
Page bands
Each Section has the section space above and below. Two page sections sit one section space apart; a band (tone="surface-2") pads both sides.
Services
Brand identity, websites and design support.
Newsletter
A band: tone="surface-2", the light page fill.
Work
A page section after the band pads both sides.
A page section right after a page section: one section space between them, not two.
Force statemain.astro
examples/section/main.astro
---
import Button from "@astronomic-dev/ui/components/Button.astro";
import Container from "@astronomic-dev/ui/components/Container.astro";
import Field from "@astronomic-dev/ui/components/Field.astro";
import Input from "@astronomic-dev/ui/components/Input.astro";
import Section from "@astronomic-dev/ui/components/Section.astro";
---
<div>
<Section aria-labelledby="section-services" data-section-sample="services">
<Container size="md">
<h3 id="section-services" class="m-0 text-2xl font-semibold">Services</h3>
<p class="m-0 mt-2 text-muted">Brand identity, websites and design support.</p>
</Container>
</Section>
<Section as="div" tone="surface-2" data-section-sample="band">
<Container size="md">
<h3 class="m-0 text-2xl font-semibold">Newsletter</h3>
<p class="m-0 mt-2 text-muted">A band: tone="surface-2", the light page fill.</p>
<div class="mt-5 flex flex-wrap items-end gap-3">
<Field label="Email" for="section-band-email">
<Input id="section-band-email" name="email" type="email" autocomplete="email" />
</Field>
<Button variant="secondary" type="button">Subscribe</Button>
</div>
</Container>
</Section>
<Section aria-labelledby="section-work" data-section-sample="work">
<Container size="md">
<h3 id="section-work" class="m-0 text-2xl font-semibold">Work</h3>
<p class="m-0 mt-2 text-muted">A page section after the band pads both sides.</p>
</Container>
</Section>
<Section as="div" data-section-sample="about">
<Container size="md">
<p class="m-0 text-muted">A page section right after a page section: one section space between them, not two.</p>
</Container>
</Section>
</div>Minimal · Light