Skip to the page
Supply UI

Page transition

In code: PageTransition

Makes going to this page smooth: the page you leave fades out and this one fades and rises in, while the app's sidebar, a site's header and the tab bar stay still. Wrap each page's content in it (in Next.js, in every page.tsx, not the layout: a layout stays from page to page, so it never comes or goes). A site of plain pages needs nothing: the kit's CSS does the same there. A page opened on its own (a first visit, a reload) fades in by itself, with or without this.

Preview

BookingsFriday, 27 November
  • Noor Haddad09:30 · Cut and finish
  • Otis Brandt11:00 · Colour

Use

The code of the preview above
import { Button, ItemText, List, ListItem, PageHeader, PageTransition, Stack } from '@/components/ui';

<PageTransition>
  <Stack gap={4}>
    <PageHeader>
      <ItemText title="Bookings" note="Friday, 27 November" />
      <Button variant="primary">New booking</Button>
    </PageHeader>
    <List>
      <ListItem>
        <ItemText title="Noor Haddad" note="09:30 · Cut and finish" />
      </ListItem>
      <ListItem>
        <ItemText title="Otis Brandt" note="11:00 · Colour" />
      </ListItem>
    </List>
  </Stack>
</PageTransition>

This page as text, for an AI

Options

OptionTypeWhat it does
children NeededReactNodeThe page's content.

Without React

The same look on any HTML, with the classes ::view-transition-old(.ui-page), ::view-transition-new(.ui-page); @view-transition.

With the CSS in parts (/ui/css/), it needs these, besides the ones every page loads:

components/page-transitions.css

Layout: states, do and don’t

Wraps one page's content (in Next.js, in each page.tsx) so going to it is smooth: the old page fades out, this one fades and rises in, and the sidebar, site header and tab bar stay still. Plain multi-page sites need nothing: the kit's CSS does the same. A page opened on its own (a first visit, a reload) fades in by itself, with or without it.

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