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
import { Layout } from '@fibrous/semi-ui-solid';
Use the subcomponents as Layout.Header, Layout.Sider, Layout.Content and Layout.Footer.
Three-section Layout
Code
import { Layout } from '@fibrous/semi-ui-solid';
const commonStyle = {
height: '64px',
'line-height': '64px',
background: 'var(--semi-color-fill-0)',
};
export default function LayoutDemo() {
return (
<Layout class="components-layout-demo">
<Layout.Header style={commonStyle}>Header</Layout.Header>
<Layout.Content style={{ height: '300px', 'line-height': '300px' }}>Content</Layout.Content>
<Layout.Footer style={commonStyle}>Footer</Layout.Footer>
</Layout>
);
}Left-sidebar Layout
Code
import { Layout } from '@fibrous/semi-ui-solid';
const commonStyle = {
height: '64px',
'line-height': '64px',
background: 'var(--semi-color-fill-0)',
};
export default function LayoutDemo() {
return (
<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', 'line-height': '300px' }}>Content</Layout.Content>
</Layout>
<Layout.Footer style={commonStyle}>Footer</Layout.Footer>
</Layout>
);
}Right-sidebar Layout
Code
import { Layout } from '@fibrous/semi-ui-solid';
const commonStyle = {
height: '64px',
'line-height': '64px',
background: 'var(--semi-color-fill-0)',
};
export default function LayoutDemo() {
return (
<Layout class="components-layout-demo">
<Layout.Header style={commonStyle}>Header</Layout.Header>
<Layout>
<Layout.Content style={{ height: '300px', 'line-height': '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>
);
}Sidebar Layout
Code
import { Layout } from '@fibrous/semi-ui-solid';
const commonStyle = {
height: '64px',
'line-height': '64px',
background: 'var(--semi-color-fill-0)',
};
export default function LayoutDemo() {
return (
<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', 'line-height': '300px' }}>Content</Layout.Content>
<Layout.Footer style={commonStyle}>Footer</Layout.Footer>
</Layout>
</Layout>
);
}Responsive Layout
Six response sizes are preset in the sidebar: xs,sm,md,lg,xl,xxl. You can use breakpoint to set breakpoints.
Use onBreakpoint to call callback functions.
Code
import { Layout, type SiderProps } from '@fibrous/semi-ui-solid';
const commonStyle = {
height: '64px',
'line-height': '64px',
background: 'var(--semi-color-fill-0)',
};
export default function LayoutDemo() {
const onBreakpoint: SiderProps['onBreakpoint'] = (screen, bool) => {
console.log(screen, bool);
};
return (
<Layout class="components-layout-demo">
<Layout.Header style={commonStyle}>Header</Layout.Header>
<Layout>
<Layout.Sider style={{ width: '120px', background: 'var(--semi-color-fill-2)' }} breakpoint={['md']} onBreakpoint={onBreakpoint}>
Sider
</Layout.Sider>
<Layout.Content style={{ height: '300px', 'line-height': '300px' }}>Content</Layout.Content>
</Layout>
<Layout.Footer style={commonStyle}>Footer</Layout.Footer>
</Layout>
);
}Layout Examples
Top-nav Layout
Top-Nav SideBar Layout
SideBar Navigation
API Reference
Layout
Props
| Property | Description | Type | Default |
|---|---|---|---|
| hasSider | Indicates that a Sider is inside; usually not needed. A Sider registers with the nearest Layout when it is created, so the has-sider class is present on the first frame, including SSR. Passing false cannot remove the has-sider class that a Sider adds. | boolean | - |
| prefixCls | Class name prefix. | string | "semi-layout" |
| tagName | Tag name of the root element. | keyof HTMLElementTagNameMap | "section" |
class, style, ref 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. Defaults to semi-layout. | string | - |
| tagName | Tag name of the root element. Defaults to header. | keyof HTMLElementTagNameMap | - |
| type | For internal use; decides the class name suffix. Defaults to header. | string | - |
Layout.Footer
Props
| Property | Description | Type | Default |
|---|---|---|---|
| prefixCls | Class name prefix. Defaults to semi-layout. | string | - |
| tagName | Tag name of the root element. Defaults to footer. | keyof HTMLElementTagNameMap | - |
| type | For internal use; decides the class name suffix. Defaults to footer. | string | - |
Layout.Content
Props
| Property | Description | Type | Default |
|---|---|---|---|
| prefixCls | Class name prefix. Defaults to semi-layout. | string | - |
| tagName | Tag name of the root element. Defaults to main. | keyof HTMLElementTagNameMap | - |
| type | For internal use; decides the class name suffix. Defaults to content. | string | - |
class, style, ref and native attributes (including role and aria-*) fall through to each root element.
Layout.Sider
Props
| Property | Description | Type | Default |
|---|---|---|---|
| breakpoint | Breakpoints that trigger the responsive layout: xs, sm, md, lg, xl or xxl. Read once at mount. | TypeArray<keyof ResponsiveMap> | - |
| onBreakpoint | Called 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. | Type(screen: keyof ResponsiveMap, match: boolean) => void | - |
| prefixCls | Class name prefix. Defaults to semi-layout. | string | - |
class, style, ref and native attributes and events (including role, aria-* and onClick) 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.