Checkbox class Components InteractableComponents

A terminal-based checkbox UI component.

A Checkbox displays a label with a selectable box prefix. It does not hold its own state directly — an internal CheckboxInstance tracks whether the box is checked or unchecked.

Features:

  • Toggle between checked/unchecked states via keyboard (space or enter) or mouse click.
  • Visual state changes when hovered or focused.
  • Optional styling for selection, hover, and text colors.
  • Configurable width padding.

This class is a configuration object — actual rendering and interaction is handled by CheckboxInstance.

Example:

final checkbox = Checkbox(
  label: 'Enable feature',
  selectionColor: Colors.green,
  hoverColor: Colors.blue,
  textColor: Colors.white,
  width: 2,
);

See also:

Inheritance

Constructors

Checkbox({required String label, AnsiColorType? selectionColor, AnsiColorType? hoverColor, AnsiColorType? textColor, int width = 0})
Creates a Checkbox with the given label and optional styling.
const

Properties

hashCode → int
The hash code for this object.
no setterinherited
hoverColor → AnsiColorType?
The background color applied when the checkbox is hovered but not checked.
final
label → String
The text label displayed next to the checkbox.
final
padding → EdgeInsets
The padding inside the component’s layout bounds.
finalinherited
position → Position?
The position of the component within its parent or layout.
finalinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
selectionColor → AnsiColorType?
The background color applied when the checkbox is checked.
final
textColor → AnsiColorType?
The text color for the label.
final
width → int
Extra horizontal space (padding) to the right of the label.
final

Methods

createInstance() → ComponentInstance
Creates a ComponentInstance that can be rendered.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited