Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Layout component for React. Handling the overall layout of a page.

License

NotificationsYou must be signed in to change notification settings

uiwjs/react-layout

Repository files navigation

Usingmy app is also a way tosupport me:
KeyzerVidwall HubVidCropVidwallMousio HintMousioMusicerAudioerFileSentinelFocusCursorVideoerKeyClickerDayBarIconedMousioQuick RSSQuick RSSWeb ServeCopybook GeneratorDevTutor for SwiftUIRegexMateTime PassageIconize FolderTextsound SaverCreate Custom SymbolsDevHubResume RevisePalette GeniusSymbol Scribe

Layout

NPM DownloadsBuild & DeployOpen in unpkgnpm versionCoverage StatusOpen in Gitpod

Handling the overall layout of a page.

⚠️ Note: Implemented with flex layout, please pay attention tobrowser compatibility issues.

import{Layout}from'uiw';// orimportLayoutfrom'@uiw/react-layout';const{ Header, Footer, Sider, Content}=Layout;// orimportLayout,{LayoutHeader,LayoutContent,LayoutSider,LayoutFooter}from'@uiw/react-layout';Layout.Header===LayoutHeaderLayout.Content===LayoutContentLayout.Sider===LayoutSiderLayout.Footer===LayoutFooter

Basic Usage

importReactfrom'react';importReactDOMfrom'react-dom';importLayout,{LayoutHeader,LayoutContent,LayoutSider,LayoutFooter}from'@uiw/react-layout';const{ Header, Footer, Sider, Content}=Layout;conststylHeader={color:'#fff'}conststylSider={background:'#484a4e',color:'#fff',display:'flex',justifyContent:'center',alignItems:'center'}conststylConten={background:'#108ee9',minHeight:120,display:'flex',justifyContent:'center',alignItems:'center',color:'#fff'}functionDemo(){const[collapsed,setCollapsed]=React.useState(false)return(<div><Layoutstyle={{marginBottom:20}}><Headerstyle={stylHeader}>Header</Header><Layout><Siderstyle={stylSider}>Sider</Sider><Contentstyle={stylConten}>Content</Content></Layout><Footer>Footer</Footer></Layout><Layout><Headerstyle={stylHeader}>Header</Header><Layout><Contentstyle={stylConten}>Content</Content><Siderstyle={stylSider}>Sider</Sider></Layout><Footer>Footer</Footer></Layout><Layout><LayoutHeaderstyle={stylHeader}>Header</LayoutHeader><Layout><LayoutContentstyle={stylConten}>Content</LayoutContent><LayoutSiderstyle={stylSider}>Sider</LayoutSider></Layout><LayoutFooter>Footer</LayoutFooter></Layout></div>);}exportdefaultDemo;

Layout top-middle-bottom

importReactfrom'react';importReactDOMfrom'react-dom';importLayoutfrom'@uiw/react-layout';const{ Header, Footer, Sider, Content}=Layout;conststylHeader={color:'#fff'}conststylConten={background:'#108ee9',minHeight:120,display:'flex',justifyContent:'center',alignItems:'center',color:'#fff'}functionDemo(){const[collapsed,setCollapsed]=React.useState(false)return(<Layoutstyle={{marginBottom:20}}><Headerstyle={stylHeader}>Header</Header><Contentstyle={stylConten}>Content</Content><Footer>Footer</Footer></Layout>);}exportdefaultDemo;

Layout left-right

importReactfrom'react';importReactDOMfrom'react-dom';importLayoutfrom'@uiw/react-layout';const{ Header, Footer, Sider, Content}=Layout;conststylHeader={color:'#fff'}conststylSider={background:'#484a4e',color:'#fff',display:'flex',justifyContent:'center',alignItems:'center'}conststylConten={background:'#108ee9',minHeight:120,display:'flex',justifyContent:'center',alignItems:'center',color:'#fff'}functionDemo(){const[collapsed,setCollapsed]=React.useState(false)return(<Layoutstyle={{marginBottom:20}}><Sidercollapsed={collapsed}style={stylSider}>Sider</Sider><Layout><Headerstyle={stylHeader}><buttononClick={()=>setCollapsed(!collapsed)}>{collapsed ?'>>' :'<<'}</button></Header><Contentstyle={stylConten}>Content</Content><Footer>Footer</Footer></Layout></Layout>);}exportdefaultDemo;

Layout

The layout wrapper, in whichHeaderSiderContentFooter orLayout itself can be nested, and can be placed in any parent container.

  • Header: The top layout with the default style, in which any element can be nested, and must be placed inLayout.
  • Sider: The sidebar with default style and basic functions, in which any element can be nested, and must be placed inLayout.
  • Content: The content layout with the default style, in which any element can be nested, and must be placed inLayout.
  • Footer: The bottom layout with the default style, in which any element can be nested, and must be placed inLayout.
PropertyDescriptionTypeDefault
classNameContainer classNamestring-
styleTo customize the stylesCSSProperties-
hasSiderhasSiderWhether contain Sider in children, don't have to assign it normally. Useful in ssr avoid style flickeringboolean-

Header

importLayout,{LayoutHeader}from'@uiw/react-layout';Layout.Header===LayoutHeader
importReactfrom'react';exportinterfaceLayoutHeaderPropsextendsReact.HTMLAttributes<HTMLElement>{prefixCls?:string;children?:React.ReactNode;}exportdeclareconstLayoutHeader:React.ForwardRefExoticComponent<LayoutHeaderProps&React.RefAttributes<HTMLElement>>;

Content

importLayout,{LayoutContent}from'@uiw/react-layout';Layout.Content===LayoutContent
importReactfrom'react';exportinterfaceLayoutContentPropsextendsReact.HTMLAttributes<HTMLElement>{prefixCls?:string;children?:React.ReactNode;}exportdeclareconstLayoutContent:React.ForwardRefExoticComponent<LayoutContentProps&React.RefAttributes<HTMLElement>>;

Footer

importLayout,{LayoutFooter}from'@uiw/react-layout';Layout.Footer===LayoutFooter
importReactfrom'react';exportinterfaceLayoutFooterPropsextendsReact.HTMLAttributes<HTMLElement>{prefixCls?:string;children?:React.ReactNode;}exportdeclareconstLayoutFooter:React.ForwardRefExoticComponent<LayoutFooterProps&React.RefAttributes<HTMLElement>>;

Sider

PropertyDescriptionTypeDefault
classNameContainer classNamestring-
styleTo customize the stylesCSSProperties-
collapsedTo set the current statusboolean-
collapsedWidthWidth of the collapsed sidebar, by setting to 0 a special trigger will appearboolean80
widthWidth of the sidebarnumber/string200
importLayout,{LayoutSider}from'@uiw/react-layout';Layout.Sider===LayoutSider
importReactfrom'react';exportdeclarefunctionrandomid():string;exportinterfaceLayoutSiderPropsextendsReact.HTMLAttributes<HTMLElement>{prefixCls?:string;children?:React.ReactNode;/** Width of the sidebar */width?:number|string;/** Width of the collapsed sidebar, by setting to 0 a special trigger will appear */collapsedWidth?:number;/** To set the current status */collapsed?:boolean;}exportdeclareconstLayoutSider:React.ForwardRefExoticComponent<LayoutSiderProps&React.RefAttributes<HTMLDivElement>>;

Contributors

As always, thanks to our amazing contributors!

Made withcontributors.

License

Licensed under the MIT License.

About

Layout component for React. Handling the overall layout of a page.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

    Packages

    No packages published

    Contributors5


    [8]ページ先頭

    ©2009-2025 Movatter.jp