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:
- Variables:
label (
str) – Label textchecked (
bool) – Current checked stateon_change (
callableorNone) – Callback (old_value, new_value) when state changeson_action (
callableorNone) – Callback when Enter is pressedaction (
strorNone) – 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
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 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.
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_tabWhether this element wants the Tab key instead of focus movement.
Get the checked state.
parent_frameGet the parent Frame if this element is inside a scrollable frame.
supports_dynamic_sizingWhether this element supports dynamic sizing.
- handle_key(key)[source]
Handle keyboard input.
- Parameters:
key (
Key) – Key press to handle- Returns:
True if key was handled
- Return type:
- async handle_mouse(event)[source]
Handle mouse input.
- Parameters:
event (
MouseEvent) – Mouse event to handle- Returns:
True if event was handled
- Return type:
- 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 (
checkedandfocusedare folded into_style_signature()); the checkbox glyph is a pure function of those. Seewijjit.elements.base.Element.render_signature().- Return type:
- 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