Skip to the page
Supply UI

Main

The main part of an AppShell, beside its Sidebar, with the page's room round it

Preview

Harbour Studio

Bookings

  • Noor HaddadCut and finish09:30
  • Otis BrandtColour11:00

Use

The code of the preview above
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>
  );
}

This page as text, for an AI

Options

OptionTypeWhat it does
as "div" | "main" · default 'main'The element it renders: div when the page around it already has this element (one main per page).

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.css

Layout: 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 Card is 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-height together with an aspect-ratio.
  • Don't nest a card in a card.
  • Don't put two <main>s on a page: a screen shown inside another page takes Main as="div".