<slider>
<slider> is an Input
component that renders a draggable selection bar for graphical user input of a single value.
Attributes and Properties
Attributes for <slider>
Highlighted (4)
number. Default value: 0. Minimum value of the slider's range.
number. Default value: 1. Increment between successive slider positions.
number. Default value: 10. Maximum value of the slider's range.
keyword. Type of value the slider produces.
| Value | Description |
|---|---|
number (default) | Slider produces numeric values between from and to. |
text | Slider produces text values, one per child of the slider. |
Number display (5)
avoidScientificNotationboolean. Default value: false. Whether to render numbers in full decimal form rather than scientific notation.
displayDecimalsinteger. Default value: 2. Number of decimal places to display when rendering this number.
displayDigitsinteger. Default value: 3. Number of significant digits to display when rendering this number.
displaySmallAsZeronumber. Default value: 1e-14. Threshold below which numbers are displayed as zero.
padZerosboolean. Default value: false. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.
Labels (1)
boolean. Default value: false. Whether to use this component's name as its rendered label.
Other (8)
bindValueTo_componentWithSelectableType. Two-way binding target for the input's value.
heightcomponentSize. Default value: {"size":100,"isAbsolute":true}. Display height of the slider.
_componentWithSelectableType. Initial value of the slider before any user interaction.
rotateTickLabelsboolean. Default value: false. Whether to rotate the tick labels.
showControlsboolean. Default value: false. Whether to render play/pause controls alongside the slider.
boolean. Default value: true. Whether to render tick marks on the slider.
boolean. Default value: true. Whether to display the current value next to the slider.
componentSize. Default value: {"size":300,"isAbsolute":true}. Display width of the slider.
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 <slider name="s">
Highlighted (3)
$s.fromnumber. Minimum value of the slider's range.
$s.stepnumber. Increment between successive slider positions.
$s.tonumber. Maximum value of the slider's range.
Number display (5)
$s.avoidScientificNotationboolean. Whether to render numbers in full decimal form rather than scientific notation.
$s.displayDecimalsinteger. Number of decimal places to display when rendering this number.
$s.displayDigitsinteger. Number of significant digits to display when rendering this number.
$s.displaySmallAsZeronumber. Threshold below which numbers are displayed as zero.
$s.padZerosboolean. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.
Labels (2)
$s.labellabel. The label rendered with this component.
$s.labelIsNameboolean. Whether to use this component's name as its rendered label.
Other (13)
$s.disabledboolean. Whether this component is disabled and cannot be interacted with.
$s.fixedboolean. Whether this component's value is fixed and cannot be modified.
$s.fixLocationboolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
$s.heightcomponentSize. Display height of the slider.
$s.itemsThe values the slider can take.
$s.numItemsinteger. The total number of values.
$s.rotateTickLabelsboolean. Whether to rotate the tick labels.
$s.showControlsboolean. Whether to render play/pause controls alongside the slider.
$s.showTicksboolean. Whether to render tick marks on the slider.
$s.showValueboolean. Whether to display the current value next to the slider.
$s.valueThe current value of the slider.
$s.widthcomponentSize. Display width of the slider.
Common to all components (4)
$s.doenetMLtext. The DoenetML source code that produced this component.
$s.hideboolean. Whether to hide this component from the rendered output.
$s.isResponseboolean. Whether this component is treated as a response for the purposes of assessment.
$s.styleNumberinteger. The style number used to select this component's visual styling from the available style definitions.
Examples
Example: Default <slider>
The range for a default <slider> is from to . The current value of the slider is shown, by default, in
the upper left corner of the slider bar. Referencing the named slider using the $name notation renders its current value.
Example: A labeled <slider>
A <slider> can be given a <label> child, which renders above the slider to the
left of the current value of the <slider>.
Attribute Examples
Attribute Example: type
There are two types of sliders, “number” and “text”, which can be
specified using the type attribute. The text type requires <text> children, and
frames them in a sequential list on the <slider> when it is rendered.
Attribute Example: initialValue
Using the initialValue attribute, the slider can be set to an initial value
occuring in the interior of the slider’s range. Without this attribute, the
initial value of the slider defaults to the starting value.
Attribute Example: width
The default width for a <slider> is 300 pixels, in absolute measurement; this
value can be adjusted with the width attribute.
Attribute Example: labelIsName
If the labelIsName attribute is specified, a default label is displayed above the slider, with
the name of the slider taken as its label.
Attribute Example: showTicks
By default, the showTicks attribute is set to true. If showTicks is set to false, no values
are rendered on the slider bar.
Attribute Example: showValue
By default, the showValue attribute is set to true, and the current value of the slider is
automatically rendered directly above the bar on the left side. If showValue is set to “false”,
no value is rendered above the slider bar as the user drags the point.
Attribute Example: from / to
The from and to attributes can be used to customize the range for the <slider>. The default
range is from to .
Attribute Example: step
The step attribute can be used to customize the incremental step size for the <slider>. The default
step is .
Property Examples
Property Example: Attributes as properties
The attributes of <slider> listed above are also accessible as properties.
Property Example: items
The items property of <slider> returns a list of all the possible values in
the slider’s range for a text type <slider>.
Property Example: numItems
The numItems property of <slider> returns the number of possible values
occuring in the slider’s range.