Switch
A setting that takes effect at once.
forSlots(SwitchSlots)(Recipes.Switch({}))
Usage
The function that drew the preview, over the theme module Create a theme writes. The preview passes it the style picked above instead of its default.
export const SwitchStyle = forSlots(SwitchSlots)(Recipes.Switch({}))
export const toggle = <Message>(
style: NamedStyle<typeof SwitchSlots>,
on: boolean,
onToggle: (on: boolean) => Message,
h: HtmlBuilder<Message>,
): Html =>
UiSwitch.view(
{
id: 'airplane',
isChecked: on,
onToggle,
toView: Switch.toView([style.mixin], { h }, resolved =>
h.div(
[h.Style({ display: 'flex', alignItems: 'center', gap: '0.5rem' })],
[h.button(resolved.button, []), h.label(resolved.label, ['Airplane mode'])],
),
),
},
h,
)