# Settings

> The settings page of an AI product. Handles a save bar that appears only when something changed, field errors and loading states.

Canonical: https://hextaui.com/blocks/settings
Last updated: 2026-10-29

## Overview

Cursor, Claude and Codex all settled on the same settings page: a filled sidebar with search and a handful of grouped sections, and on the right, cards of rows with a label and description on the left and a quiet control on the right. Settings is that page. It holds your sections and handles the parts every settings page gets wrong: losing edits, saving twice, and the jump from a sidebar on desktop to a list on a phone.

Rows take any control. SettingsSelect is the compact value picker those apps use, a small outlined button that opens a menu of choices, and SettingsNumber is a stepper you can hold to repeat. Both are named by its row so screen readers hear "Chat font, Serif". SettingsLink is a row that opens something else, with a chevron or an arrow for links that leave the app. SettingsNested slides open dependent options under a switch, like network access under Run code. Search filters the sidebar by label, description and keywords, and Enter opens the first match. SettingsChoice turns a choice into picture cards, so people pick a theme or a density by what it looks like.

Nothing saves until you say so. As soon as a value differs from what's saved, a dark island rises from the bottom with Discard and Save, and the section's entry in the sidebar gets a dot. Change it back and the bar goes away. Try to open another section, go back on a phone or close the tab, and the switch is blocked: the bar shakes and says to save or discard first, and the browser asks before the tab closes. ⌘S or Ctrl+S saves from anywhere.

Saving shows its progress in the button, then the island shrinks to a Saved check and slides away. If your checks fail, the fields show their errors, focus moves to the first one, and the bar says how many to fix. If the server says no, return errors for the fields or throw, and the draft stays exactly as typed. Keep typing while it saves and the bar stays up for the newer edits.

On a phone the sidebar becomes a grouped list with descriptions and chevrons. Tapping a section slides it in over the list with a back button, and focus moves to its heading. While a section's data loads it shows a skeleton shaped like rows of switches, or your own through the skeleton prop, and an error with Try again if loading fails.

## Installation

### Step 1: Get HextaUI Pro

