Overview
Layout: Layout containers. You can nestHeaderSiderContentFooterorLayoutitself inside.Header: Head component, can only be used insideLayout.Sider: Sidebar, can only be used insideLayout.Content: Content component, can only be used insideLayout.Footer: Footer component, can only be used insideLayout.
Demos
How to import
<script setup lang="ts">
import { Layout } from '@fibrous/semi-ui-vue';
</script>
Use the subcomponents as Layout.Header, Layout.Sider, Layout.Content and Layout.Footer, or import LayoutHeader, LayoutSider, LayoutContent and LayoutFooter by name.
Three-section Layout
Code
<script setup lang="ts">
import { Layout } from '@fibrous/semi-ui-vue';
const commonStyle = {
height: '64px',
lineHeight: '64px',
background: 'var(--semi-color-fill-0)',
};
</script>
<template>
<Layout class="components-layout-demo">
<Layout.Header :style="commonStyle">Header</Layout.Header>
<Layout.Content :style="{ height: '300px', lineHeight: '300px' }">Content</Layout.Content>
<Layout.Footer :style="commonStyle">Footer</Layout.Footer>
</Layout>
</template>Left-sidebar Layout
Code
<script setup lang="ts">
import { Layout } from '@fibrous/semi-ui-vue';
const commonStyle = {
height: '64px',
lineHeight: '64px',
background: 'var(--semi-color-fill-0)',
};
</script>
<template>
<Layout class="components-layout-demo">
<Layout.Header :style="commonStyle">Header</Layout.Header>
<Layout>
<Layout.Sider :style="{ width: '120px', background: 'var(--semi-color-fill-2)' }">Sider</Layout.Sider>
<Layout.Content :style="{ height: '300px', lineHeight: '300px' }">Content</Layout.Content>
</Layout>
<Layout.Footer :style="commonStyle">Footer</Layout.Footer>
</Layout>
</template>Right-sidebar Layout
Code
<script setup lang="ts">
import { Layout } from '@fibrous/semi-ui-vue';
const commonStyle = {
height: '64px',
lineHeight: '64px',
background: 'var(--semi-color-fill-0)',
};
</script>
<template>
<Layout class="components-layout-demo">
<Layout.Header :style="commonStyle">Header</Layout.Header>
<Layout>
<Layout.Content :style="{ height: '300px', lineHeight: '300px' }">Content</Layout.Content>
<Layout.Sider :style="{ width: '120px', background: 'var(--semi-color-fill-2)' }">Sider</Layout.Sider>
</Layout>
<Layout.Footer :style="commonStyle">Footer</Layout.Footer>
</Layout>
</template>Sidebar Layout
Code
<script setup lang="ts">
import { Layout } from '@fibrous/semi-ui-vue';
const commonStyle = {
height: '64px',
lineHeight: '64px',
background: 'var(--semi-color-fill-0)',
};
</script>
<template>
<Layout class="components-layout-demo">
<Layout.Sider :style="{ width: '120px', background: 'var(--semi-color-fill-2)' }">Sider</Layout.Sider>
<Layout>
<Layout.Header :style="commonStyle">Header</Layout.Header>
<Layout.Content :style="{ height: '300px', lineHeight: '300px' }">Content</Layout.Content>
<Layout.Footer :style="commonStyle">Footer</Layout.Footer>
</Layout>
</Layout>
</template>Responsive Layout
Six response sizes are preset in the sidebar: xs,sm,md,lg,xl,xxl. You can use breakpoint to set breakpoints.
Listen to @breakpoint for changes in whether a breakpoint matches.
Code
<script setup lang="ts">
import { Layout } from '@fibrous/semi-ui-vue';
const commonStyle = {
height: '64px',
lineHeight: '64px',
background: 'var(--semi-color-fill-0)',
};
</script>
<template>
<Layout class="components-layout-demo">
<Layout.Header :style="commonStyle">Header</Layout.Header>
<Layout>
<Layout.Sider :breakpoint="['md']" :style="{ width: '120px', background: 'var(--semi-color-fill-2)' }" @breakpoint="(screen, matches) => console.log(screen, matches)"> Sider </Layout.Sider>
<Layout.Content :style="{ height: '300px', lineHeight: '300px' }">Content</Layout.Content>
</Layout>
<Layout.Footer :style="commonStyle">Footer</Layout.Footer>
</Layout>
</template>Layout Examples
Top-nav Layout
Top-Nav SideBar Layout
SideBar Navigation
API Reference
Layout
Props
| Property | Description | Type | Default |
|---|---|---|---|
| prefixCls | Class name prefix. | string | semiDefault("Layout", "prefixCls", cssClasses.PREFIX) |
| tagName | Tag name of the root element. | keyof HTMLElementTagNameMap | semiDefault("Layout", "tagName", "section") |
| hasSider | Indicates that a Sider is inside. A Sider among the direct children is detected automatically; a deeper one registers after mount, so pass true during server rendering to avoid style flashing. Passing false cannot remove the has-sider class that a Sider adds. | boolean | semiGlobalDefault("Layout", "hasSider") |
Events
| Event | Description | Callback parameters |
|---|---|---|
| None |
Slots
| Slot | Description | Scope parameters |
|---|---|---|
| default | Content of the Layout: Layout.Header, Layout.Sider, Layout.Content, Layout.Footer or a nested Layout. | any |
Exposes
| Name | Description | Type |
|---|---|---|
| None |
class, style and native attributes (including role and aria-*) fall through to the root element.
Layout.Header, Layout.Footer, Layout.Content
The three share the same API. Their default tags are header, footer and main.
Layout.Header
Props
| Property | Description | Type | Default |
|---|---|---|---|
| prefixCls | Class name prefix. | string | cssClasses.PREFIX |
| tagName | Tag name of the root element. | keyof HTMLElementTagNameMap | "header" |
| type | For internal use; decides the class name suffix. | string | "header" |
Events
| Event | Description | Callback parameters |
|---|---|---|
| None |
Slots
| Slot | Description | Scope parameters |
|---|---|---|
| default | Content of the header. | any |
Exposes
| Name | Description | Type |
|---|---|---|
| None |
Layout.Footer
Props
| Property | Description | Type | Default |
|---|---|---|---|
| prefixCls | Class name prefix. | string | cssClasses.PREFIX |
| tagName | Tag name of the root element. | keyof HTMLElementTagNameMap | "footer" |
| type | For internal use; decides the class name suffix. | string | "footer" |
Events
| Event | Description | Callback parameters |
|---|---|---|
| None |
Slots
| Slot | Description | Scope parameters |
|---|---|---|
| default | Content of the footer. | any |
Exposes
| Name | Description | Type |
|---|---|---|
| None |
Layout.Content
Props
| Property | Description | Type | Default |
|---|---|---|---|
| prefixCls | Class name prefix. | string | cssClasses.PREFIX |
| tagName | Tag name of the root element. | keyof HTMLElementTagNameMap | "main" |
| type | For internal use; decides the class name suffix. | string | "content" |
Events
| Event | Description | Callback parameters |
|---|---|---|
| None |
Slots
| Slot | Description | Scope parameters |
|---|---|---|
| default | Content of the main area. | any |
Exposes
| Name | Description | Type |
|---|---|---|
| None |
class, style and native attributes (including role and aria-*) fall through to each root element.
Layout.Sider
Props
| Property | Description | Type | Default |
|---|---|---|---|
| prefixCls | Class name prefix. | string | cssClasses.PREFIX |
| breakpoint | Breakpoints that trigger the responsive layout: xs, sm, md, lg, xl or xxl. Read once at mount. | Breakpoint[] | undefined |
Events
| Event | Description | Callback parameters |
|---|---|---|
| breakpoint | Emitted once at mount for each screen listed in breakpoint with the current viewport state, then whenever it starts or stops matching, with the screen name and whether it matches. | [screen: Breakpoint, match: boolean] |
Slots
| Slot | Description | Scope parameters |
|---|---|---|
| default | Content of the sider. | any |
Exposes
| Name | Description | Type |
|---|---|---|
| None |
class, style and native attributes (including role and aria-*) fall through to the root aside element.
responsive map
{
xs: '(max-width: 575px)',
sm: '(min-width: 576px)',
md: '(min-width: 768px)',
lg: '(min-width: 992px)',
xl: '(min-width: 1200px)',
xxl: '(min-width: 1600px)',
}
Accessibility
ARIA
- Sider renders an
aside; passaria-labelto describe what this Sider is for. - Header and Footer render
headerandfooterby default. Inside thesectionof a Layout they are not banner or contentinfo landmarks; passrole="banner"orrole="contentinfo"when they are the header or footer of the whole page. - Content renders
mainby default, and a page should have only onemain; when nesting, usetagNameto switch to another tag. - Header, Content and Footer accept
roleandaria-labelto describe the corresponding element.