# Notification preferences

- **[App UI](/app/)**
- **[Settings](/app/settings/)**
- **Notification preferences**

A list of notification preferences, each a title, one line of explanation and a switch (applies at once) or a checkbox (saved with a button).

## Notes

- **When to use it**: A list of preferences with an on or off state per row. It fits a settings page; to read what has already arrived, use `app-notifications-inbox`. Choose switch when each change should apply at once and checkbox when rows are saved together.
- **Writing for it**: - The control enum decides the whole block. With switch there is no save button, so the save text (30) is only used with checkbox.
- A row title holds 60 characters and the description 140. Describe when the message is sent, such as 'every Monday at 08:00', rather than repeating the title.
- The on field carries the starting state of each row, so set it to the person's current choice and not to a default you hope for. Two to seven rows are allowed.
- **Watch out for**: The block does not save anything by itself. Switches change visually on click, but persisting them is up to the host app, so a preview that looks saved is not a stored preference.

## Pairs well with

- **[App, profile settings](/blocks/app/settings-profile)**
- **[App, notification inbox](/blocks/app/notifications-inbox)**
- **[App, danger zone](/blocks/app/settings-danger)**

## Usage

The block in a page, with its default content (long lists shortened). Every prop is in the table below.

section.tsx

```
import { Theme } from '@/components/klarhimmel/theme/style';
import { BlockSurface } from '@/components/klarhimmel/blocks/surface';
import AppSettingsNotifications from '@/components/klarhimmel/blocks/app-settings-notifications';

export default function Section() {
  return (
    <Theme theme="brand">
      <BlockSurface>
        <AppSettingsNotifications props={{
          "eyebrow": "Settings",
          "title": "Notifications",
          "description": "Say what the person can choose and how it reaches them.",
          "control": "switch",
          "rows": [
            {
              "title": "Name an event",
              "description": "Say what happens when it occurs.",
              "on": true
            },
            {
              "title": "Name a second event",
              "description": "Say what the person learns from it.",
              "on": true
            },
            {
              "title": "Name a recurring one",
              "description": "Say what it contains and how often it arrives.",
              "on": false
            },
            {
              "title": "Name a rare one",
              "description": "Say what it contains and how rare it is.",
              "on": false
            }
          ],
          "save": "Save preferences"
        }} />
      </BlockSurface>
    </Theme>
  );
}
```

## Props

The type, default and text limit of every prop. On a real page, over-limit text is kept and checkSections flags it (Installation, Check a page before you ship); this live preview shows the default until it fits. The panel above edits all props.

- **eyebrow**: Text, up to 60 characters. Optional; empty is not rendered.
- **title**: Text, up to 120 characters.
- **description**: Text, up to 300 characters. Optional; empty is not rendered.
- **control**: One of 'switch', 'checkbox'.
- **rows**: List of 2 to 7. Each item: title, description, on.
- **save**: Text, up to 30 characters.
- **headingLevel**: One of '1', '2'. Optional; empty is not rendered.

## Install

- **CLI**

  ```
  npx shadcn add @klarhimmel/app-settings-notifications
  ```

Uses

- Switch
- Checkbox
- Button

- **About**: A list of notification preferences, each a title, one line of explanation and a switch (applies at once) or a checkbox (saved with a button). The on/off state of every row is a prop.
- **States**: Switch rows (apply at once) or checkbox rows (saved with a button). Each row is on or off. New project? Set it up once: /get-started/installation.
