shadcn.io is not affiliated with official shadcn/ui
User Preferences Dialog Block for React
A time tracker's Today page with a preferences sheet shown open where each setting shows its effect: a theme choice over a preview card, a text size and a reduce-motion switch acting on a sample, a default view and two behaviour switches.
Installation
Overview
Let people tune an app and see what each choice does before they keep it, with this preferences sheet for React with Base UI. It opens from the Today page of Clockbarn, a time tracker: the page's header holds an outline Preferences Button, and the page itself, a sidebar, a header with a text-size chip and a gear, and a task list in real words, is drawn under a soft scrim inside a hairline frame with a plus mark on each corner. The Sheet has three groups. Appearance is a Toggle Group, Light, Dark or System, over a small preview card that wears the choice. Reading is a Segment Group for the text size and a Reduce motion Switch, both acting on a sample sentence and a sample entrance. Behaviour has the default view in a Select, List, Board or Calendar, and two switches, Show completed tasks and Open links in a new tab. Reset to defaults then offers Undo reset, and the only Shine Button saves: the drawn page behind the sheet switches to the chosen view, at the chosen text size, with a Text chip. This page keeps its own theme. For preview the sheet is drawn open in place at the end of the frame when the page loads; the header button opens the real Sheet.
FAQ
Why is the sheet already open, and what do I keep?
So you can see it without a click. On load the sheet is a copy drawn in place at the end of the frame: a native dialog element that isn't modal, so nothing is trapped, hidden or focused, and the page around the preview keeps working. The Preferences button opens the real Sheet, modal, with its focus trap, Escape and focus return, and the copy stays closed until a reload. Both show the same PrefFields component and share the block's state, so what you chose in the copy is there in the real one. In your app keep the Sheet and drop the copy: the "in-place" state, the scrim and the dialog element inside the frame.
Does choosing Dark change my page's theme?
No. The preview card is drawn from this page's own colours with its two main ones traded: its background takes the foreground colour and its ink takes the background, and on a dark page they trade back. System draws the light and dark halves split along a diagonal. No dark class is written anywhere and the site's theme is untouched; in your app apply the choice to your own theme provider when it is saved.
What does each setting do in the sheet?
Text size changes the sample sentence at once, Small, Medium or Large. Reduce motion replays a small Saved chip's entrance: it slides in with motion on and appears at once with motion reduced, and the line under the switch says which. The default view, Show completed tasks and Open links in a new tab take effect on the drawn page when you save. Every change also says what it did in a polite message.
How do Reset to defaults and Undo work?
Reset to defaults puts the defaults in the draft, six settings, and the same button then reads Undo reset until you change something else: pressing it puts your edits back. Neither saves anything; Save preferences does, and closing the sheet any other way drops the unsaved edits. Reset says when you are already at the defaults.
What stays local in the demo, and how do I wire it up?
All of it. The tasks, the defaults and what is saved are typed constants, and Save changes only the drawn page. In your app load the saved preferences with the user's profile, save them from save, and apply the text size and motion setting to the whole app, ideally also honouring the system's reduced-motion setting when the user has made no choice.
Is it accessible from the keyboard?
Yes. The real sheet is named Preferences, focus starts inside and stays there until it closes, and Escape and the close button return focus to the header button. The theme group, the text size and the Select use the arrow keys, each switch is named for its setting and flips with Space, and the body scrolls inside the sheet while the foot stays. The trigger is passed to SheetTrigger through render, and the sheet is controlled with open and onOpenChange. The sheet opens from the end of the page's reading direction, the right in a left-to-right page. The copy shown on load moves no focus; Escape inside it and its close button close it and put focus on the button.
Related
- Pro
Appearance Settings
Appearance and localeAn appearance settings panel that previews instead of applying: a drawn app window that wears the choices, theme and contrast cards with a drawn thumbnail each, a text-size slider with a sample sentence and a reduce motion switch with a replay.
- Pro
Language and Region Settings
Appearance and localeA language and region settings panel: two selects over three cells that show what they do, a sort order made by the language's collation, a month marked with the region's first weekday, and units with a worked example.
- Pro
Assign Task Dialog
Side sheetsA sprint board with a side sheet that assigns its one unowned task shown open: five people with their open tasks and load, a priority, a due date from chips or an inline calendar, and a switch to notify the assignee.
- Pro
Keyboard Shortcuts Settings
Appearance and localeA keyboard shortcuts editor: twelve editor actions in three groups with their keys in Kbd caps, a Change button that records the next combination, a conflict check with Replace or Cancel, Changed marks and Reset, a search and a PC or Mac choice for the key words.
- Pro
Sidebar Layout Settings
Appearance and localeA navigation editor in a window beside the app it edits: a layout chosen from three cards with drawn thumbnails, a collapse mode, five items with visibility toggles and Move up and down, Settings that cannot be hidden, and a drawn app that redraws on every change.
- Pro
A team chat inbox with a settings dialog shown open: a real table of notification kinds by channel with a switch in every cell, mixed-state column masters, reset and save, and a chip on the inbox that reports the saved count.