Math
TeX formulas rendered as native MathML: no font CSS, readable by screen readers, safe for untrusted input.
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
value | string | undefined | — | TeX source. When unset, the element's text content is used. |
display | boolean | false | Block (display) style, centred on its own line. Inline when false. |
Events
| Name | Type | Description |
|---|---|---|
math-error | CustomEvent<{ message: string; position?: number }> | The source failed to parse. position is the offset of the problem when known. |
CSS parts
Shadow DOM styling hooks used with ::part(name). Prefer CSS custom properties when they cover the change.
| Name | Description |
|---|---|
math | The rendered MathML formula. |
error | Shown instead of the formula when the source does not parse: the TeX source in the error style. |
CSS custom properties
Grouped by semantic target and state from --c2-<component>__<target>__<state>--<property>. Click a group to collapse it; click a name to copy it.
| Name | Type | Default | Description |
|---|---|---|---|
--c2-math--font-family | font-family | Cambria Math, STIX Two Math, STIXTwoMath-Regular, NotoSansMath-Regular, math | |
--c2-math--font-size | pixel | 1.1em | Math fonts run small next to body text. |
--c2-math--color | color | inherit | |
--c2-math__display--margin | margin | 12px 0 | Space around a display formula. |
--c2-math__display--text-align | text-align | center | |
--c2-math__error--color | color | rgb(211, 21, 16) | |
--c2-math__error--background | background | rgba(211, 21, 16, 0.08) | |
--c2-math__error--font-family | font-family | ui-monospace, SFMono-Regular, Menlo, Consolas, monospace | |
--c2-math__error--font-size | pixel | 0.9em | |
--c2-math__error--border-radius | border-radius | 4px | |
--c2-math__scroller__focus--outline | outline | 2px solid rgba(2, 101, 220, 0.4) | Focus ring of a display formula that overflows and scrolls. |