> For AI agents: the complete documentation index is available at https://wallarm.github.io/design-system/llms.txt, the full documentation bundle is available at https://wallarm.github.io/design-system/llms-full.txt.

# Settings page

**Components:** [`Page`](https://wallarm.github.io/design-system/components/page.md), [`PageHeader`](https://wallarm.github.io/design-system/components/page.md), [`PageHeaderGroup`](https://wallarm.github.io/design-system/components/page.md), [`PageContent`](https://wallarm.github.io/design-system/components/page.md), [`PageTitle`](https://wallarm.github.io/design-system/components/page.md), [`RemoteShellBreadcrumb`](https://wallarm.github.io/design-system/components/remote-shell.md), [`Heading`](https://wallarm.github.io/design-system/components/heading.md), [`Text`](https://wallarm.github.io/design-system/components/text.md)


+23 more

[`Field`](https://wallarm.github.io/design-system/components/field.md), [`FieldLabel`](https://wallarm.github.io/design-system/components/field.md), [`FieldError`](https://wallarm.github.io/design-system/components/field.md), [`Input`](https://wallarm.github.io/design-system/components/input.md), [`Select`](https://wallarm.github.io/design-system/components/select.md), [`SelectInput`](https://wallarm.github.io/design-system/components/select.md), [`SegmentedControl`](https://wallarm.github.io/design-system/components/segmented-control.md), [`RadioGroup`](https://wallarm.github.io/design-system/components/radio.md), [`Radio`](https://wallarm.github.io/design-system/components/radio.md), [`Switch`](https://wallarm.github.io/design-system/components/switch.md), [`Button`](https://wallarm.github.io/design-system/components/button.md), [`Avatar`](https://wallarm.github.io/design-system/components/avatar.md), [`FileUpload`](https://wallarm.github.io/design-system/components/file-upload.md), [`Separator`](https://wallarm.github.io/design-system/components/separator.md), [`Tooltip`](https://wallarm.github.io/design-system/components/tooltip.md), [`Toast`](https://wallarm.github.io/design-system/components/toast.md), [`Dialog`](https://wallarm.github.io/design-system/components/dialog.md), [`PasswordInput`](https://wallarm.github.io/design-system/components/password-input.md), [`PasswordComplexity`](https://wallarm.github.io/design-system/components/password-complexity.md), `ThemeProvider`, [`ImageCropper`](https://wallarm.github.io/design-system/components/image-cropper.md), [`Slider`](https://wallarm.github.io/design-system/components/slider.md), `NavRail`

A 640px column of sections. Each row saves itself and a toast confirms it. No Save button.

## When to use

| Need                                      | Use                                                                                                                         | Not                         |
| ----------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | --------------------------- |
| Independent values of one account or org  | This pattern                                                                                                                | One form with a Save button |
| Values saved together (a provider config) | [Create and edit forms](https://wallarm.github.io/design-system/patterns/create-edit-forms.md) in a `Drawer`                | Rows that autosave          |
| A list of entities                        | [Resource list page](https://wallarm.github.io/design-system/patterns/resource-list-page.md)                                | A row per entity            |
| An events × channels matrix               | `Table` with `Switch` cells ([Entity table](https://wallarm.github.io/design-system/patterns/entity-table.md))              | A row per cell              |
| Email or password change                  | A `Dialog` opened from the row                                                                                              | Editing the value in place  |
| Deleting the account                      | Type-to-confirm `Dialog` ([Confirmation dialogs](https://wallarm.github.io/design-system/patterns/confirmation-dialogs.md)) | Deleting at once            |

Pick the row kind by the control:

| Control                     | Row                                                                                         |
| --------------------------- | ------------------------------------------------------------------------------------------- |
| `Input`, `Select`, `Switch` | Field row: `Field orientation='horizontal'` › `FieldLabel` + a `w-[320px] shrink-0` wrapper |
| `SegmentedControl`          | Action row with `aria-label` on the control                                                 |
| `Button`, `Avatar`          | Action row: `Text` + control                                                                |
| `RadioGroup variant='card'` | No row; the section `Heading` labels it through `aria-labelledby`                           |

## Rules

**Layout and spacing** (spacing counts in pixels, `gap-16` = 16px):

- Use `Page fullSize fixedHeight` › `PageHeader` › `PageContent`. **Never** add `PageActions`, `PageToolbar` or `PageDescription`.
- `PageHeader` › `PageHeaderGroup` › `PageTitle`. The trail is the Settings section's `RemoteShellBreadcrumb` ([Application layout](https://wallarm.github.io/design-system/patterns/app-layout.md)); **never** put `Breadcrumbs` in `PageHeader`.
- `PageContent` owns the 24px gutter. **Never** add padding around it.
- Put the sections in one `div className='flex max-w-[640px] flex-col gap-16'`. **Never** wrap it in a `Card` or padded box. **Never** give it `mx-auto`; it stays left-aligned.
- Section: `flex flex-col gap-16` › `Heading as='h2' size='xl' weight='medium' color='primary'` + a `flex flex-col` row list.
- Put `Separator spacing={16}` after every row, including a section's last row, except in the last section.
- **Never** add `gap-*` to the row list. The separators carry the rhythm.
- Wrap `Input` and `Select` in `w-[320px] shrink-0`. Leave compact controls unwrapped.
- Give action rows `flex min-h-36 items-center justify-between gap-16`. Use the default `Button` size (36px).
- Put card radios in `div className='grid grid-cols-3 gap-8'` inside the `RadioGroup`.
- **Never** pass `className` to `Field`, `FieldLabel`, `Heading`, `Text`, `RadioGroup` or `Radio`. Size them through a wrapper `div`.

**Controls:**

- Save text on blur and choices on change. **Never** save per keystroke or an unchanged value.
- Use `SelectInput` as the trigger. Over \~10 options, add `SelectHeader` › `SelectSearchInput` with `useSelectSearch`.
- Use `SegmentedControl` for 2–4 short options. Its `onChange` gets `(value: string)`.
- Use `RadioGroup variant='card'` only when options carry a picture or description (theme).
- Use `Button variant='outline' color='neutral'` for a row action that opens a dialog ("Change password").
- Make the avatar the upload trigger: `FileUploadTrigger asChild` › `Avatar as='button'` with `AvatarOverlay`.
- If a value needs confirming (email, password), open a 560 `Dialog` that asks for the current password. **Never** edit it in the row.
- If two values only make sense together, put them in one dialog. **Never** autosave half a pair.
- Put the danger zone last: text (`max-w-[320px]`) left, `Button color='destructive'` right.

**Copy:**

- Page title = rail item ("Profile"); breadcrumbs "Settings › Profile". Section titles are one noun ("Preferences"). Labels are sentence case, no colon.
- Write the toast as "\<Label> updated" with `type: 'success'`, one per saved value. This overrides `'default'` from [Feedback toasts](https://wallarm.github.io/design-system/patterns/feedback-toasts.md).

There is no `SettingsPage`, `SettingsSection` or `SettingsRow`, no `className` on `Field`, no `label` on `Separator`, no `loading` on `Switch` or `Input`, no `'system'` theme value, and no theme preview tile.

## Examples

The page frame: a title in the header, sections straight in `PageContent`.

Settings › Profile: About, Preferences, Appearance, Security and the danger zone in one
left-aligned 640px column. Text saves on blur, choices on change, and every save shows a
"\<Label> updated" toast. Email and password open dialogs; two-factor is locked by the org.

```tsx
import { type ChangeEvent, useState } from 'react';
import { Avatar, AvatarFallback, AvatarImage, AvatarOverlay } from '@wallarm-org/design-system/Avatar';
import { Button } from '@wallarm-org/design-system/Button';
import { Field, FieldError, FieldLabel } from '@wallarm-org/design-system/Field';
import { FileUpload, FileUploadTrigger, useFilePreviewUrl } from '@wallarm-org/design-system/FileUpload';
import { Heading } from '@wallarm-org/design-system/Heading';
import { Lock } from '@wallarm-org/design-system/icons';
import { Input } from '@wallarm-org/design-system/Input';
import { Page, PageContent, PageHeader, PageHeaderGroup, PageTitle } from '@wallarm-org/design-system/Page';
import { Radio, RadioDescription, RadioGroup, RadioIndicator, RadioLabel } from '@wallarm-org/design-system/Radio';
import { SegmentedControl, SegmentedControlItem } from '@wallarm-org/design-system/SegmentedControl';
import { createListCollection, Select, SelectContent, SelectInput, SelectOption, SelectOptionIndicator, SelectOptionText, SelectPositioner } from '@wallarm-org/design-system/Select';
import { Separator } from '@wallarm-org/design-system/Separator';
import { Switch, SwitchControl } from '@wallarm-org/design-system/Switch';
import { Text } from '@wallarm-org/design-system/Text';
import { useToast } from '@wallarm-org/design-system/Toast';
import { Tooltip, TooltipContent, TooltipTrigger } from '@wallarm-org/design-system/Tooltip';

export const Default = () => {
  const toast = useToast();
  const [profile, setProfile] = useState(PROFILE);
  const [name, setName] = useState(PROFILE.name);
  const [nameError, setNameError] = useState('');
  const [photos, setPhotos] = useState<File[]>([]);
  const photo = useFilePreviewUrl(photos[0]);

  const timezones = createListCollection({ items: TIMEZONES });
  const dateFormats = createListCollection({ items: DATE_FORMATS });

  const save = async (patch: Partial<Profile>, label: string) => {
    setProfile({ ...profile, ...patch });
    try {
      await onSaveProfile(patch);
      toast.create({ title: `${label} updated`, type: 'success' });
    } catch {
      toast.create({ title: `${label} update failed`, type: 'error' });
    }
  };

  const handlePhotoChange = (files: File[]) => {
    setPhotos(files);
    toast.create({ title: 'Photo updated', type: 'success' });
  };

  const handleNameChange = (event: ChangeEvent<HTMLInputElement>) => {
    setName(event.target.value);
    setNameError('');
  };

  const handleNameBlur = () => {
    const value = name.trim();
    if (!value) {
      setNameError('Enter your name');
      return;
    }
    if (value !== profile.name) save({ name: value }, 'Name');
  };

  const handleTimezoneChange = ({ value }: { value: string[] }) =>
    save({ timezone: value[0] }, 'Timezone');
  const handleDateFormatChange = ({ value }: { value: string[] }) =>
    save({ dateFormat: value[0] }, 'Date format');
  const handleTimeFormatChange = (value: string) => save({ timeFormat: value }, 'Time format');
  const handleWeeklyReportChange = ({ checked }: { checked: boolean }) =>
    save({ weeklyReport: checked }, 'Weekly report');
  const handleSidebarStyleChange = (value: string) =>
    save({ sidebarStyle: value }, 'Sidebar style');
  const handleThemeChange = ({ value }: { value: string | null }) => {
    if (value) save({ theme: value }, 'Theme');
  };

  return (
    <Page name='settings-profile' fullSize fixedHeight data-testid='profile-page'>
      <PageHeader>
        <PageHeaderGroup>
          <PageTitle>Profile</PageTitle>
        </PageHeaderGroup>
      </PageHeader>

      <PageContent>
        <div className='flex max-w-[640px] flex-col gap-16'>
          <section className='flex flex-col gap-16'>
            <Heading as='h2' size='xl' weight='medium' color='primary'>
              About
            </Heading>
            <div className='flex flex-col'>
              <div className='flex min-h-36 items-center justify-between gap-16'>
                <Text size='sm' weight='medium' color='primary'>
                  Photo
                </Text>
                <FileUpload
                  accept='image/png,image/jpeg,image/webp'
                  maxFileSize={512 * 1024}
                  value={photos}
                  onValueChange={handlePhotoChange}
                  className='w-auto'
                  data-testid='profile-photo'
                >
                  <FileUploadTrigger asChild>
                    <Avatar as='button' aria-label='Change photo'>
                      <AvatarImage src={photo} />
                      <AvatarFallback name={profile.name} />
                      <AvatarOverlay />
                    </Avatar>
                  </FileUploadTrigger>
                </FileUpload>
              </div>
              <Separator spacing={16} />
              <Field orientation='horizontal'>
                <FieldLabel>Name</FieldLabel>
                <div className='flex w-[320px] shrink-0 flex-col gap-4'>
                  <Input
                    value={name}
                    error={!!nameError}
                    onChange={handleNameChange}
                    onBlur={handleNameBlur}
                    data-testid='profile-name'
                  />
                  {nameError && <FieldError>{nameError}</FieldError>}
                </div>
              </Field>
              <Separator spacing={16} />
              <Field orientation='horizontal'>
                <FieldLabel>Email</FieldLabel>
                <div className='w-[320px] shrink-0'>
                  <Input
                    readOnly
                    value={EMAIL}
                    onClick={onEditEmail}
                    onKeyDown={handleEmailKeyDown}
                    data-testid='profile-email'
                  />
                </div>
              </Field>
              <Separator spacing={16} />
            </div>
          </section>

          <section className='flex flex-col gap-16'>
            <Heading as='h2' size='xl' weight='medium' color='primary'>
              Preferences
            </Heading>
            <div className='flex flex-col'>
              <Field orientation='horizontal'>
                <FieldLabel>Timezone</FieldLabel>
                <div className='w-[320px] shrink-0'>
                  <Select
                    collection={timezones}
                    value={[profile.timezone]}
                    onValueChange={handleTimezoneChange}
                    data-testid='profile-timezone'
                  >
                    <SelectInput className='w-full' />
                    <SelectPositioner>
                      <SelectContent>
                        {timezones.items.map(item => (
                          <SelectOption key={item.value} item={item}>
                            <SelectOptionText>{item.label}</SelectOptionText>
                            <SelectOptionIndicator />
                          </SelectOption>
                        ))}
                      </SelectContent>
                    </SelectPositioner>
                  </Select>
                </div>
              </Field>
              <Separator spacing={16} />
              <Field orientation='horizontal'>
                <FieldLabel>Date format</FieldLabel>
                <div className='w-[320px] shrink-0'>
                  <Select
                    collection={dateFormats}
                    value={[profile.dateFormat]}
                    onValueChange={handleDateFormatChange}
                    data-testid='profile-date-format'
                  >
                    <SelectInput className='w-full' />
                    <SelectPositioner>
                      <SelectContent>
                        {dateFormats.items.map(item => (
                          <SelectOption key={item.value} item={item}>
                            <SelectOptionText>{item.label}</SelectOptionText>
                            <SelectOptionIndicator />
                          </SelectOption>
                        ))}
                      </SelectContent>
                    </SelectPositioner>
                  </Select>
                </div>
              </Field>
              <Separator spacing={16} />
              <div className='flex min-h-36 items-center justify-between gap-16'>
                <Text size='sm' weight='medium' color='primary'>
                  Time format
                </Text>
                <SegmentedControl
                  aria-label='Time format'
                  value={profile.timeFormat}
                  onChange={handleTimeFormatChange}
                  data-testid='profile-time-format'
                >
                  <SegmentedControlItem value='12h'>12-hour</SegmentedControlItem>
                  <SegmentedControlItem value='24h'>24-hour</SegmentedControlItem>
                </SegmentedControl>
              </div>
              <Separator spacing={16} />
              <Field orientation='horizontal'>
                <FieldLabel>Weekly attack summary email</FieldLabel>
                <Switch
                  checked={profile.weeklyReport}
                  onCheckedChange={handleWeeklyReportChange}
                  data-testid='profile-weekly-report'
                >
                  <SwitchControl />
                </Switch>
              </Field>
              <Separator spacing={16} />
            </div>
          </section>

          <section className='flex flex-col gap-16'>
            <Heading id='appearance-heading' as='h2' size='xl' weight='medium' color='primary'>
              Appearance
            </Heading>
            <div className='flex flex-col'>
              <RadioGroup
                variant='card'
                name='theme'
                aria-labelledby='appearance-heading'
                value={profile.theme}
                onValueChange={handleThemeChange}
              >
                <div className='grid grid-cols-3 gap-8' data-testid='profile-theme'>
                  <Radio value='light'>
                    <RadioIndicator />
                    <RadioLabel>Light</RadioLabel>
                    <RadioDescription>Bright surfaces for daytime work</RadioDescription>
                  </Radio>
                  <Radio value='dark'>
                    <RadioIndicator />
                    <RadioLabel>Dark</RadioLabel>
                    <RadioDescription>Dim surfaces for a SOC at night</RadioDescription>
                  </Radio>
                  <Radio value='system'>
                    <RadioIndicator />
                    <RadioLabel>System</RadioLabel>
                    <RadioDescription>Follows your operating system</RadioDescription>
                  </Radio>
                </div>
              </RadioGroup>
              <Separator spacing={16} />
              <div className='flex min-h-36 items-center justify-between gap-16'>
                <Text size='sm' weight='medium' color='primary'>
                  Sidebar style
                </Text>
                <SegmentedControl
                  aria-label='Sidebar style'
                  value={profile.sidebarStyle}
                  onChange={handleSidebarStyleChange}
                  data-testid='profile-sidebar-style'
                >
                  <SegmentedControlItem value='neutral'>Neutral</SegmentedControlItem>
                  <SegmentedControlItem value='branded'>Branded</SegmentedControlItem>
                </SegmentedControl>
              </div>
              <Separator spacing={16} />
            </div>
          </section>

          <section className='flex flex-col gap-16'>
            <Heading as='h2' size='xl' weight='medium' color='primary'>
              Security
            </Heading>
            <div className='flex flex-col'>
              <div className='flex min-h-36 items-center justify-between gap-16'>
                <Text size='sm' weight='medium' color='primary'>
                  Password
                </Text>
                <Button
                  variant='outline'
                  color='neutral'
                  onClick={onChangePassword}
                  data-testid='profile-change-password'
                >
                  Change password
                </Button>
              </div>
              <Separator spacing={16} />
              <Field orientation='horizontal'>
                <FieldLabel>Two-factor authentication</FieldLabel>
                <div className='flex items-center gap-8'>
                  <Tooltip>
                    <TooltipTrigger asChild>
                      <Lock aria-label='Locked' />
                    </TooltipTrigger>
                    <TooltipContent>Enabled by your organization</TooltipContent>
                  </Tooltip>
                  <Switch checked disabled data-testid='profile-two-factor'>
                    <SwitchControl />
                  </Switch>
                </div>
              </Field>
              <Separator spacing={16} />
            </div>
          </section>

          <section className='flex flex-col gap-16'>
            <Heading as='h2' size='xl' weight='medium' color='primary'>
              Danger zone
            </Heading>
            <div className='flex flex-col'>
              <div className='flex min-h-36 items-center justify-between gap-16'>
                <div className='max-w-[320px]'>
                  <Text size='sm' color='secondary'>
                    Deletes your account and signs you out. Your organization's data stays.
                  </Text>
                </div>
                <Button
                  color='destructive'
                  onClick={onDeleteAccount}
                  data-testid='profile-delete-account'
                >
                  Delete account
                </Button>
              </div>
            </div>
          </section>
        </div>
      </PageContent>
    </Page>
  );
};
```

A field row saves on blur and shows an inline error; a failed save keeps the typed value.

Starts invalid: the message sits under the input inside the 320px wrapper, and nothing saves
until the name is valid. A failed save shows an error toast instead of "Name updated".

```tsx
import { type ChangeEvent, useState } from 'react';
import { Field, FieldError, FieldLabel } from '@wallarm-org/design-system/Field';
import { Heading } from '@wallarm-org/design-system/Heading';
import { Input } from '@wallarm-org/design-system/Input';
import { Page, PageContent } from '@wallarm-org/design-system/Page';
import { useToast } from '@wallarm-org/design-system/Toast';

export const InvalidValue = () => {
  const toast = useToast();
  const [savedName, setSavedName] = useState(PROFILE.name);
  const [name, setName] = useState('');
  const [nameError, setNameError] = useState('Enter your name');

  const handleNameChange = (event: ChangeEvent<HTMLInputElement>) => {
    setName(event.target.value);
    setNameError('');
  };

  // On failure the input keeps the typed value, and the next blur retries.
  const handleNameBlur = async () => {
    const value = name.trim();
    if (!value) {
      setNameError('Enter your name');
      return;
    }
    if (value === savedName) return;
    try {
      await onSaveProfile({ name: value });
      setSavedName(value);
      toast.create({ title: 'Name updated', type: 'success' });
    } catch {
      toast.create({ title: 'Name update failed', type: 'error' });
    }
  };

  return (
    <Page name='settings-profile' data-testid='profile-page'>
      <PageContent>
        <div className='flex max-w-[640px] flex-col gap-16'>
          <section className='flex flex-col gap-16'>
            <Heading as='h2' size='xl' weight='medium' color='primary'>
              About
            </Heading>
            <div className='flex flex-col'>
              <Field orientation='horizontal'>
                <FieldLabel>Name</FieldLabel>
                <div className='flex w-[320px] shrink-0 flex-col gap-4'>
                  <Input
                    value={name}
                    error={!!nameError}
                    onChange={handleNameChange}
                    onBlur={handleNameBlur}
                    data-testid='profile-name'
                  />
                  {nameError && <FieldError>{nameError}</FieldError>}
                </div>
              </Field>
            </div>
          </section>
        </div>
      </PageContent>
    </Page>
  );
};
```

An action row labels with `Text` and `aria-label`, not `FieldLabel`.

The control saves on change; the row keeps its 36px height whatever the control is.

```tsx
import { useState } from 'react';
import { Heading } from '@wallarm-org/design-system/Heading';
import { Page, PageContent } from '@wallarm-org/design-system/Page';
import { SegmentedControl, SegmentedControlItem } from '@wallarm-org/design-system/SegmentedControl';
import { Text } from '@wallarm-org/design-system/Text';
import { useToast } from '@wallarm-org/design-system/Toast';

export const ActionRow = () => {
  const toast = useToast();
  const [sidebarStyle, setSidebarStyle] = useState(PROFILE.sidebarStyle);

  const handleSidebarStyleChange = (value: string) => {
    setSidebarStyle(value);
    onSaveProfile({ sidebarStyle: value });
    toast.create({ title: 'Sidebar style updated', type: 'success' });
  };

  return (
    <Page name='settings-profile' data-testid='profile-page'>
      <PageContent>
        <div className='flex max-w-[640px] flex-col gap-16'>
          <section className='flex flex-col gap-16'>
            <Heading as='h2' size='xl' weight='medium' color='primary'>
              Appearance
            </Heading>
            <div className='flex flex-col'>
              <div className='flex min-h-36 items-center justify-between gap-16'>
                <Text size='sm' weight='medium' color='primary'>
                  Sidebar style
                </Text>
                <SegmentedControl
                  aria-label='Sidebar style'
                  value={sidebarStyle}
                  onChange={handleSidebarStyleChange}
                  data-testid='profile-sidebar-style'
                >
                  <SegmentedControlItem value='neutral'>Neutral</SegmentedControlItem>
                  <SegmentedControlItem value='branded'>Branded</SegmentedControlItem>
                </SegmentedControl>
              </div>
            </div>
          </section>
        </div>
      </PageContent>
    </Page>
  );
};
```

An org-locked value puts the tooltip on `Lock`; a disabled `Switch` never opens one.

The row stays visible with its current value, so users see what the org enforces.

```tsx
import { Field, FieldLabel } from '@wallarm-org/design-system/Field';
import { Heading } from '@wallarm-org/design-system/Heading';
import { Lock } from '@wallarm-org/design-system/icons';
import { Page, PageContent } from '@wallarm-org/design-system/Page';
import { Switch, SwitchControl } from '@wallarm-org/design-system/Switch';
import { Tooltip, TooltipContent, TooltipTrigger } from '@wallarm-org/design-system/Tooltip';

export const LockedValue = () => (
  <Page name='settings-profile' data-testid='profile-page'>
    <PageContent>
      <div className='flex max-w-[640px] flex-col gap-16'>
        <section className='flex flex-col gap-16'>
          <Heading as='h2' size='xl' weight='medium' color='primary'>
            Security
          </Heading>
          <div className='flex flex-col'>
            <Field orientation='horizontal'>
              <FieldLabel>Two-factor authentication</FieldLabel>
              <div className='flex items-center gap-8'>
                <Tooltip>
                  <TooltipTrigger asChild>
                    <Lock aria-label='Locked' />
                  </TooltipTrigger>
                  <TooltipContent>Enabled by your organization</TooltipContent>
                </Tooltip>
                <Switch checked disabled data-testid='profile-two-factor'>
                  <SwitchControl />
                </Switch>
              </div>
            </Field>
          </div>
        </section>
      </div>
    </PageContent>
  </Page>
);
```

A read-only email opens its dialog on click or Enter.

The dialog asks for the current password before it changes the email.

```tsx
import { Field, FieldLabel } from '@wallarm-org/design-system/Field';
import { Heading } from '@wallarm-org/design-system/Heading';
import { Input } from '@wallarm-org/design-system/Input';
import { Page, PageContent } from '@wallarm-org/design-system/Page';

export const ReadOnlyValue = () => (
  <Page name='settings-profile' data-testid='profile-page'>
    <PageContent>
      <div className='flex max-w-[640px] flex-col gap-16'>
        <section className='flex flex-col gap-16'>
          <Heading as='h2' size='xl' weight='medium' color='primary'>
            About
          </Heading>
          <div className='flex flex-col'>
            <Field orientation='horizontal'>
              <FieldLabel>Email</FieldLabel>
              <div className='w-[320px] shrink-0'>
                <Input
                  readOnly
                  value={EMAIL}
                  onClick={onEditEmail}
                  onKeyDown={handleEmailKeyDown}
                  data-testid='profile-email'
                />
              </div>
            </Field>
          </div>
        </section>
      </div>
    </PageContent>
  </Page>
);
```

## States

| State                  | Show                                              | Example component                        |
| ---------------------- | ------------------------------------------------- | ---------------------------------------- |
| Saved                  | Success toast "\<Label> updated"                  | `useToast().create({ type: 'success' })` |
| Save failed            | Error toast; keep the typed value                 | `useToast().create({ type: 'error' })`   |
| Invalid value          | Message inside the 320 wrapper; no save, no toast | `Input error` + `FieldError`             |
| Saving a select        | Disabled until the request ends                   | `Select disabled`                        |
| Saving a button action | Loading button; never disable the page            | `Button loading`                         |
| Saving a switch        | Disabled until the request ends                   | `Switch disabled`                        |
| Locked by the org      | Disabled control + `Lock` tooltip; keep the row   | `Tooltip` › `TooltipTrigger`             |
| Opens a dialog         | Read-only value                                   | `Input readOnly`                         |

Pass `error` to `Input`; `Field invalid` alone does not mark it.

While a value saves, only its own control changes.

Saving: a select and a switch stay disabled until the request ends, and a button action shows
its loading state. The rest of the page stays usable.

```tsx
import { Button } from '@wallarm-org/design-system/Button';
import { Field, FieldLabel } from '@wallarm-org/design-system/Field';
import { Heading } from '@wallarm-org/design-system/Heading';
import { Page, PageContent, PageHeader, PageHeaderGroup, PageTitle } from '@wallarm-org/design-system/Page';
import { createListCollection, Select, SelectContent, SelectInput, SelectOption, SelectOptionIndicator, SelectOptionText, SelectPositioner } from '@wallarm-org/design-system/Select';
import { Separator } from '@wallarm-org/design-system/Separator';
import { Switch, SwitchControl } from '@wallarm-org/design-system/Switch';
import { Text } from '@wallarm-org/design-system/Text';

export const Saving = () => {
  const timezones = createListCollection({ items: TIMEZONES });

  return (
    <Page name='settings-profile' fullSize fixedHeight data-testid='profile-page'>
      <PageHeader>
        <PageHeaderGroup>
          <PageTitle>Profile</PageTitle>
        </PageHeaderGroup>
      </PageHeader>

      <PageContent>
        <div className='flex max-w-[640px] flex-col gap-16'>
          <section className='flex flex-col gap-16'>
            <Heading as='h2' size='xl' weight='medium' color='primary'>
              Preferences
            </Heading>
            <div className='flex flex-col'>
              <Field orientation='horizontal'>
                <FieldLabel>Timezone</FieldLabel>
                <div className='w-[320px] shrink-0'>
                  <Select
                    collection={timezones}
                    defaultValue={['Asia/Singapore']}
                    disabled
                    data-testid='profile-timezone'
                  >
                    <SelectInput className='w-full' />
                    <SelectPositioner>
                      <SelectContent>
                        {timezones.items.map(item => (
                          <SelectOption key={item.value} item={item}>
                            <SelectOptionText>{item.label}</SelectOptionText>
                            <SelectOptionIndicator />
                          </SelectOption>
                        ))}
                      </SelectContent>
                    </SelectPositioner>
                  </Select>
                </div>
              </Field>
              <Separator spacing={16} />
              <Field orientation='horizontal'>
                <FieldLabel>Weekly attack summary email</FieldLabel>
                <Switch checked disabled data-testid='profile-weekly-report'>
                  <SwitchControl />
                </Switch>
              </Field>
              <Separator spacing={16} />
            </div>
          </section>

          <section className='flex flex-col gap-16'>
            <Heading as='h2' size='xl' weight='medium' color='primary'>
              Security
            </Heading>
            <div className='flex flex-col'>
              <div className='flex min-h-36 items-center justify-between gap-16'>
                <Text size='sm' weight='medium' color='primary'>
                  Active sessions
                </Text>
                <Button
                  variant='outline'
                  color='neutral'
                  loading
                  data-testid='profile-sign-out-sessions'
                >
                  Sign out of all sessions
                </Button>
              </div>
            </div>
          </section>
        </div>
      </PageContent>
    </Page>
  );
};
```

## What your app owns

| Concern                    | Recipe                                                                                                                                                                                                                                         |
| -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Saving, validation, toasts | Call your API, then `useToast().create(...)`                                                                                                                                                                                                   |
| Email and password dialogs | `Dialog` from `@wallarm-org/design-system/Dialog`; `PasswordInput` with `PasswordComplexity` and `passwordValidators` for the new password. See [Create and edit forms](https://wallarm.github.io/design-system/patterns/create-edit-forms.md) |
| Avatar crop                | `Dialog` with `ImageCropper` and `Slider`; `FileUpload` only holds the file                                                                                                                                                                    |
| "System" theme             | `useTheme().setTheme` takes `'light'` or `'dark'`. Store `'system'` yourself and resolve it with `matchMedia('(prefers-color-scheme: dark)')`                                                                                                  |
| Theme previews             | Pass your own image in `RadioDescription`                                                                                                                                                                                                      |
| Sidebar style              | `useTheme().frameStyle` / `setFrameStyle('neutral' \| 'branded')`                                                                                                                                                                              |
| Sidebar mode               | Store it yourself; pass `mode` (`'expanded'`, `'collapsed'`, `'compact'`) to `NavRail`. "Adaptive" is your logic                                                                                                                               |
| Date and time formats      | Option labels built from the current date                                                                                                                                                                                                      |
| Org locks                  | Which values are locked                                                                                                                                                                                                                        |
| Delete account             | Type-to-confirm `Dialog`, then sign the user out                                                                                                                                                                                               |

## Related

- [Application layout](https://wallarm.github.io/design-system/patterns/app-layout.md)
- [Spacing](https://wallarm.github.io/design-system/foundations/spacing.md)
- [Typography](https://wallarm.github.io/design-system/foundations/typography.md)
- [Resource list page](https://wallarm.github.io/design-system/patterns/resource-list-page.md)
- [Create and edit forms](https://wallarm.github.io/design-system/patterns/create-edit-forms.md)
- [Confirmation dialogs](https://wallarm.github.io/design-system/patterns/confirmation-dialogs.md)
- [Feedback toasts](https://wallarm.github.io/design-system/patterns/feedback-toasts.md)
- [Entity table](https://wallarm.github.io/design-system/patterns/entity-table.md)
