Skip to content

Settings row

One setting per line, with its name at the start and its control at the end, plus the page.

<div data-mount="rows"></div>

Installation

// package.json: "capsomer": "github:DrDustinEdwards/capsomer#v0.152.2"
import "capsomer/tokens.css";
import "capsomer/base.css";
import "capsomer/settings-row.css";

Usage

<div class="cap-settings-row">
  <div class="cap-settings-row-text">
    <span class="cap-settings-row-label" id="r1-label">Failure alerts</span>
    <p class="cap-settings-row-help" id="r1-help">An email the moment a check fails.</p>
  </div>
  <div class="cap-settings-row-control">
    <label class="cap-switch"><input type="checkbox" role="switch" name="alerts" aria-labelledby="r1-label" aria-describedby="r1-help" checked /> <span class="cap-switch-state" aria-hidden="true">On</span></label>
  </div>
</div>

Examples

A settings page: on a phone, a link back to the settings index above the page head

<div data-mount="page"></div>

API reference

SettingsRow

PropTypeRequiredDoes
labelReactNodeYes
helpReactNode
children(ids: { labelId: string; helpId?: string }) => ReactNodeYes

SwitchRow

PropTypeRequiredDoes
namestring
labelReactNodeYes
helpReactNode
checkedboolean
defaultCheckedboolean
onCheckedChange(checked: boolean) => void
busyboolean
formstringThe id of the form the switch belongs to, when it sits outside it (its form attribute).
submitOnChangebooleanSend the switch's form as soon as it is flipped: the setting takes effect at once, as a switch should. Without script a Save button for that form stands in.
saveLabelstring
disabledReasonReactNodeWhy it cannot be changed here ("Only the account owner can change this."): the switch is disabled and described by these words, never dimmed with no reason.

SettingsLayout

PropTypeRequiredDoes
titleReactNodeYes
leadReactNode
crumbsBreadcrumbItem[]
renderLinkBreadcrumbProps["renderLink"]
back{ href: string; label: string } | nullThe settings index; null for none.
actionsReactNode
childrenReactNode

Parts and data attributes

ClassIs
.cap-settings-backits own class
.cap-settings-pageits own class
.cap-settings-rowthe root
.cap-settings-row-controla part
.cap-settings-row-helpa part
.cap-settings-row-labela part
.cap-settings-row-reasona part
.cap-settings-row-texta part
AttributeValues
data-fillpresent or absent
data-flippresent or absent
StateRead from
:hoverthe platform

Accessibility

The control's own; the back link is a link.

A switch is Capsomer's switch (a checkbox with role="switch"). The page head holds the one h1.