FormRow
Un ajuste por fila: cómo se llama y qué hace a un lado, su control al otro. Las filas forman una lista con líneas entre ellas; en celulares el control va debajo del texto.
import { FormRow, Switch, NativeSelect, Input } from '@sypnia/ui/react'
En esta página
Ajustes de la cuenta
En un celular, cada control ocupa todo el ancho debajo de su texto.
Public sign-ups
Anyone with the link can create an account. Turn it off to invite people one by one.
How long someone stays signed in without using the app.
Only emails at this domain can join.
Delete project
Removes the database, the files and the logs. This cannot be undone.
Código
import { Button, FormRow, Input, NativeSelect, Panel, Switch } from '@sypnia/ui/react';
// One setting per row: what it does on the left, the control on the right. On a phone the control goes below.
export default function SettingsList() {
return (
<Panel>
<FormRow label="Public sign-ups" description="Anyone with the link can create an account. Turn it off to invite people one by one.">
<Switch label="Allow" defaultChecked />
</FormRow>
<FormRow label="Session length" description="How long someone stays signed in without using the app." htmlFor="session">
<NativeSelect id="session" defaultValue="7d"><option value="1d">1 day</option><option value="7d">7 days</option><option value="30d">30 days</option></NativeSelect>
</FormRow>
<FormRow label="Allowed domain" description="Only emails at this domain can join." htmlFor="domain">
<Input id="domain" machine defaultValue="northwind.io" />
</FormRow>
<FormRow label="Delete project" description="Removes the database, the files and the logs. This cannot be undone." danger>
<Button variant="danger" icon="trash">Delete project</Button>
</FormRow>
</Panel>
);
} Skeleton
La pieza real y su skeleton: la misma caja, así nada se mueve cuando llegan los datos.
How long someone stays signed in without using the app.
Session length
How long someone stays signed in without using the app.
Código
import { FormRow, FormRowSkeleton, NativeSelect, Panel } from '@sypnia/ui/react';
// The real row, the row with `loading` (its words are known, its value is not) and the skeleton.
export default function Skeleton() {
return (
<Panel>
<FormRow label="Session length" description="How long someone stays signed in without using the app." htmlFor="len">
<NativeSelect id="len" defaultValue="7d"><option value="7d">7 days</option></NativeSelect>
</FormRow>
<FormRow label="Session length" description="How long someone stays signed in without using the app." loading />
<FormRowSkeleton />
</Panel>
);
} Cuándo usarlo
Úsalo cuando
- Ajustes que se aplican apenas cambian, o una lista de ajustes que se guarda con una SaveBar.
- Di en la descripción qué cambia para la persona, en una frase: «Cualquiera con el enlace puede crear una cuenta».
No lo uses cuando
- Formularios que se llenan de arriba abajo: usa Field para que la etiqueta quede sobre el control.
- Controles largos como un Textarea: necesitan todo el ancho.
Para todos
- Dale al control un
idy a la filahtmlFor, así el nombre del ajuste es su etiqueta. - Sin
htmlFor, la zona del control es un grupo nombrado por el ajuste, para interruptores y botones que ya se nombran solos. - Las filas marcadas
dangerusan color y palabras: la descripción dice qué se pierde.
Props
| FormRow | Tipo | Por defecto |
|---|---|---|
labelobligatorio | ReactNode | |
danger | boolean | |
description | ReactNode | |
htmlFor | string | |
loadingThe setting's value is on its way: the text stays and the control (`children`, when given) is drawn as a skeleton of its own box; without children, a skeleton of a control's height. | boolean |
| Switch | Tipo | Por defecto |
|---|---|---|
labelobligatorio | ReactNode | |
description | ReactNode |
| NativeSelect | Tipo | Por defecto |
|---|---|---|
size | "sm" | "md" | "lg" |
| Input | Tipo | Por defecto |
|---|---|---|
machineMachine text (ids, keys, code): set in the mono face. | boolean | |
size | "sm" | "md" | "lg" |