BooleanFieldView
A toggle switch UI element for boolean (true/false) values.
Displays as a sliding switch that can be toggled between on and off states. Supports keyboard navigation (Space to toggle, Enter for on, Backspace/Delete for off) and mouse/touch interaction.
The visual style adapts based on the inputStyle
property:
- DEFAULT: Standard switch with background
- OVERLAY: Transparent background, suitable for overlays
- MINIMAL: Minimal style with just borders
Instance Members
Custom theme override for this field
The current boolean value (true = on, false = off)
Visual style of the switch (DEFAULT, OVERLAY, or MINIMAL)
Whether the switch is disabled (non-interactive)
Hook called when the boolean value changes. Override this to handle value updates.
Name | Type | Description |
---|---|---|
field |
BooleanFieldView | The field instance (this) |
value |
Bool | The new boolean value |
Creates a new BooleanFieldView with a toggle switch. Sets up the visual components and interaction handlers.
Private Members
Container view for the switch background
The sliding square indicator within the switch
Event when theme field changes.
Name | Type |
---|---|
current |
Theme |
previous |
Theme |
Event when value field changes.
Name | Type |
---|---|
current |
Bool |
previous |
Bool |
Event when inputStyle field changes.
Name | Type |
---|---|
current |
Anonymous |
previous |
Anonymous |
Event when disabled field changes.
Name | Type |
---|---|
current |
Bool |
previous |
Bool |
Positions the switch indicator based on the current value. Slides to the right when true, left when false.
Handles keyboard input for the switch.
- Space: Toggle value
- Enter: Set to true
- Backspace/Delete: Set to false
Name | Type | Description |
---|---|---|
key |
ceramic.Key | The key event |
Toggles the boolean value between true and false. Calls the setValue hook with the new value.
Updates the visual style of the switch based on theme and state. Applies different colors and borders for focused, disabled, and value states.
Metadata
Name | Parameters |
---|---|
:build |
ceramic.macros.EntityMacro.buildForCompletion() |
:autoBuild |
ceramic.macros.EntityMacro.buildForCompletion() |
:build |
tracker.macros.EventsMacro.build() |
:autoBuild |
tracker.macros.EventsMacro.build() |
:build |
tracker.macros.ObservableMacro.build() |
:autoBuild |
tracker.macros.ObservableMacro.build() |