<booleanInput>
<booleanInput> is an Input
component that renders a checkbox. If the box is checked by the user, Doenet
stores the boolean value true in the named <booleanInput>.
Attributes and Properties
Attributes for <booleanInput>
Labels (1)
boolean. Default value: false. Whether to use this component's name as its rendered label.
Positioning (2)
anchorpoint. Default value: . Coordinates of the anchor point used to position this component on a graph.
positionFromAnchorkeyword. Where this component sits relative to its anchor point.
| Value | Description |
|---|---|
upperRight | Place the component above and to the right of the anchor point. |
upperLeft | Place the component above and to the left of the anchor point. |
lowerRight | Place the component below and to the right of the anchor point. |
lowerLeft | Place the component below and to the left of the anchor point. |
top | Place the component directly above the anchor point. |
bottom | Place the component directly below the anchor point. |
left | Place the component directly to the left of the anchor point. |
right | Place the component directly to the right of the anchor point. |
center (default) | Center the component on the anchor point. |
Other (6)
boolean. Default value: false. Whether to render the input as a toggle button rather than a checkbox.
boolean. Two-way binding target for the input's value.
draggableboolean. Default value: true. Whether the input can be dragged on a graph by its anchor.
forAnswerreference. References to <answer> elements that this input should submit to.
labelPositionkeyword. Position of the label relative to the input.
| Value | Description |
|---|---|
left | Place the label to the left of the input. |
right (default) | Place the label to the right of the input. |
boolean. Default value: false. The initial value of the input before the student interacts.
Common to all components (9)
copyreference. Create an independent copy of another component by reference. Enter a references a $name.
disabledboolean. Default value: false. Whether this component is disabled and cannot be interacted with.
extendreference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.
fixedboolean. Default value: false. Whether this component's value is fixed and cannot be modified.
fixLocationboolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
hideboolean. Default value: false. Whether to hide this component from the rendered output.
isResponseboolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.
nametext. The name used to reference this component from elsewhere in the document.
styleNumberinteger. Default value: 1. The style number used to select this component's visual styling from the available style definitions.
Properties for <booleanInput name="b">
Labels (2)
$b.labellabel. The label rendered with this component.
$b.labelIsNameboolean. Whether to use this component's name as its rendered label.
Positioning (2)
$b.anchorpoint. The coordinates where this component is anchored on the graph.
$b.positionFromAnchortext. Where this component sits relative to its anchor point.
Other (13)
$b.asToggleButtonboolean. Whether to render the input as a toggle button rather than a checkbox.
$b.disabledboolean. Whether this component is disabled and cannot be interacted with.
$b.draggableboolean. Whether the input can be dragged on a graph by its anchor.
$b.fixedboolean. Whether this component's value is fixed and cannot be modified.
$b.fixLocationboolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
$b.focusedboolean. Whether this input currently has keyboard focus.
$b.labelPositiontext. Position of the label relative to the input.
$b.prefillboolean. The initial value of the input before the student interacts.
$b.shortDescriptiontext. A short accessibility description of this input; it is visible to screen readers but not rendered visually.
$b.texttext. The current value rendered as a text string ("true" or "false").
$b.valueboolean. The current boolean value of the input.
$b.valueChangedboolean. Whether the input's value has been changed from its prefill value.
Common to all components (4)
$b.doenetMLtext. The DoenetML source code that produced this component.
$b.hideboolean. Whether to hide this component from the rendered output.
$b.isResponseboolean. Whether this component is treated as a response for the purposes of assessment.
$b.styleNumberinteger. The style number used to select this component's visual styling from the available style definitions.
Examples
Example: <booleanInput> survey question
A <booleanInput> component renders a checkbox whose value is
stored as true if the box is checked.
Example: <booleanInput> to show/hide graph elements
The <booleanInput> component can be used to provide user-control over the
values of attributes that accept a boolean, such as the <graph> attribute grid,
and the general attribute hide available to all rendered components.
Example: <booleanInput> with a label
A <label> child can be nested within a <booleanInput> to create a label.
Attribute Examples
Attribute Example: prefill
The <booleanInput> component is false initially by default.
Use the prefill attribute set to true to reverse this behavior.
Attribute Example: asToggleButton
The asToggleButton attribute changes the default rendering format
from a checkbox to a toggle button.
Attribute Example: labelIsName
The labelIsName attribute can be used as a shortcut to adding a <label> child.
Attribute Example: bindValueTo
A <booleanInput> is used to simulate a light switch using the bindValueTo attribute.
The behavior of the <booleanInput> checkbox is tied to the <boolean> that is named
onBoolean within the bindValueTo specification. When the user’s <textInput/> has value ON,
the condition inside the <boolean> becomes true, which in turn causes the <booleanInput> to
take on the value true, and the checkbox, or “lightbulb” becomes checked.
Property Examples
Property Example: value
The value property of a named <booleanInput> returns its value of true or false.
Property Example: text
The text property of a named <booleanInput> returns the text value of true or false.
Property Example: Attributes as properties
The above listed attributes of a <booleanInput> are also available as properties.