One payment unlocks every block, including future ones. [See pricing](https://hextaui.com/pricing).

### Step 2: Add the Pro registry to components.json

```json title="components.json"
{
  "registries": {
    "@hextaui-pro": {
      "url": "https://hextaui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${HEXTAUI_PRO_TOKEN}"
      }
    }
  }
}
```

### Step 3: Add your token

Create a token on your [account page](https://hextaui.com/account) and put it in `.env.local` as `HEXTAUI_PRO_TOKEN`.

### Step 4: Add the block

```bash
npx shadcn@latest add @hextaui-pro/settings
```

## Usage

### Wire a section to your API

useSettingsForm keeps a draft of the values you pass. Return field errors from onSave to show them under the field, or throw to show the message in the save bar. Either way the draft stays.

```tsx
"use client"

import { IconAdjustmentsHorizontal, IconUserCircle } from "@tabler/icons-react"

import { Input } from "@/components/ui/input"
import { Switch } from "@/components/ui/switch"

import {
  SettingsGroup,
  SettingsRow,
  SettingsSection,
  SettingsShell,
  useSettingsForm,
  type SettingsSectionItem,
} from "@/components/blocks/settings/settings"

const sections: SettingsSectionItem[] = [
  { id: "profile", label: "Profile", icon: <IconUserCircle />, group: "Account" },
  { id: "preferences", label: "Preferences", icon: <IconAdjustmentsHorizontal />, group: "Account" },
]

type Profile = { name: string; digest: boolean }

function ProfileForm({ profile }: { profile: Profile }) {
  const form = useSettingsForm({
    values: profile,
    validate: (values) => (values.name.trim() ? {} : { name: "Enter your name." }),
    onSave: async (values) => {
      const response = await fetch("/api/profile", {
        method: "PATCH",
        body: JSON.stringify(values),
      })
      if (response.status === 409) return { name: "That name is taken." }
      if (!response.ok) throw new Error("Check your connection and try again.")
    },
  })

  return (
    <SettingsGroup>
      <SettingsRow label="Name" error={form.errors.name}>
        <Input
          value={form.values.name}
          onChange={(event) => form.setValue("name", event.target.value)}
          className="@md/field-group:w-64"
        />
      </SettingsRow>
      <SettingsRow label="Weekly digest" description="A summary every Monday." layout="inline">
        <Switch
          checked={form.values.digest}
          onCheckedChange={(checked) => form.setValue("digest", checked)}
        />
      </SettingsRow>
    </SettingsGroup>
  )
}

export function SettingsPage({ profile }: { profile: Profile }) {
  return (
    <SettingsShell sections={sections} className="h-svh">
      <SettingsSection id="profile">
        <ProfileForm profile={profile} />
      </SettingsSection>
      <SettingsSection id="preferences">{null}</SettingsSection>
    </SettingsShell>
  )
}
```

### One route per section

Control the active section with value and onValueChange to give each section its own URL. The shell still blocks the switch while something is unsaved, so onValueChange only fires when it's safe to leave.

```tsx
"use client"

import { usePathname, useRouter } from "next/navigation"

import {
  SettingsSection,
  SettingsShell,
  type SettingsSectionItem,
} from "@/components/blocks/settings/settings"

const sections: SettingsSectionItem[] = [
  { id: "profile", label: "Profile", group: "Account" },
  { id: "billing", label: "Billing", group: "Workspace" },
]

export function SettingsLayout({ children }: { children: React.ReactNode }) {
  const router = useRouter()
  const section = usePathname().split("/").at(-1) ?? "profile"

  return (
    <SettingsShell
      sections={sections}
      value={section}
      onValueChange={(id) => router.push(`/settings/${id}`)}
      className="h-svh"
    >
      <SettingsSection id={section}>{children}</SettingsSection>
    </SettingsShell>
  )
}
```

### Loading and errors

Pass status while a section's data loads. The skeleton waits 150ms so fast loads never flash, and an error state offers Try again through onRetry.

```tsx
"use client"

import * as React from "react"

import { Switch } from "@/components/ui/switch"

import { SettingsGroup, SettingsRow, SettingsSection, useSettingsForm } from "@/components/blocks/settings/settings"

type Alerts = { invoices: boolean; overage: boolean }

function AlertsForm({ alerts }: { alerts: Alerts }) {
  const form = useSettingsForm({
    values: alerts,
    onSave: async (values) => {
      const response = await fetch("/api/alerts", { method: "PUT", body: JSON.stringify(values) })
      if (!response.ok) throw new Error("Try again in a moment.")
    },
  })

  return (
    <SettingsGroup>
      <SettingsRow label="Invoices" layout="inline">
        <Switch
          checked={form.values.invoices}
          onCheckedChange={(checked) => form.setValue("invoices", checked)}
        />
      </SettingsRow>
      <SettingsRow label="Usage over 80%" layout="inline">
        <Switch
          checked={form.values.overage}
          onCheckedChange={(checked) => form.setValue("overage", checked)}
        />
      </SettingsRow>
    </SettingsGroup>
  )
}

export function AlertsSection() {
  const [alerts, setAlerts] = React.useState<Alerts | null>(null)
  const [failed, setFailed] = React.useState(false)

  const load = React.useCallback(() => {
    setFailed(false)
    fetch("/api/alerts")
      .then((response) => (response.ok ? response.json() : Promise.reject(response)))
      .then(setAlerts)
      .catch(() => setFailed(true))
  }, [])

  React.useEffect(load, [load])

  return (
    <SettingsSection
      id="alerts"
      status={failed ? "error" : alerts ? "ready" : "loading"}
      onRetry={load}
    >
      {alerts ? <AlertsForm alerts={alerts} /> : null}
    </SettingsSection>
  )
}
```

## Anatomy

The parts you compose, from the outside in.

| Part | Description |
| --- | --- |
| `SettingsShell` | The page: the section nav, the content column, the save bar and the guard against leaving with unsaved changes. |
| `SettingsSection` | One section. Renders only while it's open, with its heading, optional actions, and loading or error states. |
| `SettingsGroup` | A titled card of rows, with an optional footer for a note about the group. |
| `SettingsRow` | A label, description and control, wired together for screen readers, with the field error underneath. |
| `SettingsSelect` | A quiet picker for one value from a short list. |
| `SettingsLink` | A row that opens a page, a dialog or an external link. |
| `SettingsNested` | Dependent options that slide open while a parent switch is on. |
| `SettingsNumber` | A number stepper with − and + that repeat while held, built on Base UI's Number Field. |
| `SettingsChoice` | Picture cards for picking one option, like a theme or a density, with radio semantics. |
| `SettingsSkeleton` | The loading placeholder, configurable by rows per group and control shape. |
| `useSettingsForm` | The draft for one section. Tracks what changed, validates, saves and connects the section to the save bar. |
| `useSettingsNavigate` | Opens a section from inside the content, guarded like the sidebar. |

## API reference

### SettingsShell

Also accepts every div prop.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `sections` | `SettingsSectionItem[]` | – | { id, label, description?, icon?, group?, keywords?, href? }. Consecutive items with the same group share a heading. keywords help search find a section, and href makes the item an external link. |
| `value` | `string` | – | The open section, when you control it. |
| `defaultValue` | `string` | `first section` | The section open at first. |
| `onValueChange` | `(value: string) => void` | – | Called when someone opens another section. Never called while something is unsaved or saving. |
| `title` | `ReactNode` | `"Settings"` | The page heading above the nav, and the back button's label on phones. |
| `description` | `ReactNode` | – | A line under the title. |
| `navHeader` | `ReactNode` | – | Content at the top of the sidebar, like a Back link to the app. |
| `searchable` | `boolean` | `false` | Adds a search field above the sections. |
| `navFooter` | `ReactNode` | – | Content pinned to the bottom of the sidebar, like the signed-in user. |
| `groupLabels` | `boolean` | `true` | Shows each group's name above it. Turn off to separate groups by space alone; the names still label the groups for screen readers. |

### SettingsSection

Also accepts every section prop.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `id` | `string` | – | Matches an id in sections. |
| `title` | `ReactNode` | `the section's label` | The heading. |
| `description` | `ReactNode` | `the section's description` | The line under the heading. |
| `actions` | `ReactNode` | – | Buttons beside the heading. |
| `status` | `"ready" \| "loading" \| "error"` | `"ready"` | Shows a skeleton or an error instead of the children. |
| `skeleton` | `ReactNode` | `<SettingsSkeleton />` | What to show while status is loading. |
| `error` | `ReactNode` | – | The message for the error state. |
| `onRetry` | `() => void` | – | Adds Try again to the error state. |

### SettingsGroup

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `title` | `ReactNode` | – | Heading above the card. |
| `description` | `ReactNode` | – | A muted line under the heading, for what the group is about. |
| `footer` | `ReactNode` | – | A muted strip at the bottom of the card, for notes like what a change affects. |

### SettingsRow

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `label` | `ReactNode` | – | Labels the control inside the row. |
| `description` | `ReactNode` | – | Help text, read out with the control. |
| `error` | `string` | – | Marks the control invalid and shows the message under the row. |
| `layout` | `"auto" \| "inline" \| "stacked"` | `"auto"` | auto puts the control beside the label when the card is wide and under it when narrow. inline keeps it beside the label, for switches. stacked always puts it underneath, for text areas. |
| `disabled` | `boolean` | `false` | Disables the row's field. |

### SettingsSelect

Also accepts every Button prop.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `value` | `string` | – | The chosen value. |
| `onValueChange` | `(value: string) => void` | – | Called with the new value. |
| `options` | `{ value, label }[]` | – | The choices, in order. |

### SettingsChoice

A radio group, so arrow keys move between cards. Also accepts every Base UI RadioGroup prop.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `value` | `string` | – | The chosen option. |
| `onValueChange` | `(value: string) => void` | – | Called with the new option. |
| `options` | `{ value, label, preview }[]` | – | Each card's picture and the name under it. |
| `columns` | `2 \| 3 \| 4` | `3` | Cards per row. 4 drops to 2 when the row is narrow. |
| `ratio` | `"card" \| "wide"` | `"card"` | 16:10 previews, or 2:1 for shorter ones. |

### SettingsNumber

Also accepts every Base UI NumberField.Root prop, such as format and smallStep.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `value` | `number \| null` | – | The current number. |
| `onValueChange` | `(value: number \| null) => void` | – | Called as the number changes. |
| `min` | `number` | – | Lowest value. The − button disables there. |
| `max` | `number` | – | Highest value. The + button disables there. |
| `step` | `number` | `1` | How much each press or arrow key changes it. |

### SettingsLink

Also accepts every anchor prop. Renders a button when there's no href.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `label` | `ReactNode` | – | The row's title. |
| `description` | `ReactNode` | – | A line under the title. |
| `external` | `boolean` | `false` | Opens href in a new tab and shows an arrow instead of a chevron. |

### SettingsNested

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `open` | `boolean` | – | Shows the options. Usually the parent switch's value. |

### SettingsSkeleton

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `groups` | `number[]` | `[3, 2]` | How many rows each placeholder group has. |
| `control` | `"switch" \| "select" \| "input"` | `"switch"` | The shape on the right of each row. |

### useSettingsForm

Returns { values, setValue, errors, dirty, status, save, discard }.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `values` | `Values` | – | What's saved now. When it changes and there are no edits, the draft follows it. |
| `onSave` | `(values) => void \| errors \| Promise<void \| errors>` | – | Save the draft. Return { field: message } to show field errors, or throw to show the message in the save bar. |
| `validate` | `(values) => errors \| undefined` | – | Runs before onSave. Any error stops the save and focuses the first invalid field. |

### useSettingsNavigate

Returns a function that opens a section from anywhere inside the shell, like a banner's Open button. It respects unsaved changes the same way the sidebar does.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `navigate` | `(id: string) => void` | – | Opens the section, or shakes the save bar if something is unsaved. |

## Keyboard

| Key | Action |
| --- | --- |
| `Tab` | Moves through the nav, then the section, then the save bar when it's open. |
| `Enter` | Opens the focused section. |
| `↑` `↓` | In a stepper, change the number by one step. Shift moves by ten. |
| `Enter` | In the search field, opens the first matching section. Escape clears the search. |
| `⌘` `S` | Saves while something is unsaved. Ctrl+S on Windows and Linux. |

## Accessibility

- The nav is a landmark, and the open section is marked as the current page.
- Each section is a region named by its heading. On phones, focus moves to the heading when a section opens and back to its row when you go back.
- Rows use Field, so labels, descriptions and errors are attached to the control.
- Blocked navigation is announced politely, and a failed save is announced as an alert.
- The save bar and any hidden panel are inert, so they're out of the tab order and hidden from screen readers.
- With reduced motion, panels fade instead of sliding and the save bar's shake becomes a ring.

## Built with

The free HextaUI components Settings is made from. Each one installs on its own.

- [Button](https://hextaui.com/docs/button) - Buttons in every variant and size, with a built-in loading, success and error flow that skips the spinner for fast requests.
- [Collapsible](https://hextaui.com/docs/collapsible) - A panel that shows and hides with height motion you can reverse mid-way, without jumping the layout.
- [Dropdown menu](https://hextaui.com/docs/dropdown-menu) - A menu of actions and options behind a button, with groups, submenus, checkbox and radio items, and shortcuts.
- [Empty](https://hextaui.com/docs/empty) - A placeholder for screens with nothing to show yet, with an icon, a message and the next action.
- [Field](https://hextaui.com/docs/field) - Labels, descriptions and errors wired to their control, with validation states and layouts for forms.
- [Input group](https://hextaui.com/docs/input-group) - An input with icons, text, buttons or a keyboard hint attached, sharing one border and focus ring.
- [Skeleton](https://hextaui.com/docs/skeleton) - Placeholders that wait 150ms before showing, take the exact size of the content they wrap, and fade it in without moving anything.

## Code

6 files, added to components/blocks/settings.
