Theme studio

Design a theme, preview it live, then export it. Saved in this browser.

Quick picks #10b981
Generated scale
50100200300400500600700800900
Some text is below AA

Settings that save themselves

Apply simple on/off settings the moment they change and confirm with a toast; save groups of related fields with one button.

The problem

Settings pages mix two models. Some switches save straight away, some fields wait for a Save button at the bottom of the page, and nothing tells people which is which. They change a setting, leave, and lose it, or press Save on a page that already saved.

When to use it

Use it for

  • Preferences and settings pages: notifications, privacy, workspace settings.
  • Any screen where people change a few values and then leave.

Not for

  • Changes that are expensive or affect other people, like payroll rules: use a form with Save and a confirmation.
  • Multi-field records where the fields only make sense together, like an address.

Anatomy

  1. SectionsVerticalTab or Tab per area: Profile, Notifications, Security.
  2. Instant settingsSwitchField, SegmentedControl. Each change saves on its own and shows a short Toast.
  3. Saved groupsRelated text fields in a form with its own Save button, right below the group.
  4. FailureIf an instant save fails, put the switch back and show an error Toast with a retry.

How to build it

  1. Sort each setting into instant (on/off, a choice) or saved (text fields, related values).
  2. Use SwitchField for instant settings and save each change straight away.
  3. Confirm each instant save with a polite Toast: “Leave emails turned off”.
  4. Group saved fields into a form with its own Save button directly below it, not at the bottom of the page.
  5. Never mix both models in one section. A section is either instant or has a Save button.
  6. If people leave a saved group with unsaved changes, ask before throwing them away.
app.tsx
import { SwitchField, useToast } from "@nexera-ui/react";

export function LeaveEmails({ initial }: { initial: boolean }) {
  const toasts = useToast();
  const [on, setOn] = useState(initial);
  return (
    <SwitchField
      label="Email me about leave requests"
      description="When someone on your team applies or cancels"
      isSelected={on}
      onChange={async (next) => {
        setOn(next);
        try {
          await saveSetting("leaveEmails", next);
          toasts.add({ title: next ? "Leave emails turned on" : "Leave emails turned off" });
        } catch {
          setOn(!next);
          toasts.add({ title: "Couldn't save. Try again.", tone: "danger" });
        }
      }}
    />
  );
}

Accessibility

Keyboard support
KeyAction
SpaceTurns the focused switch on or off.
Arrow keysMove between settings sections in the tab list.
EnterSubmits a saved group when focus is in one of its fields.
  • A switch announces its new state when it changes; the toast confirms that it was saved.
  • Each saved group is a form with its own heading, so its Save button is clearly its own.
  • Don't disable Save until something changes; explain instead, or people can't find out why.

Do and don't

DoApply switches immediately and confirm with a short toast.

Don'tMake people press Save after flipping a switch.

DoPut the Save button directly under the fields it saves.

Don'tPut one Save button at the bottom of a long page of tabs.

DoPut the switch back and say so when saving fails.

Don'tLeave the switch on when the setting didn't save.