field.switch

A setting that turns on or off immediately: show images, compact mode. Pair with a text.label

Component

Renders

<input type="checkbox">

Profile

Example

Preview
<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.switch this page
  • A choice that waits for a submit button

    field.checkbox
  • A setting that takes effect immediately

    rather than field.checkbox
    field.switch this 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.

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.toggle

    Sliding 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.switch

    A setting that turns on or off immediately: show images, compact mode. Pair with a text.label

Final classes
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
Element behaviour
{ type: 'checkbox', role: 'switch' }
Definition
TS
'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',
},
],
},