Math
TeX math typeset with KaTeX. Formula sits inside a sentence; Equation stands on its own line, numbered and captioned when you want. Screen readers get real MathML, and chemistry is one \ce away.
Install
npx shadcn@latest add @nelumbo/mathUsage
import { Equation, Formula } from "@/components/ui/math"// String.raw keeps backslashes as written<p>The rate is <Formula>{String.raw`v = \frac{V_{max}[S]}{K_m + [S]}`}</Formula>.</p><Equation number={1} caption="Michaelis–Menten"> {String.raw`v = \frac{V_{\max}[S]}{K_m + [S]}`}</Equation>Inline
Formula takes the size of the text around it and sits on its baseline.
At low substrate the rate is nearly linear, , and it saturates at when . A buffer works best within one unit of its , where .
Numbered equations
number puts a reference on the right; caption names the equation. Hover or focus to copy the TeX.
Aligned derivations
aligned lines several steps up on their equals signs. This is the steady-state derivation of Michaelis–Menten.
Populations, light and membranes
Fractions, sums, derivatives, cases and Greek letters.
Chemistry
mhchem is built in: \ce writes reactions with proper arrows, charges and states, and \pu writes units.
Matrices and cases
Rotation about z, used to turn a structure, and a piecewise dose response.
Try it
Type TeX and it typesets as you go. An error shows the source and what went wrong, instead of breaking the page.
Props
| Prop | Type | Default | Notes |
|---|---|---|---|
children / tex | string | — | The TeX source. String.raw saves escaping backslashes. |
macros | Record<string, string> | — | Shortcuts, e.g. { "\\R": "\\mathbb{R}" }. |
Equation number | ReactNode | — | Reference at the right, in parentheses. |
Equation caption | ReactNode | — | A short caption under the equation. |
Equation align | "center" | "start" | "center" | Where the equation sits. |
Equation copyable | boolean | true | A button that copies the TeX source. |