Layout
Page structure, sidebar, collapsing and responsive navigation.
When to use
Layout defines the structure of the page: header, content, footer and side navigation. Svelte uses separate LayoutHeader, LayoutContent, LayoutFooter and LayoutSider. Layout can be nested so that the header covers the entire screen or only the area next to the menu.
The component defines the framework, and the application organizes the menu, content and routing. The state of Menu inside Sider is consistent with its folding through the context.
Structure and side panel
Place parts of the page in Layout according to their role. hasSider explicitly specifies a horizontal structure for SSR; For a complex conditional composition, this helps preserve the original layout before registering child sections.
| Problem | Setting | Example |
|---|---|---|
| Assemble the page frame | Family Layout |
Basic structures |
| Place a header above all sections | Nested Layout |
Header above the side menu |
| Collapse navigation | LayoutSider.collapsible, bind:collapsed |
Rollable panel |
| Move control button | trigger={null}, external handler |
Own button |
| Change panel to fit screen width | breakpoint |
Adaptive panel |
width sets the normal Sider width, collapsedWidth sets the collapsed width. Collapsed supports bind; defaultCollapsed specifies the initial local state. onCollapse reports the value and reason of clickTrigger/responsive.
trigger=null removes the standard button. With collapsedWidth=0, the panel can disappear completely, leaving a special expand button; zeroWidthTriggerStyle styles it. For an external trigger, keep the name accessible and associated with the collapsed state.
Adaptability and positioning
breakpoint uses the width of the viewport. onBreakpoint reports threshold crossing, and onCollapse receives the reason responsive. This state is different from manually pressing a button; adaptive example shows both events.
hasSider is also recognized for direct Sider via CSS, but an explicit prop is useful for nested or conditional sections. Keep navigation and content area names accessible regardless of panel width.
Panel on top of content is a CSS application composition, not a separate Layout mode. The same applies to pinned cap and pinned menu: customize the position, height, padding of the main content and custom scroll area.
theme=light/dark for Sider sets the design of the side area itself. This is not switching the entire ConfigProvider theme. The Menu inside it uses the Sider context; For a separate Menu outside the panel, its own settings are applied.
Design and DOM
Sections support class/style, rootClassName and bind:nativeElement. Sider additionally has classNames/styles available for root/body by object or function from props; styles contains CSS strings. Sider design shows both areas.
theme.components.Layout is connected to Layout, its sections and Sider. Design tokens set the background, header/footer sizes and paddings, panel colors and trigger. Local class/style and semantic styles specify the design after the theme.
ConfigProvider.layout accepts LayoutConfig with class and style, without semantic slots. Record applies to Layout containers, including nested ones; Header, Content, Footer and Sider do not receive it directly. undefined inherits the parent setting, and its object, including {}, replaces the entire record. The general and local design classes are added together; style is applied after theme variables and before local style.
General settings show inheritance, local padding, resetting record in nested provider and updating indents with saving draft and collapsed. CSS text properties such as color can be inherited by child sections using normal browser rules - it is not assigning a layout-record to those sections.
Layout.prefixCls and LayoutSider.prefixCls are set independently. A non-empty local prop takes precedence over the global ConfigProvider.prefixCls. The empty string and undefined use the provider's base prefix with the suffix layout or layout-sider; without configuration these are ant-layout and ant-layout-sider. The container's root classes and states change, and the Sider's body and trigger also change.
LayoutHeader, LayoutContent and LayoutFooter accept their own prefixCls: this is a full section class, without an automatic suffix. For example, prefixCls="region" gives the class region, not region-header. The empty line inherits the base prefix ConfigProvider with the suffix layout-header/content/footer. A container's local prefix does not change the classes of its sections; common prefixCls applies to the entire family. ConfigProvider.layout still only contains class/style.
Section prefixes show independent and shared classes Header/Content/Footer, returning standard classes and saving draft. Inside Layout, sections inherit its variables, including the owner's style; without Layout they get their own theme values even with SSR. The local style of the section retains priority.
Local prefixes switch without re-creating the DOM, losing draft, highlighting, focus and collapsed. The body and aria-controls identifiers of the button are preserved, the namespace of the --ant-layout-* variables and the ant-layout-css-var marker are not renamed. The direct child Sider is recognized by SSR regardless of the prefix; for a complex composition, still set hasSider explicitly. When collapsedWidth=0, the content becomes inert, and the trigger remains available for expansion.
The header, content and footer retain the native semantics of the corresponding sections. Collapsing changes the available width, so check labels and interactive elements inside the narrow panel. Menu links must retain real href attributes for app navigation.
Examples
Basic structures
Header, content, footer and nested Layout. hasSider explicitly sets the horizontal structure already on the server.
<script lang="ts">
import { Layout, LayoutHeader, LayoutContent, LayoutFooter, LayoutSider } from '@woodger/antd';
</script>
<style>
.preview {
min-width: 0;
overflow: hidden;
border: 1px solid var(--ant-color-border-secondary);
border-radius: 8px;
isolation: isolate;
transform: translate(0);
}
.preview :global(.ant-layout-header) {
height: 40px;
padding-inline: 12px;
color: white;
line-height: 40px;
}
.preview :global(.ant-layout-content) {
min-width: 0;
padding: 16px;
overflow-wrap: anywhere;
}
.preview :global(.ant-layout-footer) { padding: 12px; }
</style>
<div class="preview">
<Layout><LayoutHeader>
{("Hat")}
</LayoutHeader><LayoutContent>
{("Contents")}
</LayoutContent><LayoutFooter>
{("Basement")}
</LayoutFooter></Layout>
</div>
<div class="preview" style="margin-top:16px">
<Layout
hasSider
><LayoutSider
width={80}
theme="light"
>
<p>
{("Menu")}
</p>
</LayoutSider><Layout><LayoutHeader>
{("Hat")}
</LayoutHeader><LayoutContent>
{("Contents")}
</LayoutContent><LayoutFooter>
{("Basement")}
</LayoutFooter></Layout></Layout>
</div>
<div class="preview" style="margin-top:16px">
<Layout><LayoutHeader>{("Hat")}</LayoutHeader><Layout
hasSider
><LayoutContent>
{("Contents")}
</LayoutContent><LayoutSider width={80} theme="light">
<p>
{("Menu")}
</p>
</LayoutSider></Layout><LayoutFooter>
{("Basement")}
</LayoutFooter></Layout>
</div>
Work area of the selected section.
Header, contents and footer
Horizontal Menu controls the current section of the example. There are no links to external sites inside the card.
<script lang="ts">
import { Layout, LayoutHeader, LayoutContent, LayoutFooter, Menu } from '@woodger/antd';
let selected = $state('overview');
</script>
<style>
.preview {
min-width: 0;
overflow: hidden;
border: 1px solid var(--ant-color-border-secondary);
border-radius: 8px;
isolation: isolate;
transform: translate(0);
}
.preview :global(.ant-layout-header) {
height: 40px;
padding-inline: 12px;
color: white;
line-height: 40px;
}
.preview :global(.ant-layout-content) {
min-width: 0;
padding: 16px;
overflow-wrap: anywhere;
}
.preview :global(.ant-layout-footer) { padding: 12px; }
</style>
<div class="preview"><Layout>
<LayoutHeader><Menu mode="horizontal" theme="dark" selectedKeys={[selected]} items={([
{ key: 'overview', label: "Overview" },
{ key: 'api', label: 'API' },
{ key: 'code', label: "Code" }
])} onSelect={info => { selected = info.key; }} /></LayoutHeader>
<LayoutContent><output
aria-label={("Top section Layout")}
>{selected}</output><p>{("Work area of the selected section.")}</p></LayoutContent>
<LayoutFooter>{("Project documentation")}</LayoutFooter>
</Layout></div>
Work area
The header remains common to the two columns.
Header above the side menu
The overall cap covers the entire width. A nested Layout separates the navigation and workspace.
<script lang="ts">
import {
Layout,
LayoutHeader,
LayoutContent,
LayoutFooter,
LayoutSider,
Menu
} from '@woodger/antd';
</script>
<style>
.preview {
min-width: 0;
overflow: hidden;
border: 1px solid var(--ant-color-border-secondary);
border-radius: 8px;
isolation: isolate;
transform: translate(0);
}
.preview :global(.ant-layout-header) {
height: 40px;
padding-inline: 12px;
color: white;
line-height: 40px;
}
.preview :global(.ant-layout-content) {
min-width: 0;
padding: 16px;
overflow-wrap: anywhere;
}
.preview :global(.ant-layout-footer) { padding: 12px; }
</style>
<div class="preview">
<Layout>
<LayoutHeader>{("Documentation")}</LayoutHeader>
<Layout hasSider>
<LayoutSider width={112} theme="light"><Menu mode="inline" items={([{
key: 'start',
label: "Home"
}, { key: 'guide', label: "Help" }])} defaultSelectedKeys={['start']} /></LayoutSider>
<LayoutContent><h4>
{("Work area")}
</h4><p>
{("The header remains common to the two columns.")}
</p></LayoutContent>
</Layout>
<LayoutFooter>{("Basement")}</LayoutFooter>
</Layout>
</div>
Contents of the right column.
Side menu and section footer
The general header is located above the columns. The nested Layout leaves a footer underneath the right workspace.
<script lang="ts">
import {
Layout,
LayoutHeader,
LayoutContent,
LayoutFooter,
LayoutSider,
Menu
} from '@woodger/antd';
</script>
<style>
.preview {
min-width: 0;
overflow: hidden;
border: 1px solid var(--ant-color-border-secondary);
border-radius: 8px;
isolation: isolate;
transform: translate(0);
}
.preview :global(.ant-layout-header) {
height: 40px;
padding-inline: 12px;
color: white;
line-height: 40px;
}
.preview :global(.ant-layout-content) {
min-width: 0;
padding: 16px;
overflow-wrap: anywhere;
}
.preview :global(.ant-layout-footer) { padding: 12px; }
</style>
<div class="preview">
<Layout>
<LayoutHeader>{("Workspace")}</LayoutHeader>
<Layout hasSider>
<LayoutSider width={112} theme="light"><Menu mode="inline" items={([{
key: 'docs',
label: "Lyrics"
}, { key: 'files', label: "Files" }])} defaultSelectedKeys={['docs']} /></LayoutSider>
<Layout><LayoutContent>
<p>
{("Contents of the right column.")}
</p>
</LayoutContent><LayoutFooter>
{("Basement section")}
</LayoutFooter></Layout>
</Layout>
</Layout>
</div>
Roll-up panel
Built-in trigger controls collapsed. Menu inherits the Sider state; labels are returned upon disclosure.
<script lang="ts">
import { Layout, LayoutSider, LayoutContent, Menu } from '@woodger/antd';
let collapsed = $state(false);
</script>
<style>
.preview {
min-width: 0;
overflow: hidden;
border: 1px solid var(--ant-color-border-secondary);
border-radius: 8px;
isolation: isolate;
transform: translate(0);
}
.preview :global(.ant-layout-header) {
height: 40px;
padding-inline: 12px;
color: white;
line-height: 40px;
}
.preview :global(.ant-layout-content) {
min-width: 0;
padding: 16px;
overflow-wrap: anywhere;
}
.preview :global(.ant-layout-footer) { padding: 12px; }
</style>
<div class="preview"><Layout hasSider style="min-height:240px">
<LayoutSider
width={160}
collapsedWidth={48}
collapsible
bind:collapsed
theme="light"
expandLabel={("Expand sidebar")}
collapseLabel={("Collapse sidebar")}
>
<Menu mode="inline" items={([{ key: 'docs', label: "Documents" }, {
key: 'files',
label: "Files"
}])} defaultSelectedKeys={['docs']} />
</LayoutSider>
<LayoutContent><output aria-label={("Side Panel Layout")}>{(collapsed ? "Collapsed" : "Revealed")}</output></LayoutContent>
</Layout></div>
Own button
trigger=null hides the built-in button. The outer Button changes bind:collapsed and communicates the state via aria-expanded.
<script lang="ts">
import { Button, Layout, LayoutSider, LayoutContent } from '@woodger/antd';
let collapsed = $state(false);
</script>
<style>
.preview {
min-width: 0;
overflow: hidden;
border: 1px solid var(--ant-color-border-secondary);
border-radius: 8px;
isolation: isolate;
transform: translate(0);
}
.preview :global(.ant-layout-header) {
height: 40px;
padding-inline: 12px;
color: white;
line-height: 40px;
}
.preview :global(.ant-layout-content) {
min-width: 0;
padding: 16px;
overflow-wrap: anywhere;
}
.preview :global(.ant-layout-footer) { padding: 12px; }
.controls {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 12px;
margin-bottom: 16px;
}
</style>
<div
class="controls"
><Button
aria-expanded={!collapsed}
onclick={() => { collapsed = !collapsed; }}
>{(collapsed ? "Show panel" : "Hide panel")}</Button></div>
<div class="preview">
<Layout hasSider style="min-height:160px">
<LayoutSider
width={120}
collapsedWidth={0}
trigger={null}
bind:collapsed
theme="light"
><p>{("Navigation")}</p></LayoutSider>
<LayoutContent>
{("Access to the button is maintained when the panel width is zero.")}
</LayoutContent>
</Layout>
</div>
The work area remains full width.
Panel on top of content
As in the official example, the overlay is created by the CSS of the application. The width of the work area does not change when the panel is expanded.
<script lang="ts">
import { Button, Layout, LayoutSider, LayoutContent } from '@woodger/antd';
let collapsed = $state(true);
</script>
<style>
.preview {
min-width: 0;
overflow: hidden;
border: 1px solid var(--ant-color-border-secondary);
border-radius: 8px;
isolation: isolate;
transform: translate(0);
}
.preview :global(.ant-layout-header) {
height: 40px;
padding-inline: 12px;
color: white;
line-height: 40px;
}
.preview :global(.ant-layout-content) {
min-width: 0;
padding: 16px;
overflow-wrap: anywhere;
}
.preview :global(.ant-layout-footer) { padding: 12px; }
.controls {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 12px;
margin-bottom: 16px;
}
</style>
<div
class="controls"
><Button
aria-expanded={!collapsed}
onclick={() => { collapsed = !collapsed; }}
>{(collapsed ? "Open overlay" : "Close overlay")}</Button></div>
<div class="preview"><Layout hasSider={false} style="
position: relative;
min-height: 200px;
">
<LayoutSider
width={160}
collapsedWidth={0}
trigger={null}
bind:collapsed
theme="light"
style="
position: absolute;
inset-block: 0;
inset-inline-start: 0;
z-index: 1;
"
><p>{("Navigation on top of the page")}</p></LayoutSider>
<LayoutContent><p>{("The work area remains full width.")}</p></LayoutContent>
</Layout></div>
Change the width of the window.
Adaptive panel
breakpoint=md collapses the panel below 768px. Zero width enables a special trigger; callbacks differentiate between responsive and clickTrigger.
<script lang="ts">
import { Layout, LayoutSider, LayoutContent } from '@woodger/antd';
let broken = $state(false);
let event = $state(("Waiting for change"));
</script>
<style>
.preview {
min-width: 0;
overflow: hidden;
border: 1px solid var(--ant-color-border-secondary);
border-radius: 8px;
isolation: isolate;
transform: translate(0);
}
.preview :global(.ant-layout-header) {
height: 40px;
padding-inline: 12px;
color: white;
line-height: 40px;
}
.preview :global(.ant-layout-content) {
min-width: 0;
padding: 16px;
overflow-wrap: anywhere;
}
.preview :global(.ant-layout-footer) { padding: 12px; }
</style>
<div class="preview">
<Layout hasSider style="min-height:180px">
<LayoutSider width={160} collapsedWidth={0} breakpoint="md" theme="light" expandLabel={("Open responsive panel")} collapseLabel={("Close responsive panel")} onCollapse={(
next,
type
) => {
event = ("" + String((next ? ("Collapsed") : ("Revealed"))) + ": " + String((type)) + "");
}} onBreakpoint={next => {
broken = next;
}}><p>{("Adaptive navigation")}</p></LayoutSider>
<LayoutContent><p>
{("Change the width of the window.")}
</p><output aria-label={("Threshold Layout")}>
{(broken ? "Below md" : "From md")}
</output><p>
<output aria-label={("Reason Layout")}>
{event}
</output>
</p></LayoutContent>
</Layout>
</div>
Document section 1
Document section 2
Document section 3
Document section 4
Document section 5
Document section 6
Fixed hat
position:sticky keeps the header at the top edge of its own scroll area. The main menu of the site remains separate.
<script lang="ts">
import { Layout, LayoutHeader, LayoutContent } from '@woodger/antd';
</script>
<style>
.preview {
min-width: 0;
overflow: hidden;
border: 1px solid var(--ant-color-border-secondary);
border-radius: 8px;
isolation: isolate;
transform: translate(0);
}
.preview :global(.ant-layout-header) {
height: 40px;
padding-inline: 12px;
color: white;
line-height: 40px;
}
.preview :global(.ant-layout-content) {
min-width: 0;
padding: 16px;
overflow-wrap: anywhere;
}
.preview :global(.ant-layout-footer) { padding: 12px; }
.scroller {
height: 200px;
overflow: auto;
}
</style>
<div class="preview">
<div class="scroller" tabindex="0" role="region" aria-label={("Scrolling with Layout header")}>
<Layout><LayoutHeader
style="
position: sticky;
top: 0;
z-index: 1;
"
>{("Fixed hat")}</LayoutHeader><LayoutContent
style="min-height:520px"
>
{#each [1, 2, 3, 4, 5, 6] as number (number)}
<p>{("Document section ")}{(number)}</p>
{/each}
</LayoutContent></Layout>
</div>
</div>
Section contents 1
Section contents 2
Section contents 3
Section contents 4
Section contents 5
Section contents 6
Sticky side menu
Sider remains inside the scroll container thanks to sticky. The example does not use fixed relative to the site window.
<script lang="ts">
import { Layout, LayoutSider, LayoutContent } from '@woodger/antd';
</script>
<style>
.preview {
min-width: 0;
overflow: hidden;
border: 1px solid var(--ant-color-border-secondary);
border-radius: 8px;
isolation: isolate;
transform: translate(0);
}
.preview :global(.ant-layout-header) {
height: 40px;
padding-inline: 12px;
color: white;
line-height: 40px;
}
.preview :global(.ant-layout-content) {
min-width: 0;
padding: 16px;
overflow-wrap: anywhere;
}
.preview :global(.ant-layout-footer) { padding: 12px; }
.scroller {
height: 200px;
overflow: auto;
}
</style>
<div class="preview">
<div class="scroller" tabindex="0" role="region" aria-label={("Scrolling with Layout menu")}>
<Layout
hasSider
style="min-height:520px"
><LayoutSider
width={96}
theme="light"
style="
position: sticky;
top: 0;
height: 180px;
"
><p>{("Menu")}</p></LayoutSider><LayoutContent>
{#each [1, 2, 3, 4, 5, 6] as number (number)}
<p>{("Section contents ")}{(number)}</p>
{/each}
</LayoutContent></Layout>
</div>
</div>
Sider design
root and body are available from LayoutSider. The styles function gets collapsed; the design of the remaining sections is specified via class/style.
<script lang="ts">
import { Button, Layout, LayoutSider, LayoutContent } from '@woodger/antd';
let collapsed = $state(false);
</script>
<style>
.preview {
min-width: 0;
overflow: hidden;
border: 1px solid var(--ant-color-border-secondary);
border-radius: 8px;
isolation: isolate;
transform: translate(0);
}
.preview :global(.ant-layout-header) {
height: 40px;
padding-inline: 12px;
color: white;
line-height: 40px;
}
.preview :global(.ant-layout-content) {
min-width: 0;
padding: 16px;
overflow-wrap: anywhere;
}
.preview :global(.ant-layout-footer) { padding: 12px; }
.controls {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 12px;
margin-bottom: 16px;
}
</style>
<div class="controls">
<Button onclick={() => { collapsed = !collapsed; }}>
{("Change semantic panel")}
</Button>
</div>
<div class="preview"><Layout hasSider style="min-height:160px">
<LayoutSider
width={140}
collapsedWidth={64}
theme="light"
bind:collapsed
trigger={null}
classNames={{ root: 'custom-sider' }}
styles={(
{
props
}
) => ({
root: 'border-inline-end:2px solid #722ed1',
body: `
padding: 12px;
background: ${props.collapsed
? 'var(--ant-color-primary-bg)'
: 'var(--ant-color-fill-quaternary)'};
`
})}
><p>{("Menu")}</p></LayoutSider>
<LayoutContent>{("Local design preserves the Layout structure.")}</LayoutContent>
</Layout></div>
Workspace
Initial review example: adaptive panel and external control.
<script lang="ts">
import {
Button,
Layout,
LayoutSider,
LayoutHeader,
LayoutContent,
LayoutFooter
} from '@woodger/antd';
let collapsed = $state(false);
</script>
<Layout style="min-height:240px">
<LayoutSider theme="light" bind:collapsed trigger={null} breakpoint="md" collapsedWidth={0}>
<nav
aria-label={("Layout example sections")}
><a
href={("#layout")}
>
{("Overview")}
</a>{#if !collapsed}
<p>
{("Planning and tasks")}
</p>
{/if}</nav>
</LayoutSider>
<Layout>
<LayoutHeader
style="
padding-inline: 16px;
color: white;
"
>{("Workspace")}</LayoutHeader>
<LayoutContent style="padding:16px"><Button
onclick={() => { collapsed = !collapsed; }}
aria-expanded={!collapsed}
>{(collapsed ? "Expand menu" : "Collapse menu")}</Button></LayoutContent>
<LayoutFooter style="padding:12px 16px">
{("The panel state is maintained when switching.")}
</LayoutFooter>
</Layout>
</Layout>
General Layout settings
ConfigProvider.layout, local style, reset record and save draft and minimized panel.
<script lang="ts">
import {
Checkbox, ConfigProvider, Input, Layout, LayoutContent, LayoutFooter, LayoutHeader, LayoutSider
} from '@woodger/antd';
let spacious = $state(true);
let collapsed = $state(false);
let draft = $state('');
</script>
<style>
.example, .layouts {
display: grid;
gap: 24px;
}
.preview {
min-width: 0;
overflow: hidden;
border: 1px solid var(--ant-color-border-secondary);
border-radius: 8px;
isolation: isolate;
transform: translate(0);
}
.draft {
display: grid;
gap: 8px;
}
.sider-content {
padding: 12px;
overflow-wrap: anywhere;
}
</style>
<div class="example">
<Checkbox bind:checked={spacious}>{("Spacious Layouts")}</Checkbox>
<ConfigProvider layout={{
class: 'shared-layout',
style: spacious
? `
padding: 16px;
gap: 12px;
`
: `
padding: 8px;
gap: 8px;
`
}}>
<div class="layouts">
<div class="preview">
<Layout aria-label={("Layout with general settings")}>
<LayoutHeader style="
height: 40px;
line-height: 40px;
padding-inline: 12px;
">
{("Draft")}
</LayoutHeader>
<LayoutContent style="
padding: 12px;
min-width: 0;
">
<label
class="draft"
>{("\n Project name\n ")}<Input
aria-label={("Draft layout")}
bind:value={draft}
/>
</label>
</LayoutContent>
<LayoutFooter style="padding: 12px">
{("The setting affects the Layout container.")}
</LayoutFooter>
</Layout>
</div>
<div class="preview">
<Layout aria-label={("Layout with local style")} hasSider class="local-layout"
style="
padding: 20px;
min-height: 140px;
">
<LayoutSider width={100} collapsedWidth={48} theme="light" collapsible bind:collapsed
collapseLabel={("Collapse panel with defaults")} expandLabel={("Expand panel with defaults")}>
<div class="sider-content">{("Menu")}</div>
</LayoutSider>
<LayoutContent style="
padding: 12px;
min-width: 0;
">
<output aria-label={("Layout panel with defaults")}>{(collapsed ? "Collapsed" : "Revealed")}</output>
</LayoutContent>
</Layout>
</div>
<ConfigProvider layout={{}}>
<div class="preview">
<Layout aria-label={("Layout without defaults")}>
<LayoutContent style="padding: 12px">
{("Nested empty record resets the class/style of the provider.")}
</LayoutContent>
</Layout>
</div>
</ConfigProvider>
</div>
</ConfigProvider>
</div>
Local CSS prefixes
Independent prefixCls Layout and Sider, standard sections, draft, collapse and adjacent layout.
<script lang="ts">
import {
Checkbox, Input, Layout, LayoutContent, LayoutFooter, LayoutHeader, LayoutSider
} from '@woodger/antd';
let customLayout = $state(true);
let customSider = $state(true);
let zeroWidth = $state(false);
let collapsed = $state(false);
let draft = $state('');
let layoutPrefix = $derived(customLayout ? 'woodger-layout' : '');
let siderPrefix = $derived(customSider ? 'woodger-sider' : '');
</script>
<style>
.example {
display: grid;
gap: 24px;
}
.controls {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
.preview {
min-width: 0;
overflow: hidden;
border: 1px solid var(--ant-color-border-secondary);
border-radius: 8px;
isolation: isolate;
transform: translate(0);
}
output { overflow-wrap: anywhere; }
</style>
<div class="example">
<div class="controls">
<Checkbox bind:checked={customLayout}>{("Custom Layout prefix")}</Checkbox>
<Checkbox bind:checked={customSider}>{("Own prefix Sider")}</Checkbox>
<Checkbox bind:checked={zeroWidth}>{("Minimize panel to zero")}</Checkbox>
</div>
<div class="preview">
<Layout
prefixCls={layoutPrefix}
aria-label={("Layout with prefix")}
style="min-height: 220px"
>
<LayoutSider
prefixCls={siderPrefix}
aria-label={("Panel with prefix")}
width={128}
collapsedWidth={zeroWidth ? 0 : 48}
theme="light"
collapsible
bind:collapsed
collapseLabel={("Collapse panel with prefix")}
expandLabel={("Expand panel with prefix")}
classNames={{ body: 'prefix-layout-body' }}
styles={{ body: 'padding: 12px' }}
>
<Input aria-label={("Draft panel with prefix")} placeholder={("Draft")} bind:value={draft} />
</LayoutSider>
<Layout style="min-width: 0">
<LayoutHeader style="
height: 40px;
line-height: 40px;
padding-inline: 12px;
">
{("Section")}
</LayoutHeader>
<LayoutContent style="
padding: 12px;
min-width: 0;
overflow-wrap: anywhere;
">
<output aria-label={("Panel status with prefix")}>{(collapsed ? "Collapsed" : "Revealed")}</output>
</LayoutContent>
<LayoutFooter style="
padding: 12px;
overflow-wrap: anywhere;
">
{("Standard sections")}
</LayoutFooter>
</Layout>
</Layout>
</div>
<div class="preview">
<Layout
hasSider
aria-label={("Standard layout side by side")}
style="min-height: 100px"
>
<LayoutSider
aria-label={("Standard panel side by side")}
width={128}
collapsedWidth={zeroWidth ? 0 : 48}
{collapsed}
theme="light"
trigger={null}
styles={{ body: `
padding: 12px;
overflow-wrap: anywhere;
` }}
>{("Menu")}</LayoutSider>
<LayoutContent style="
padding: 12px;
min-width: 0;
overflow-wrap: anywhere;
">
{("Standard Layout")}
</LayoutContent>
</Layout>
</div>
<output aria-label={("Layout prefixes")}>
Layout: {(layoutPrefix || ("from ConfigProvider"))}; Sider: {(siderPrefix
|| ("from ConfigProvider"))}
</output>
</div>
Inside Layout
Without Layout
Inside the Layout, the header inherits 56px from the style container; without it, uses the headerHeight token: 48.
Section prefixes
Complete Header/Content/Footer classes, common prefix, inheritance within Layout and tokens of individual sections.
<script lang="ts">
import {
Checkbox, ConfigProvider, Input, Layout, LayoutContent, LayoutFooter, LayoutHeader
} from '@woodger/antd';
let custom = $state(true);
let shared = $state(false);
let draft = $state('');
const headerPrefix = $derived(
custom
? (shared ? 'woodger-region' : 'woodger-header')
: ''
);
const contentPrefix = $derived(
custom
? (shared ? 'woodger-region' : 'woodger-content')
: ''
);
const footerPrefix = $derived(
custom
? (shared ? 'woodger-region' : 'woodger-footer')
: ''
);
</script>
<style>
.example, .samples {
display: grid;
gap: 16px;
}
.sample {
display: grid;
gap: 8px;
min-width: 0;
}
.controls {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
.preview {
min-width: 0;
overflow: hidden;
border: 1px solid var(--ant-color-border-secondary);
border-radius: 8px;
}
.caption {
margin: 0;
font-weight: 600;
}
.hint {
margin: 0;
color: var(--ant-color-text-secondary);
}
output { overflow-wrap: anywhere; }
</style>
<div class="example">
<div class="controls">
<Checkbox bind:checked={custom}>{("Own section prefix")}</Checkbox>
<Checkbox
bind:checked={shared}
disabled={!custom}
>{("General class of sections")}</Checkbox>
</div>
<ConfigProvider theme={{
components: {
Layout: {
headerHeight: 48,
headerPadding: '0 16px',
headerBg: 'var(--ant-color-fill-secondary)',
footerPadding: '12px 16px'
}
}
}}>
<div class="samples">
<div class="sample">
<p class="caption">{("Inside Layout")}</p>
<div class="preview" role="region" aria-label={("Sections inside Layout")}>
<Layout prefixCls="woodger-section-layout"
style="
--ant-layout-header-height: 56px;
min-width: 0;
">
<LayoutHeader prefixCls={headerPrefix}>{("Hat")}</LayoutHeader>
<LayoutContent prefixCls={contentPrefix} style="
padding: 16px;
min-width: 0;
">
<Input aria-label={("Draft content")} placeholder={("Enter text")} bind:value={draft} />
</LayoutContent>
<LayoutFooter prefixCls={footerPrefix}>{("Basement")}</LayoutFooter>
</Layout>
</div>
</div>
<div class="sample">
<p class="caption">{("Without Layout")}</p>
<div class="preview" role="region" aria-label={("Sections without Layout")}>
<LayoutHeader prefixCls={headerPrefix}>{("Hat")}</LayoutHeader>
<LayoutContent prefixCls={contentPrefix} style="
padding: 16px;
min-width: 0;
">
{("\n The section receives tokens of its ConfigProvider area.\n ")}
</LayoutContent>
<LayoutFooter prefixCls={footerPrefix}>{("Basement")}</LayoutFooter>
</div>
</div>
</div>
</ConfigProvider>
<p class="hint">
{("Inside the Layout, the header inherits 56px from the style container; without it, uses the headerHeight token: 48.")}
</p>
<output aria-label={("Section classes")}>
Header: {(headerPrefix || ("from ConfigProvider"))};
Content: {(contentPrefix || ("from ConfigProvider"))};
Footer: {(footerPrefix || ("from ConfigProvider"))}
</output>
</div>
API
Themes of the ant.design live page are mapped to the public API of the installed package. Full definitions of Props are in @woodger/antd.
| Theme | Example or limitation |
|---|---|
| Basic Structure | Nested sections and hasSider. |
| Header-Content-Footer | Top navigation and content. |
| Header-Sider | Common header above two columns. |
| Header Sider 2 | General header and footer of the right work area. |
| Sider | Built-in collapse and Menu. |
| Custom trigger | External button and trigger=null. |
| Collapsible overlay | Composition with absolute Sider. |
| Responsive | breakpoint and zero-width trigger. |
| Fixed Header | Sticky in a local scroll container. |
| Fixed Sider | Sticky Sider in its own area. |
| Component config | General class/style, local priorities, record reset and state saving. |
| Local CSS prefixes | Independent namespace Layout/Sider, native sections, SSR and state saving. |
| Local section prefixes (Svelte) | Own and common classes Header/Content/Footer, inheritance and sections without Layout. |
Layout
| Property | Description | Type | Default |
|---|---|---|---|
prefixCls | Local full CSS prefix of container and states. Does not change sections/Sider; undefined/empty string use the common prefix + layout. | string | ConfigProvider / ant-layout |
hasSider | Clear horizontal structure with SSR. The direct child Sider is also recognized with its own prefixCls. | boolean | automatically |
LayoutSider
| Property | Description | Type | Default |
|---|---|---|---|
prefixCls | Full prefix of Sider, body, states and trigger. An empty string inherits the common prefix + layout-sider; ids/aria-controls are saved. | string | ConfigProvider / ant-layout-sider |
collapsed | Controlled state; supports bind:collapsed. | boolean | false |
defaultCollapsed | Initial state without external control. | boolean | false |
collapsible | Built-in collapse button. | boolean | false |
width | Width of the opened panel, number in px. | number | string | 200 |
collapsedWidth | Width of folded panel; 0 enables special trigger. | number | string | 80 |
breakpoint | Automatic minimizing according to viewport. | GridBreakpoint | — |
theme | Design of Sider and its built-in trigger. | light | dark | dark |
trigger | Button content; null hides the button completely. | Snippet | string | number | null | false | Arrow |
reverseArrow | Changes the direction of the built-in arrow and the side of the zero-width trigger. | boolean | false |
onCollapse | Condition and reason: clickTrigger or responsive. | (collapsed, type) => void | — |
onBreakpoint | Crossing the adaptive threshold. | (broken) => void | — |
zeroWidthTriggerStyle | CSS buttons with collapsedWidth=0. | string | — |
classNames | The root and body classes. | LayoutSiderSemanticSlots | function | — |
styles | CSS lines root/body; the function receives info.props. | LayoutSiderSemanticSlots | function | — |
nativeElement | Native ref of each Layout section. | HTMLElement | — |
ConfigProvider.layout
LayoutConfig contains only class and style. The setting applies to Layout containers, including nested ones. undefined inherits record; its own object, including an empty one, replaces it entirely. The local style is applied after the general one; Header/Content/Footer/Sider do not receive the record directly.
| Property | Description | Type | Default |
|---|---|---|---|
class | General class of Layout containers only; is added to the local class and rootClassName. | string | — |
style | Container CSS string after theme variables and before local style. Not assigned to sections and Sider directly. | string | — |
prefixCls is set independently for Layout, LayoutSider, LayoutHeader, LayoutContent and LayoutFooter. A non-empty local prop takes precedence over a global prop ConfigProvider.prefixCls; undefined/empty string uses its base prefix with the role suffix. The container local prefix does not rename child sections.
LayoutHeader, LayoutContent, LayoutFooter
LayoutSectionProps includes prefixCls, children, class, rootClassName, style, nativeElement and native HTML attributes. LayoutProps additionally contains hasSider.
| Property | Description | Type | Default |
|---|---|---|---|
prefixCls | Full section CSS class without adding a suffix. A non-empty local prop takes precedence over a general prefix; undefined/empty string inherit the base prefix ConfigProvider + layout-header/content/footer. | string | ConfigProvider / ant-layout-header/content/footer |
Semantic DOM
Layout creates a div, LayoutHeader - header, LayoutContent - main, LayoutFooter - footer, LayoutSider - aside with an inner body. The structure is chosen by the application; Layout itself does not create routes or manage the selected Menu item.
Sider has root/body available via classNames/styles. The collapse button is a real button with aria-expanded and aria-controls; expandLabel/collapseLabel set its name. With a zero width, the content becomes inert. For the remaining sections, class, rootClassName, style and bind:nativeElement are available.
Registration tokens
Sixteen current component tokens verified against ant.design. theme.components.Layout applies to sections, sidebar and trigger. class/style and semantic styles Sider specify local styling.
| Token | Purpose |
|---|---|
bodyBg | Work area background. |
footerBg | Basement background. |
footerPadding | Basement indentations. |
headerBg | Header background. |
headerColor | Header text. |
headerHeight | Header height. |
headerPadding | Horizontal header padding. |
lightSiderBg | Light panel background. |
lightTriggerBg | Light panel button background. |
lightTriggerColor | Light panel button text. |
siderBg | Dark panel background. |
triggerBg | Dark panel button background. |
triggerColor | The color of her icon. |
triggerHeight | Built-in button height. |
zeroTriggerHeight | Zero panel button height. |
zeroTriggerWidth | Its width. |
| Token | Current value |
|---|---|
colorText | rgba(0,0,0,0.88) |
fontSize | 14 |
FAQ
Why hasSider with SSR?
It explicitly sets the structure before registering the Sider. The direct child of Sider is also recognized via CSS; a complex composition is better described explicitly.
How to associate Menu with collapsing?
Menu inside Sider receives panel context. To control the panel itself, use bind:collapsed; inlineCollapsed is needed for a separate Menu outside the Sider.
Is overlay a separate API mode?
No, this is a CSS composition of the application with a panel on top of the content.
What happens below the breakpoint?
Sider reports onBreakpoint and changes collapsed with reason responsive. When collapsedWidth=0, a special button remains if trigger is not null.
Is it possible to use sections without Layout?
For the page frame you usually need a Layout. In Svelte, the individual LayoutHeader, LayoutContent and LayoutFooter also receive their ConfigProvider area tokens, initial CSS values and border-box before hydration. A nested section inherits the variables of the nearest Layout; the native prefixCls does not reset them.
Does the design of sections with your own prefixCls match the React standard?
Svelte retains the design of the section role, including the general class of the header, content and footer. The erroneous container design of sections found in the React standard Ant Design 6.6.8 with its own prefixCls is not reproduced. The class changes, but the native header/main/footer, their tokens and the state of the controls are preserved.