# Settings row

What a settings page is made of: a label, one sentence under it and the control at the end, ruled like the list with a hairline between rows and nothing else drawn. A row with a switch or a check is one label, so pressing anywhere on it turns the control; a row with a key, a select or a value is a plain box, so a press means what the key says.

Kit part · Free · https://tactileui.dev/parts/settings-row

- Element: `<label class="tui-settings__row">`
- Needs: `kit.css` only, no script ([how to install the kit](https://tactileui.dev/docs/installation#the-kit))
- Categories: Forms, Lists
- Finishes: Aluminium, Graphite, Oak, Walnut, Porcelain, Black, Daylight, Night, Paper, Phosphor, E-paper, AMOLED
- Volumes: Tactile, Quiet

## Variants

### A switch · the row is the label

```html
<div class="tui-settings" role="group"><label class="tui-settings__row"><span class="tui-settings__text"><span class="tui-settings__title" id="sr61-t">Email receipts</span><span class="tui-settings__desc" id="sr61-d">Send a receipt after every payment.</span></span><input class="tui-switch" type="checkbox" role="switch" aria-labelledby="sr61-t" aria-describedby="sr61-d" checked tabindex="-1"></label></div>
```

### A check

```html
<div class="tui-settings" role="group"><label class="tui-settings__row"><span class="tui-settings__text"><span class="tui-settings__title" id="sr62-t">Remember this device</span><span class="tui-settings__desc" id="sr62-d">Stay signed in for thirty days.</span></span><input class="tui-check" type="checkbox" aria-labelledby="sr62-t" aria-describedby="sr62-d" checked tabindex="-1"></label></div>
```

### A key at the end

```html
<div class="tui-settings" role="group"><div class="tui-settings__row"><span class="tui-settings__text"><span class="tui-settings__title" id="sr63-t">Two-step sign-in</span><span class="tui-settings__desc" id="sr63-d">Ask for a code from your phone.</span></span><button class="tui-key tui-key--sm" type="button" tabindex="-1">Set up</button></div></div>
```

### A select at the end

```html
<div class="tui-settings" role="group"><div class="tui-settings__row"><span class="tui-settings__text"><span class="tui-settings__title" id="sr64-t">Language</span><span class="tui-settings__desc" id="sr64-d">The words in your dashboard.</span></span><select class="tui-select" aria-labelledby="sr64-t" tabindex="-1"><option>English (UK)</option></select></div></div>
```

### A value and a key

```html
<div class="tui-settings" role="group"><div class="tui-settings__row"><span class="tui-settings__text"><span class="tui-settings__title" id="sr65-t">Billing plan</span><span class="tui-settings__desc" id="sr65-d">Team, billed monthly.</span></span><span class="tui-settings__end"><span class="tui-settings__value">£12 a seat</span><button class="tui-key tui-key--sm" type="button" tabindex="-1">Change</button></span></div></div>
```

### Danger · the words say so

```html
<div class="tui-settings" role="group"><div class="tui-settings__row tui-settings__row--danger"><span class="tui-settings__text"><span class="tui-settings__title" id="sr66-t">Delete this workspace</span><span class="tui-settings__desc" id="sr66-d">Removes every project and cannot be undone.</span></span><button class="tui-key tui-key--sm tui-key--danger" type="button" tabindex="-1">Delete…</button></div></div>
```

### A page of rows · with headings

```html
<div style="width:min(100%,420px)"><div class="tui-settings" role="group" aria-label="Notifications"><h3 class="tui-settings__head">Notifications</h3><label class="tui-settings__row"><span class="tui-settings__text"><span class="tui-settings__title" id="sr67-t">Email receipts</span></span><input class="tui-switch" type="checkbox" role="switch" aria-labelledby="sr67-t" checked tabindex="-1"></label><label class="tui-settings__row"><span class="tui-settings__text"><span class="tui-settings__title" id="sr68-t">Weekly summary</span></span><input class="tui-switch" type="checkbox" role="switch" aria-labelledby="sr68-t" tabindex="-1"></label></div></div>
```

### Disabled

```html
<div class="tui-settings" role="group"><label class="tui-settings__row"><span class="tui-settings__text"><span class="tui-settings__title" id="sr69-t">Weekly summary</span><span class="tui-settings__desc" id="sr69-d">Turned off by your administrator.</span></span><input class="tui-switch" type="checkbox" role="switch" aria-labelledby="sr69-t" aria-describedby="sr69-d" tabindex="-1" disabled></label></div>
```

## Every state

- Rest
- Hover
- Focus
- On
- Disabled

Hover, pressed and focus are forced with `.is-hover`, `.is-down` and `.is-focus`; checked and disabled are real.

## API

| Name | Kind | Values | What it does |
| - | - | - | - |
| .tui-settings | class | role="group", with an aria-label | The page or the section: rows ruled like a list. Put a .tui-settings__head heading first to print a section name. |
| label.tui-settings__row | element | holds .tui-settings__text and a switch or check | A row that is one control. Pressing anywhere on it turns the switch. Name the input with aria-labelledby on the title and describe it with the sentence. |
| div.tui-settings__row | element | holds .tui-settings__text and a key, select or value | A row that holds a control which does something when pressed. Only the control is pressable. |
| .tui-settings__text > .tui-settings__title + .tui-settings__desc | class | two lines | The label and the one sentence under it. Keep the sentence to what changes when the control is turned. |
| .tui-settings__end · .tui-settings__value | class | at the end of a row | A printed value beside its key: “£12 a seat” and Change. |
| .tui-settings__row--danger | modifier | on the row | The title reads in the error ink, and the key says what it destroys. |
| role="switch" | attribute | on .tui-switch | Makes the checkbox a switch to a screen reader: “Email receipts, switch, on”. |

## Markup

```html
<div class="tui-settings" role="group" aria-label="Notifications">
  <h3 class="tui-settings__head">Notifications</h3>

  <!-- A switch or a check: the whole row is the label -->
  <label class="tui-settings__row">
    <span class="tui-settings__text">
      <span class="tui-settings__title" id="s1-t">Email receipts</span>
      <span class="tui-settings__desc" id="s1-d">Send a receipt after every payment.</span>
    </span>
    <input class="tui-switch" type="checkbox" role="switch" aria-labelledby="s1-t" aria-describedby="s1-d" checked>
  </label>

  <!-- A key, a select or a value: a plain box -->
  <div class="tui-settings__row">
    <span class="tui-settings__text">
      <span class="tui-settings__title">Two-step sign-in</span>
      <span class="tui-settings__desc">Ask for a code from your phone.</span>
    </span>
    <button class="tui-key tui-key--sm" type="button">Set up</button>
  </div>
</div>
```

The demo on the page:

```html
<div class="tui-panel" style="width:min(100%,500px);display:grid;gap:16px;text-align:left"><div class="tui-panel__head" style="margin-bottom:0"><span class="tui-label">Settings · Northwind</span><span class="tui-status"><span class="tui-lamp" data-on></span>Saved</span></div><div data-sr-demo><div class="tui-settings" role="group" aria-label="Notifications"><h3 class="tui-settings__head">Notifications</h3>
    <label class="tui-settings__row"><span class="tui-settings__text"><span class="tui-settings__title" id="sr-a-t">Email receipts</span><span class="tui-settings__desc" id="sr-a-d">Send a receipt after every payment.</span></span><input class="tui-switch" type="checkbox" role="switch" aria-labelledby="sr-a-t" aria-describedby="sr-a-d" checked></label>
    <label class="tui-settings__row"><span class="tui-settings__text"><span class="tui-settings__title" id="sr-b-t">Weekly summary</span><span class="tui-settings__desc" id="sr-b-d">A short note on Monday mornings.</span></span><input class="tui-switch" type="checkbox" role="switch" aria-labelledby="sr-b-t" aria-describedby="sr-b-d"></label>
    <label class="tui-settings__row"><span class="tui-settings__text"><span class="tui-settings__title" id="sr-c-t">Failed payments</span><span class="tui-settings__desc" id="sr-c-d">Tell me the moment a charge fails.</span></span><input class="tui-switch" type="checkbox" role="switch" aria-labelledby="sr-c-t" aria-describedby="sr-c-d" checked></label></div>
  <div class="tui-settings" role="group" aria-label="Account"><h3 class="tui-settings__head">Account</h3>
    <div class="tui-settings__row"><span class="tui-settings__text"><span class="tui-settings__title" id="sr-d-t">Language</span><span class="tui-settings__desc" id="sr-d-d">The words in your dashboard.</span></span><select class="tui-select" aria-labelledby="sr-d-t"><option>English (UK)</option><option>Português</option><option>Deutsch</option></select></div>
    <div class="tui-settings__row"><span class="tui-settings__text"><span class="tui-settings__title" id="sr-e-t">Two-step sign-in</span><span class="tui-settings__desc" id="sr-e-d">Ask for a code from your phone.</span></span><span class="tui-settings__end"><span class="tui-settings__value">Off</span><button class="tui-key tui-key--sm" type="button" aria-describedby="sr-e-t">Set up</button></span></div>
    <div class="tui-settings__row tui-settings__row--danger"><span class="tui-settings__text"><span class="tui-settings__title" id="sr-f-t">Delete this workspace</span><span class="tui-settings__desc" id="sr-f-d">Removes every project and cannot be undone.</span></span><button class="tui-key tui-key--sm tui-key--danger" type="button">Delete…</button></div></div></div>
  <output class="tui-muted" style="font-size:var(--tui-t-small)" data-sr-out aria-live="polite">Nothing changed yet</output></div>
```

## Usage notes

Press the words of a row, not just the switch: the whole row is the control. The language and the sign-in rows hold a select and a key instead, so they are not one big target. The last row is the one that cannot be undone, so its words say so.

## Accessibility

- A row that holds a switch is a `<label>`, so the whole row is the target and the pointer, a finger and a switch-access device all reach it; on a phone the row is at least 64px tall.
- The switch is named by the title with `aria-labelledby` and described by the sentence with `aria-describedby`, so it reads “Email receipts, switch, on, Send a receipt after every payment” and not the title and sentence run together as a name.
- The state is the switch’s own position and its lit slot, and a screen reader hears “on” or “off”; no sentence changes with the state, so the words never contradict the control.
- A key row is not a label on purpose: pressing the words does nothing, and the key is named by its words with the title as its description, “Set up, two-step sign-in”.
- The focus ring goes round the whole label row when the switch has the focus, and round the key or select alone in a plain row. A disabled row dims its words and is skipped by the keyboard.

## How it’s built

The list already knows how to be a rack of rows with hairlines between them, so the settings row borrows its rule exactly: a one-pixel line, inset to the words, that vanishes under the row the pointer is on. The controls are the kit’s own, a switch, a check, a key and a select, set in the row’s end with auto margin. The row is a flex box that wraps, so on a narrow screen a wide control drops under its words instead of squeezing them.

## Rules

Lay out a settings page as rows that say what each setting does in a sentence, with the control where the eye ends up, and a whole row to press.

The full rules are in `settings-row.rules.md` in the brain, which ships with the Kit.

## Related parts

- [Switch](https://tactileui.dev/parts/switch): On or off, applied the moment it moves. A native checkbox with a ridged thumb in a slot that lights green when on.
- [List](https://tactileui.dev/parts/list): Rows in a rack: a mark, a title, a second line and a fact or a key at the end. Chosen rows sink into a recess with their check key latched; in a running order, a row lifts out of the rack on its skirt and slides past the others, from the keyboard or by its grip.
- [Check](https://tactileui.dev/parts/check): An option in a form: a small square key that presses below the plate when chosen, with a tick printed on it.
- [Field](https://tactileui.dev/parts/field): Text entry in a recess, the label printed above it, and a hint that says how to fix an error.
