App shell
In code: AppShell
Sidebar and main area. On a phone the sidebar becomes a strip at the top.
Preview
Bookings
- Noor HaddadCut and finish09:30
- Otis BrandtColour11:00
Use
import { useState } from 'react';
import {
AppShell,
Button,
Calendar,
ItemText,
List,
ListItem,
Main,
Nav,
NavItem,
PageHeader,
Sidebar,
} from '@/components/ui';
import { Calendar, House, Plus, Users } from 'lucide-react';
function AppShellDemo() {
const [at, setAt] = useState('bookings');
const go = (id: string) => (e: MouseEvent) => {
e.preventDefault();
setAt(id);
};
return (
<AppShell>
<Sidebar as="div">
<span className="ui-subheading">Harbour Studio</span>
<Nav aria-label="Studio">
<NavItem href="#today" active={at === 'today'} onClick={go('today')}>
<House />
Today
</NavItem>
<NavItem href="#bookings" active={at === 'bookings'} onClick={go('bookings')}>
<Calendar />
Bookings
</NavItem>
<NavItem href="#clients" active={at === 'clients'} onClick={go('clients')}>
<Users />
Clients
</NavItem>
</Nav>
</Sidebar>
<Main as="div">
<PageHeader>
<h3 className="ui-title">{at === 'today' ? 'Today' : at === 'bookings' ? 'Bookings' : 'Clients'}</h3>
<Button variant="primary">
<Plus />
New booking
</Button>
</PageHeader>
<List>
<ListItem>
<ItemText className="ui-grow" title="Noor Haddad" note="Cut and finish" />
<span className="ui-mono">09:30</span>
</ListItem>
<ListItem>
<ItemText className="ui-grow" title="Otis Brandt" note="Colour" />
<span className="ui-mono">11:00</span>
</ListItem>
</List>
</Main>
</AppShell>
);
}Options
No options of its own.
It also takes the 280 attributes of the element or UI SDK part it draws: className, aria-label, events and the rest.
Without React
The same look on any HTML, with the classes ui-app, ui-sidebar, ui-main.
With the CSS in parts (/ui/css/), it needs these, besides the ones every page loads:
components/card.csscomponents/prose.csscomponents/page-transitions.cssLayout: states, do and don’t
Sidebar and main area; the sidebar becomes a top strip on a phone. They are the page's <aside> and <main>; a screen shown inside another page (an example, a preview) passes as="div" to both, so the page keeps one main.
States. Layout follows the box it is in, not the window: Split, Grid, AppShell and the site parts stack when their box is narrow, at any width of the window.
Do
- Space with
gap(Stack,Row,Grid), never with margins on children. - Put the page's sections straight on the page, under their titles; a
Cardis one thing a person picks or acts on. - Check every screen at 320, 375 and 768 px with the narrow check of rule 10.
Don't
- Don't give a box a fixed width, or a
min-heighttogether with anaspect-ratio. - Don't nest a card in a card.
- Don't put two
<main>s on a page: a screen shown inside another page takesMain as="div".