Settings Page for React
A complete React settings page with a scroll-spy side nav, profile upload, notification switches and a glass save bar. Use SettingsPage as an account settings UI with Profile, Notifications, Appearance and Danger sections, where a sticky side nav jumps to each card and focuses its heading.
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/settings-page.jsonSettingsPagedefaultSettingsLabelsdefaultSettingsPageLabelsdefaultSettingsNotificationOptions- +2 more
Account settings
Edit anything: the save bar rises and counts your changes, and the nav shows where they are. Save (or press ⌘S / Ctrl+S), or Discard. The Appearance switches are the real SheenUI preferences and apply at once. Delete account asks you to type the username.
import { SettingsPage } from "@/components/sheenui/blocks/settings-page";
import { type SettingsValues } from "@/components/sheenui/blocks/settings-page/model";
// Package build (after the first npm release, or a packed tarball): import { SettingsPage, type SettingsValues } from "@sheenui/theme";
// Your API; each call throws on failure so the page can show the error
async function call(path: string, method: string, body?: unknown) {
const res = await fetch("/api/" + path, {
method,
headers: { "Content-Type": "application/json" },
body: body === undefined ? undefined : JSON.stringify(body),
});
if (!res.ok) throw new Error("Request failed");
}
const api = {
updateProfile: (values: SettingsValues) => call("profile", "PUT", values),
exportData: () => call("export", "POST"),
deleteAccount: () => call("account", "DELETE"),
};
export function Example() {
return (
<SettingsPage
defaultValues={{
name: "Ada Lovelace",
username: "ada",
email: "ada@example.com",
bio: "Writing the first program, one punch card at a time.",
notifications: { mentions: true, comments: true, digest: true },
}}
onSave={async (values) => {
// A second argument lists the changed fields: ["name", "notifications.digest", …]
await api.updateProfile(values);
}}
onExportData={() => api.exportData()}
onDeleteAccount={() => api.deleteAccount()}
stickyTop="5rem" // below your app bar
/>
);
}Files to copy
19 folders · 21 files · 4 packages
- From
theme/src/ blocks/settings-page.tsxcomponents/alert-dialog/components/badge/components/button/components/drawer/parts/sheet.tsxcomponents/input/components/kbd/components/navbar/components/popover/components/segmented/components/spinner/components/switch/components/textarea/components/vertical-nav/blocks/settings-page/hooks/{use-controllable.ts, use-direction.ts, use-latest.ts, use-magnetic.ts, use-media-query.ts, use-preferences.ts}motion/{gate.ts, tokens.ts}lib/{cn.ts, field-control-shell.tsx, field-size.ts, form.ts, heading.ts, initials.ts, modal-tab-trap.ts, motion-props.ts, popup-motion.ts, state-light.tsx, warn-once.ts}styles/
- shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/settings-page.jsonRegistry item: settings-page. The styles need the Tailwind v4 glass UI setup.- Packages
pnpm add @base-ui/react clsx motion tailwind-merge
Your sections, your switches
Pick the sections and pass your own notification options (locked ones stay on). In a narrow column the sidebar turns into a sticky strip of pills: this one is capped at 28rem to show it on any screen.
import { SettingsPage } from "@/components/sheenui/blocks/settings-page";
import { type SettingsValues } from "@/components/sheenui/blocks/settings-page/model";
// Package build (after the first npm release, or a packed tarball): import { SettingsPage, type SettingsValues } from "@sheenui/theme";
async function save(values: SettingsValues) {
const res = await fetch("/api/alerts", {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(values),
});
if (!res.ok) throw new Error("Could not save");
}
export function Example() {
return (
<SettingsPage
title="Team alerts"
description="Where Acme tells your team about things."
sections={["notifications", "appearance"]}
notificationOptions={[
{ id: "deploys", group: "Chat", label: "Deploys", description: "Post to #releases when production updates." },
{ id: "incidents", group: "Chat", label: "Incidents", locked: true },
{ id: "billing", group: "Email", label: "Billing receipts" },
]}
defaultValues={{ notifications: { deploys: true } }}
onSave={save}
className="max-w-md"
/>
);
}Props
SettingsPageLabels keys and English defaults (64)
Keyboard
Accessibility
- The current section link has aria-current.
- Saving, errors and “unsaved changes” are announced in a polite status region.
- The browser asks before leaving with unsaved changes.
All exports on this page
SettingsPage— Props (see SettingsPageProps): defaultValues, notificationOptions, onSave(values, changed), onDeleteAccount, onExportData.defaultSettingsLabels— The former name of defaultSettingsPageLabels, kept as an alias for one release.defaultSettingsNotificationOptions— The sample Push and Email notification switches shown when notificationOptions is omitted; replace them with your own.defaultSettingsPageLabels— The English SettingsPageLabels used when labels is omitted; a partial labels prop is merged over them.
When to use the settings page
- Use SettingsPage for the account area of a SaaS app, where someone updates a profile photo, flips notification switches, picks a theme and finds the risky actions in a Danger card at the bottom. The side nav follows the scroll and moves focus to the card you jump to, so keyboard users land in the right place. Use it as a settings layout template with grouped preference rows.
- Use it when edits should be explicit, since a save bar with Save and Discard appears only after something changes and Ctrl or Cmd plus S saves from the keyboard.
- Use it for apps that let people export data, upload an avatar up to maxAvatarMb (default 5), or delete their account behind a confirmation dialog.
- Skip it when a single setting should apply the moment it is toggled, such as a theme switch in a header; a lone Switch or SegmentedControl is enough without a save flow.
- Pair it with VerticalNav and ConfirmDialog, which it builds on, and with useTheme and useMotionPreference if your own app needs to read the preferences it exposes.
Frequently asked questions
Related pages
20 blocks pages in all: browse them on All blocks.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .