AppShell
Responsive shell for your application with header, navbar, aside and footer
Import
Source
Docs
Package
Examples
This page includes only documentation. Since all associated AppShell
components have fixed
position, it is not possible to include demos on this page. You can find 10+ examples on
this page
Usage
AppShell
is a layout component. It can be used to implement a common Header – Navbar – Footer – Aside
layout pattern. All AppShell
components have position: fixed
style – they are not scrolled with
the page.
Basic AppShell example with header and navbar. Navbar is hidden on mobile by default and toggled with the burger button.
Configuration
AppShell
component accepts, header
, footer
, navbar
and aside
props to configure
corresponding sections. It is required to set these props if you want to use corresponding
components. For example, if you want to use AppShell.Header
component, you need to set header
prop on the AppShell
component.
header
and footer
configuration objects are the same and have the following properties:
navbar
and aside
configuration objects are the same as well and have the following properties:
layout prop
layout
prop controls how AppShell.Header
/AppShell.Footer
and AppShell.Navbar
/AppShell.Aside
are positioned relative to each other. It accepts alt
and default
values:
alt
–AppShell.Navbar
/AppShell.Aside
height is equal to viewport height,AppShell.Header
/AppShell.Footer
width is equal to viewport width -AppShell.Navbar
andAppShell.Aside
width (example)default
–AppShell.Navbar
/AppShell.Aside
height is equal to viewport height -AppShell.Header
/AppShell.Footer
height,AppShell.Header
/AppShell.Footer
width is equal to viewport width (example)
Height configuration
height
property in header
and footer
configuration objects works the following way:
- If you pass a number, the value will be converted to rem and used as height at all viewport sizes.
- To change height based on viewport width, use object with breakpoints as keys and height as values. It works the same way as style props.
Examples:
Width configuration
width
property in navbar
and aside
configuration objects works the following way:
- If you pass a number, the value will be converted to rem and used as
width when the viewport is larger than
breakpoint
. - To change width based on viewport width, use object with breakpoints as keys and width as
values. It works the same way as style props.
Note that width is always 100% when the viewport is smaller than
breakpoint
.
Examples:
padding prop
padding
prop controls the padding of the AppShell.Main
component. It is important to use it
instead of setting padding on the AppShell.Main
directly because padding of the AppShell.Main
is
also used to offset AppShell.Header
, AppShell.Navbar
, AppShell.Aside
and AppShell.Footer
components.
padding
prop works the same way as style props and
accepts numbers, strings and objects with breakpoints as keys and padding as values. You can
reference theme.spacing
values or use any valid CSS values.
Header offset configuration
header
prop has offset
property which allows removing AppShell.Header
offset from AppShell.Main
component.
It is useful when you want to collapse AppShell.Header
based on the scroll position. For example, you can use
use-headroom hook to collapse header when user scrolls down and expand it when user scrolls up (example).
Collapsed navbar/aside configuration
navbar
and aside
props have collapsed
property. The property accepts an object
{ mobile: boolean; desktop: boolean }
which allows to configure collapsed state
depending on the viewport width.
Example with separate collapsed state for mobile and desktop:
withBorder prop
withBorder
prop is available on AppShell
and associated sections: AppShell.Header
, AppShell.Navbar
, AppShell.Aside
and AppShell.Footer
.
By default, withBorder
prop is true
– all components have a border on the side that is adjacent to the AppShell.Main
component.
For example, AppShell.Header
is located at the top of the page – it has a border on the bottom side,
AppShell.Navbar
is located on the left side of the page – it has a border on the right side.
To remove the border from all components, set withBorder={false}
on the AppShell
:
To remove the border from a specific component, set withBorder={false}
on that component:
zIndex prop
zIndex
prop is available on AppShell
and associated sections: AppShell.Header
, AppShell.Navbar
, AppShell.Aside
and AppShell.Footer
.
By default, all sections z-index
is 200
.
To change z-index
of all sections, set zIndex
prop on the AppShell
:
To change z-index
of a specific section, set zIndex
prop on that section:
Control transitions
Set transitionDuration
and transitionTimingFunction
props on the AppShell
to control transitions:
disabled prop
Set disabled
prop on the AppShell
to prevent all sections except AppShell.Main
from rendering.
It is useful when you want to hide the shell on some pages of your application.
Semantic elements
AppShell.Header
root element isheader
AppShell.Navbar
root element isnav
AppShell.Aside
root element isaside
AppShell.Footer
root element isfooter
AppShell.Main
root element ismain
– !important: do not usemain
element insideAppShell.Main
component