field.switch
A setting that turns on or off immediately: show images, compact mode. Pair with a text.label
Field intents
Example
<Field intent="field.switch" id="switch" name="switch" />Choosing between neighbours
Find the row that describes your element, and use the intent on the right.
If it is
Use
A setting that turns on or off immediately: show images, compact mode. Pair with a text.label
field.switchthis pageA choice that waits for a submit button
field.checkboxA setting that takes effect immediately
rather thanfield.checkboxfield.switchthis page
Connections
Declared in the registry, both directions. Where an intent is used in your own code is something check and the gallery see; this site has no app code.
- Built from
For registry authors
Starter intents. These are the intents prongs add puts in your registry, shown in this site’s theme. Yours are your own registry.ts: rename, restyle and add to them, and see them with prongs add gallery.
What this intent is built from and its entry in components/prongs/registry.ts. You only need this to change how it looks or to add an intent like it.
How field.switch resolves, and its definition
Each layer adds to the one before it; a later class wins over an earlier one that sets the same thing.
input.toggleSliding on/off track
relative h-5 w-9 shrink-0 cursor-pointer appearance-none rounded-full bg-input transition-colors checked:bg-primary before:absolute before:left-0.5 before:top-0.5 before:h-4 before:w-4 before:rounded-full before:bg-background before:transition-transform checked:before:translate-x-4
field.switchA setting that turns on or off immediately: show images, compact mode. Pair with a text.label
relative h-5 w-9 shrink-0 cursor-pointer appearance-none rounded-full bg-input transition-colors checked:bg-primary before:absolute before:left-0.5 before:top-0.5 before:h-4 before:w-4 before:rounded-full before:bg-background before:transition-transform checked:before:translate-x-4
{ type: 'checkbox', role: 'switch' }'field.switch': {
kind: 'semantic',
description: 'A setting that turns on or off immediately: show images, compact mode. Pair with a text.label',
refs: ['input.toggle'],
binding: { behavior: { type: 'checkbox', role: 'switch' } },
notFor: [
{
context: 'a choice that waits for a submit button',
instead: 'field.checkbox',
},
],
},