CraftUI

Screen

The frame of an Ore UI screen: a picture behind everything, the light bar along the top, and titled sections.

Play

Top games

Over a world picture, a section title sits on a dark box.

Received invites (1)

With a tone, it's a colored tag with a matching rule.

Open on a page of its own

Installation

npx shadcn@latest add @runqora/craft-screen

Usage

import {
  Screen,
  ScreenBody,
  ScreenHeader,
  ScreenSection,
} from "@/components/craft/screen";

<Screen background={<img alt="" src="/world.png" />} className="h-dvh">
  <ScreenHeader onBack={() => history.back()} title="Play" />
  <ScreenBody>
    <ScreenSection title="Top games">…</ScreenSection>
    <ScreenSection title="Received invites (1)" tone="warning">…</ScreenSection>
  </ScreenBody>
</Screen>;

Props

Screen

Prop

Type

ScreenHeader

Prop

Type

ScreenSection

Prop

Type

Accessibility

  • The title is the page's heading, and each section is a region named by its own heading.
  • The back arrow is a button named Back. Pass backLabel to translate it.
  • The background is hidden from screen readers.

Customization

Every block is built on Screen, so changing it changes them all. The bar uses --craft-header, --craft-header-hi, --craft-header-lo and --craft-header-fg.

A screen is a container: the layouts inside follow its width, not the window's, so a screen in a side panel lays out as a narrow one. Every screen fills its frame, so give it a height, such as h-dvh for a whole page.

Dependencies

  • shadcn's utils, and craft-theme

Source