Componenti
Interruttore
Attiva o disattiva un'impostazione applicata immediatamente.
Utilizzo
Base
HTML
<bs:bsui-switch label="Email notifications" defaultChecked="true" />Preferenze
Gli interruttori si applicano subito, quindi un elenco di interruttori non richiede un pulsante di salvataggio.
HTML
<bs:bsui-stack direction="column" gap="4">
<bs:bsui-switch name="deploys" label="Deploy summaries" defaultChecked="true" />
<bs:bsui-switch name="failures" label="Build failures" defaultChecked="true" />
<bs:bsui-switch name="news" label="Product news" />
</bs:bsui-stack>Sola lettura e disabilitato
Un interruttore in sola lettura mostra il proprio valore ma non cambia stato; uno disabilitato appare anche attenuato.
HTML
<bs:bsui-stack direction="column" gap="4">
<bs:bsui-switch label="Two factor authentication" defaultChecked="true" readOnly="true" />
<bs:bsui-switch label="Single sign-on" disabled="true" />
</bs:bsui-stack>Valori personalizzati
Le posizioni attiva e disattiva possono inviare qualsiasi valore, non solo on e un valore vuoto.
Submits weekly while it is on and never while it is off.
HTML
<bs:bsui-field>
<bs:bsui-field-label text="Digest emails" />
<bs:bsui-switch name="digest" label="Send a weekly digest" checkedValue="weekly" uncheckedValue="never" defaultChecked="true" />
<bs:bsui-field-description text="Submits weekly while it is on and never while it is off." />
</bs:bsui-field>Struttura
Interruttore è composto dai blocchi seguenti. Ognuno è un blocco separato che viene visualizzato solo all'interno del proprio genitore.
bsui/switchbsui/switch-thumb
Attributi
| Attributo | Tipo | Predefinito |
|---|---|---|
defaultChecked | toggle | false |
disabled | toggle | false |
readOnly | toggle | false |
required | toggle | false |
name | text | — |
checkedValue | text | on |
uncheckedValue | text | — |
label | richtext | — |
bindText | text | — |
nameAlt | text | — |
onChange | text | — |
checked | text | — |
bsui/switch-thumb
Questo blocco non accetta attributi.