ReferenceionicCompound

<ionicCompound>

Forms a balanced ionic compound from constituent ions and renders its chemical formula

<ionicCompound> is a Subject-specific component that builds a balanced ionic compound from a cation and an anion and renders the resulting chemical formula. It automatically determines the smallest integer subscripts that produce a neutral compound.

Attributes and Properties

Attributes for <ionicCompound>

Other (3)
atomicNumber

integer. The atomic number of an element in the compound.

charge

integer. The charge of an ion in the compound.

symbol

text. The chemical symbol of an element in the compound.

Common to all components (9)
copy

reference. Create an independent copy of another component by reference. Enter a references a $name.

disabled

boolean. Default value: false. Whether this component is disabled and cannot be interacted with.

extend

reference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.

fixed

boolean. Default value: false. Whether this component's value is fixed and cannot be modified.

fixLocation

boolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

hide

boolean. Default value: false. Whether to hide this component from the rendered output.

isResponse

boolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.

name

text. The name used to reference this component from elsewhere in the document.

styleNumber

integer. Default value: 1. The style number used to select this component's visual styling from the available style definitions.

Properties for <ionicCompound name="i">

Other (10)
$i.backgroundColor

text. Human-readable name for this component's background color, derived from the active style and theme.

$i.disabled

boolean. Whether this component is disabled and cannot be interacted with.

$i.fixed

boolean. Whether this component's value is fixed and cannot be modified.

$i.fixLocation

boolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

$i.hidden

boolean. Whether this component is hidden from the rendered output.

latex. The ionic compound rendered as a LaTeX string.

$i.math

math. The ionic compound rendered as a math expression of its chemical formula.

$i.text

text. The ionic compound rendered as a plain text string.

$i.textColor

text. Human-readable name for this component's text color, derived from the active style and theme.

$i.textStyleDescription

text. Human-readable description of this component's text styling (color and any background color).

Common to all components (4)
$i.doenetML

text. The DoenetML source code that produced this component.

$i.hide

boolean. Whether to hide this component from the rendered output.

$i.isResponse

boolean. Whether this component is treated as a response for the purposes of assessment.

$i.styleNumber

integer. The style number used to select this component's visual styling from the available style definitions.

Examples

Example: Two <ion> children

An <ionicCompound> takes exactly two <ion> children — one cation and one anion. The component computes the simplest whole-number ratio of the two ions that produces a net charge of zero and renders the resulting formula with subscripted counts.


Example: Default charges from element symbols

When the <ion> children omit a charge, each ion uses its element’s most common charge. This makes it convenient to construct binary ionic compounds from main-group elements with predictable oxidation states.


Example: Use in an answer block

The math property is the most convenient way to use an <ionicCompound> as the reference answer in an <answer> block, since the student’s <mathInput/> value can be compared directly.

Property Examples

Property Example: math, latex, text

math is a math expression that can be used in computations, latex is a LaTeX string suitable for rendering, and text is a plain-text fallback. Subscripted ion counts appear as _{n} in the LaTeX form.