Skip to content

Switch

Show a checkbox field as a switch. Works with every style and palette.

A Notify subscribers checkbox shown as a switch that is turned onA Notify subscribers checkbox shown as a switch that is turned on
import { SWITCH } from '@payloadpack/theme'
const field = {
name: 'notify',
type: 'checkbox',
label: 'Notify subscribers',
admin: { className: SWITCH, description: 'Email everyone who follows this showcase' }
}

To put the switch at the end of the row, after its label, use SWITCH_END instead. The whole row toggles it:

import { SWITCH_END } from '@payloadpack/theme'
const field = {
name: 'pinned',
type: 'checkbox',
label: 'Pin to the top',
admin: { className: SWITCH_END, description: 'Keep this showcase first in every list' }
}

It is still Payload’s checkbox: it saves with the form, and screen readers announce it as a checkbox. Its size and thumb are tokens.