Checkbox Showcase

Primary

Example

Toggle Example

Toggle Example

Toggle orange

Component Documentation

Component Name

Checkbox

Builder Function Name

create_checkbox_manager

Description

creates a checkbox, toggle, or dark theme switch with optional label, error states, and custom on/off values

Use like example

Config

PropertyTypeDefaultDescription
typestring

checkbox

the display variant: 'checkbox', 'toggle', or 'dark_theme'

valany

the current value of the checkbox, which can match on_val or off_val

on_valany

true

the value considered 'checked'

off_valany

false

the value considered 'unchecked'

labelstring

label text displayed beside the checkbox

namestring

checkbox

the input name attribute

colorstring

var(--primary-t)

the base color for the checked state or toggle

is_requiredboolean

false

marks the input as required

is_read_onlyboolean

false

makes the checkbox read-only if true

is_disabledboolean

false

disables the checkbox if true

is_loadingboolean

false

displays a loading spinner if true

sizenumber

2.4

base size in rem for the checkbox or toggle

mlnumber

0

margin-left in rem

mrnumber

0

margin-right in rem

mtnumber

0

margin-top in rem

mbnumber

0

margin-bottom in rem

error_messagestring

an error message displayed next to the checkbox

on_changefunction

callback fired when the checkbox toggles, receiving new value

on_hover_changefunction

callback fired on pointerenter/leave, receiving true or false

Methods

MethodDescriptionParametersReturns
set_val

sets the checkbox value to on_val or off_val; updates internal bool state

val_input: any

void
set_val_from_bool

sets checkbox to on/off based on a boolean, optionally triggering on_change

val_bool_input: boolean

is_trigger_on_change: boolean

void
handle_on_hover_change

internal event that calls on_hover_change(true/false)

input: boolean

void

Returned Properties

PropertyTypeDescription
idstring

unique id generated for the checkbox input

typestring

the display variant (checkbox, toggle, or dark_theme)

val_initialany

the initial value set from config

valany

the current on/off value (on_val or off_val)

val_boolboolean

true if current value matches on_val, false otherwise

off_valany

the value for unchecked state

on_valany

the value for checked state

namestring

the input name attribute

labelstring

label text displayed beside the checkbox

colorstring

the base color for the checked state or toggle

is_requiredboolean

true if the field is required

is_read_onlyboolean

true if the checkbox is read-only

is_disabledboolean

true if the checkbox is disabled

is_loadingboolean

true if a loading spinner is shown

error_messagestring

any error text displayed beside the label

sizenumber

base size in rem of the checkbox or toggle

mlnumber

margin-left in rem

mrnumber

margin-right in rem

mtnumber

margin-top in rem

mbnumber

margin-bottom in rem

check_icon_managerobject

icon manager used for the check mark

moon_icon_managerobject

icon manager used for the moon icon in dark_theme mode

sun_icon_managerobject

icon manager used for the sun icon in dark_theme mode

icon
Sponsored byContibase