CraftUI

Settings Screen

A settings screen built from a list of categories and settings: switches, sliders, dropdowns, rows of choices and buttons, with reset.

Settings

Text to speech

Adjust how you hear on-screen text

Text to speech

Use your device for text to speech

Closed captions
Open on a page of its own

Installation

npx shadcn@latest add @runqora/craft-settings-screen

Usage

import { SettingsScreen } from "@/components/craft/blocks/settings-screen";

<SettingsScreen
  categories={[
    {
      id: "audio",
      label: "Audio",
      sections: [
        {
          title: "Volume",
          settings: [
            { id: "music", label: "Music", type: "slider" },
            { id: "captions", label: "Closed captions", type: "switch" },
          ],
        },
      ],
    },
  ]}
  onValueChange={(id, value) => save(id, value)}
  values={settings}
/>;

Props

SettingsScreen

Prop

Type

Accessibility

  • The categories are vertical tabs, and the arrow keys move between them and show each one.
  • Every setting's label and description are joined to its control.
  • A row of choices is a tab list named by the setting's label.

Customization

A setting's type picks its control: switch, slider, select, choice for a row of choices, or button. Give categories a group to put a heading above them in the sidebar.

onReset adds a Reset button to each category; reset that category's values in your state. Every screen fills its frame, so give it a height, such as h-dvh for a whole page.

Dependencies

  • craft-button, craft-screen, craft-select, craft-settings-menu, craft-slider, craft-switch and craft-tabs
  • shadcn's utils, and craft-theme

Source