<fractionInput/>
<fractionInput/> is an Input
component that renders a numerator input box above a denominator input box,
separated by a fraction bar. Each box accepts a math value, just like a
<mathInput/>.
Attributes and Properties
Attributes for <fractionInput>
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: 10. Number of significant digits to display when rendering this number.
displaySmallAsZeronumber. Default value: 0. 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)
labelIsNameboolean. Default value: false. Whether to use this component's name as its rendered label.
Other (11)
bindValueTomath. Two-way binding target for the fraction's value.
forAnswerreference. References to <answer> elements that this input should submit to.
keyword. Input format for the math entered.
| Value | Description |
|---|---|
text (default) | Plain-text math notation (e.g., x^2 + 1). |
latex | LaTeX-formatted math (e.g., x^{2} + 1). |
functionSymbolstextList. Default value: ["f","g"]. Symbols treated as function names when parsing.
labelPositionkeyword. Position of the label relative to the input.
| Value | Description |
|---|---|
left (default) | Place the label to the left of the input. |
right | Place the label to the right of the input. |
integer. Default value: 0. Minimum rendered width for the numerator and denominator, in pixels.
parseScientificNotationboolean. Default value: false. Whether to parse expressions like 1e3 as scientific notation.
math. Default value: . Initial value displayed in the denominator input.
math. Default value: . Initial value displayed in the numerator input.
splitSymbolsboolean. Default value: true. Whether multi-character symbols are split into a product of variables.
unionFromUboolean. Default value: false. Whether "U" between sets is parsed as union.
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 <fractionInput name="f">
Number display (5)
$f.avoidScientificNotationboolean. Whether to render numbers in full decimal form rather than scientific notation.
$f.displayDecimalsinteger. Number of decimal places to display when rendering this number.
$f.displayDigitsinteger. Number of significant digits to display when rendering this number.
$f.displaySmallAsZeronumber. Threshold below which numbers are displayed as zero.
$f.padZerosboolean. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.
Labels (2)
$f.labellabel. The label rendered with this component.
$f.labelIsNameboolean. Whether to use this component's name as its rendered label.
Other (21)
$f.denominatormath. The denominator of the fraction.
$f.disabledboolean. Whether this component is disabled and cannot be interacted with.
$f.fixedboolean. Whether this component's value is fixed and cannot be modified.
$f.fixLocationboolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
$f.focusedboolean. Whether the fraction input currently has keyboard focus.
$f.formattext. Input format for the math entered.
$f.functionSymbolstextList. Symbols treated as function names when parsing.
$f.immediateValuemath. The fraction value reflecting the user's in-progress edits.
boolean. Whether the value, including in-progress edits, has been changed from its initial state.
$f.labelPositiontext. Position of the label relative to the input.
$f.numeratormath. The numerator of the fraction.
$f.parseScientificNotationboolean. Whether to parse expressions like 1e3 as scientific notation.
$f.prefillDenominatormath. Initial value displayed in the denominator input.
$f.prefillNumeratormath. Initial value displayed in the numerator input.
$f.shortDescriptiontext. A short accessibility description of this input; it is visible to screen readers but not rendered visually.
$f.splitSymbolsboolean. Whether multi-character symbols are split into a product of variables.
$f.texttext. The current fraction as a text string.
$f.unionFromUboolean. Whether "U" between sets is parsed as union.
$f.valuemath. The fraction value of the input (numerator divided by denominator).
$f.valueChangedboolean. Whether the value has been changed from its initial state.
Common to all components (4)
$f.doenetMLtext. The DoenetML source code that produced this component.
$f.hideboolean. Whether to hide this component from the rendered output.
$f.isResponseboolean. Whether this component is treated as a response for the purposes of assessment.
$f.styleNumberinteger. The style number used to select this component's visual styling from the available style definitions.
Examples
Example: Default <fractionInput/>
A <fractionInput/> exposes the numerator and denominator separately,
as well as the combined value (the numerator divided by the denominator).
Example: Using a <fractionInput/> in an <answer>
Because its value is the math expression numerator divided by denominator, a
<fractionInput/> can be checked directly by an <answer>. Here
symbolicEquality makes the answer compare expressions symbolically, so only
the reduced fraction is accepted (an unreduced is
marked incorrect).
Example: Linking the value to another component
Referencing another component as a child creates a two-way link between the
fraction’s value and that component: editing the boxes updates the linked
value, and changing the linked value updates the boxes. If the linked value is
not a fraction, it is placed in the numerator over a denominator of 1.
The bindValueTo attribute (<fractionInput bindValueTo="$mi" />) creates
the same link, but the child form above is usually clearer.
Attribute Examples
Attribute Example: prefillNumerator / prefillDenominator
Use prefillNumerator and prefillDenominator to set the initial contents of
each box.
Attribute Example: format
Set format="latex" to provide prefilled values written in LaTeX.
Attribute Example: minComponentWidth
The minComponentWidth attribute adjusts the width of the numerator and
denominator input boxes.
Property Examples
Property Example: numerator / denominator / value
The numerator and denominator properties give the contents of each box,
while value gives the numerator divided by the denominator.
Property Example: valueChanged / immediateValueChanged
The valueChanged property is true once the user has changed either box and
the page has updated (when the user clicks elsewhere, hits Enter, or interacts
with another part of the page). The immediateValueChanged property becomes
true immediately as the user types.