Checkbox
A choice that is on or off, its state in your Model.
forSlots(CheckboxSlots)(Recipes.Checkbox({}))
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 CheckboxStyle = forSlots(CheckboxSlots)(Recipes.Checkbox({}))
export const checkbox = <Message>(
style: NamedStyle<typeof CheckboxSlots>,
checked: boolean,
onToggle: (checked: boolean) => Message,
h: HtmlBuilder<Message>,
): Html =>
UiCheckbox.view(
{
id: 'terms',
isChecked: checked,
onToggle,
toView: Checkbox.toView([style.mixin], { h }, resolved =>
h.div(
[h.Style({ display: 'flex', alignItems: 'center', gap: '0.5rem' })],
[h.button(resolved.checkbox, []), h.label(resolved.label, ['Accept the terms'])],
),
),
},
h,
)