wijjit.elements.input.checkbox.Checkbox

class wijjit.elements.input.checkbox.Checkbox(id=None, classes=None, tab_index=None, label='', checked=False, bind=True)[source]

Checkbox element for boolean selections.

A checkbox allows users to toggle a boolean value on/off. It renders with unicode box characters when supported, falling back to ASCII.

Parameters:
  • id (str, optional) – Element identifier

  • label (str, optional) – Label text displayed next to checkbox (default: “”)

  • checked (bool, optional) – Initial checked state (default: False)

  • classes (str | list[str] | set[str] | None)

  • tab_index (int | None)

  • bind (bool | str)

Variables:
  • label (str) – Label text

  • checked (bool) – Current checked state

  • on_change (callable or None) – Callback (old_value, new_value) when state changes

  • on_action (callable or None) – Callback when Enter is pressed

  • action (str or None) – Action ID to dispatch (set by template extension)

  • bind (bool) – Whether to auto-bind to state[id] (default: True)

Notes

Keyboard controls: - Space/Enter: Toggle checkbox (Enter also triggers action callback)

Mouse controls: - Click: Toggle checkbox

__init__(id=None, classes=None, tab_index=None, label='', checked=False, bind=True)[source]
Parameters:
Return type:

None

Methods

__init__([id, classes, tab_index, label, ...])

add_class(class_name)

Add a CSS class to this element.

apply_props(props)

Apply props from a VNode, skipping ephemeral props.

get_ephemeral_state()

Get ephemeral state that should survive reconciliation.

get_hardware_cursor_position()

Absolute screen cell where the hardware terminal cursor should park.

get_height_for_width(width)

Return the height this element needs when laid out at width.

get_intrinsic_size()

Get the intrinsic (preferred) size of the checkbox.

handle_key(key)

Handle keyboard input.

handle_mouse(event)

Handle mouse input.

has_class(class_name)

Check if element has a CSS class.

on_blur()

Called when element loses focus.

on_focus()

Called when element gains focus.

on_hover_enter()

Called when mouse enters element.

on_hover_exit()

Called when mouse exits element.

on_mount()

Called when element is first added to the element tree.

on_unmount()

Called when element is removed from the element tree.

on_update(changed_props)

Called when element props are updated during reconciliation.

remove_class(class_name)

Remove a CSS class from this element.

render_signature()

Paint memo for the skip-unchanged fast path.

render_to(ctx)

Render checkbox using cell-based rendering.

restore_ephemeral_state(state)

Restore ephemeral state after reconciliation.

set_bounds(bounds)

Set the element's screen bounds.

toggle()

Toggle the checked state and emit change event.

toggle_class(class_name)

Toggle a CSS class on this element.

Attributes

captures_tab

Whether this element wants the Tab key instead of focus movement.

checked

Get the checked state.

parent_frame

Get the parent Frame if this element is inside a scrollable frame.

supports_dynamic_sizing

Whether this element supports dynamic sizing.

property checked: bool

Get the checked state.

Returns:

Current checked state

Return type:

bool

toggle()[source]

Toggle the checked state and emit change event.

Return type:

None

handle_key(key)[source]

Handle keyboard input.

Parameters:

key (Key) – Key press to handle

Returns:

True if key was handled

Return type:

bool

async handle_mouse(event)[source]

Handle mouse input.

Parameters:

event (MouseEvent) – Mouse event to handle

Returns:

True if event was handled

Return type:

bool

get_intrinsic_size()[source]

Get the intrinsic (preferred) size of the checkbox.

Returns:

(width, height) based on checkbox box and label text

Return type:

tuple[int, int]

render_signature()[source]

Paint memo for the skip-unchanged fast path.

Captures the label plus the style-affecting state (checked and focused are folded into _style_signature()); the checkbox glyph is a pure function of those. See wijjit.elements.base.Element.render_signature().

Return type:

Any

render_to(ctx)[source]

Render checkbox using cell-based rendering.

Parameters:

ctx (PaintContext) – Paint context with buffer, style resolver, and bounds

Return type:

None

Notes

This is the new cell-based rendering method. The legacy render() method is kept for backward compatibility.

Theme styles:

This element uses the following theme style classes: - checkbox: Base style - checkbox:focus: When element has focus - checkbox:checked: When checkbox is checked