Main
A page content container that fills the viewport below the app header. Its minimum height is calc(100svh - var(--ui-header-height, 0px)),
the same variable Header, Footer, and Error share,
so the footer never creeps above the fold on short pages.
Basic Usage
Place Main between Header and Footer in your root layout.
The demo below caps the height so it fits the page; in a real layout the container stretches to the viewport.
Main content. In a real layout this area is at least 100svh - 4rem tall.
<script lang="ts">
import { Header, Main, Footer } from 'sv5ui';
</script>
<Header title="Acme" />
<Main>
<!-- Page content. The container is at least
100svh minus the header height tall. -->
</Main>
<Footer>
<p>Copyright 2026 Acme Inc.</p>
</Footer>The Height Contract
sv5ui/theme.css defines --ui-header-height: 4rem.
Header consumes it for its own height, and Main / Error subtract it from 100svh.
If your app renders no header, set the variable to 0px so Main fills the whole viewport.
Main fills calc(viewport - 4rem)
The frame stands in for the viewport, so the demo subtracts from 14rem instead of 100svh.
Toggle the header: the total height stays constant because both pieces read the same variable.
/* theme.css ships --ui-header-height: 4rem.
If your app has no <Header>, zero it out so
Main fills the whole viewport. */
:root {
--ui-header-height: 0px;
}Custom Header Height
Change the variable once and every app shell component stays in sync. See the Theming guide for the full list of CSS variables.
Main subtracts 4rem automatically
/* A taller header: set the variable once and
Header, Main, and Error all stay in sync. */
:root {
--ui-header-height: 5rem;
}Render as Another Element
Main renders a <main> landmark by default.
If your layout already provides one, switch the element with as to keep the HTML valid.
Rendered as a plain <div>.
<!-- Render as a different element when your layout
already provides the <main> landmark. -->
<Main as="div" class="bg-surface-container-low">
...
</Main>UI Slots
Use the `ui` prop to override classes on internal elements.
| Slot | Description |
|---|---|
root | The container element. Carries the `min-h-[calc(100svh-var(--ui-header-height,0px))]` height contract |
Props
| Prop | Type | Default |
|---|---|---|
as | keyof HTMLElementTagNameMap | 'main' |
ref | HTMLElement | null | null |
class | string | - |
ui | Record<Slot, Class> | - |