This page is the single reference for what is installed and how to use every
component in a note. All components listed here are registered globally in
src/theme/MDXComponents.js, so they work in any .md or .mdx file without an
import statement.
Live examples: Interactive Components gallery.
Write components as JSX. String props accept normal text; TeX props need escaped
backslashes in plain strings (math="\\nabla f") or can be passed as an expression
(math={"\\nabla f"}).
1. Installed display packages
| Package | Version | Role | Used by | Loaded |
|---|
mafs | ^0.21.0 | Interactive math plots (functions, axes, points) | FunctionPlot, gradient-descent plot | lazy |
echarts | ^6.1.0 | Scientific charts (line, heatmap, …) | DataChart, AttentionMap | lazy |
@xyflow/react | ^13.0.3 | Zoomable node/edge architecture graphs | ArchitectureDiagram, ComputationGraph | lazy |
motion | ^14.14.0 | Animation (ex-Framer Motion) | Reveal | lazy |
medium-zoom | ^1.1.2 | Click-to-zoom images | Figure | lazy |
katex | ^0.19.1 | TeX rendering inside components | MathTex (used by Definition, Equation, MathDerivation, AlgorithmPlayer) | lazy |
three | ^0.187.0 | 3D engine | all 3D components | lazy |
@react-three/fiber | ^9.8.2 | React renderer for three.js | all 3D components | lazy |
@react-three/drei | ^10.7.9 | 3D helpers (OrbitControls) | all 3D components | lazy |
lucide-react | ^1.24.0 | Icon set | ad-hoc use in notes/pages | eager |
react-icons | ^5.5.0 | Icon set | ad-hoc use in notes/pages | eager |
leaflet | ^1.9.4 | Maps | link/workspace pages | eager |
prism-react-renderer | ^2.4.1 | Syntax highlighting (Docusaurus theme) | code blocks | eager |
@docusaurus/theme-mermaid | ^3.10.2 | Mermaid diagrams | ```mermaid blocks | lazy |
remark-math / rehype-katex | 6 / 7 | Build-time TeX in Markdown | $…$ / $$…$$ | build-time |
Not installed (deferred): @codesandbox/sandpack-react (live JS editor),
pyodide (browser Python), @docusaurus/plugin-ideal-image (responsive images).
:::note Performance
Every heavy package is imported inside a lazily loaded component. Registering them
globally does not add them to pages that never render that component.
:::
2. Component index
| Group | Components |
|---|
| Knowledge | Card, CardGrid, Stat, Definition, Equation, Compare, Steps, Timeline, Term, MathDerivation |
| Media | Figure, Gallery, Reference, AnnotatedFigure |
| Learning | Quiz, Hint, Solution, Flashcard, LearningObjectives, Prerequisites |
| Math & AI | TensorViewer, MatrixViewer, MatrixOperation, NeuralNetwork, FunctionPlot |
| Data & graphs | DataChart, AttentionMap, ArchitectureDiagram, ComputationGraph, Reveal |
| 3D | CoordinateFrame, PointCloudViewer, LossSurface, RobotViewer |
| Labs | InteractiveLab, AlgorithmPlayer, PlaybackControls, ParameterSlider, CalculationInspector, useInteractive, plus GradientDescentLab, AttentionLab, NeuralNetworkLab |
3. Knowledge components
Card / CardGrid
| Prop | Type | Default | Notes |
|---|
title | string | — | card heading |
description | string | — | body text |
icon | node | — | rendered above the title |
to | string | — | when set, the card becomes a link |
CardGrid prop | Type | Default |
|---|
columns | number | 3 |
children | node | — |
<CardGrid columns={3}>
<Card title="Linear Algebra" description="Vectors · Matrices" to="/notes/mathematics" />
<Card title="Neural Networks" description="Neuron · Layers" />
</CardGrid>
Stat
| Prop | Type | Notes |
|---|
label | string | small caption |
value | string | number | large number |
unit | string | optional suffix |
<Stat label="Parameters" value="7B" />
Definition / Equation
| Prop | Type | Notes |
|---|
title | string | term / heading |
math | string | TeX, rendered display-style |
children | node | explanation text |
<Definition title="Gradient" math="\\nabla f(\\mathbf{x})">
The direction of steepest ascent.
</Definition>
Equation prop | Type | Notes |
|---|
math | string | TeX, display-style |
caption | string | optional caption |
number | string | number | optional right-aligned label |
Compare / Steps / Timeline
| Prop | Type | Notes |
|---|
leftTitle, rightTitle | string | column headings |
left, right | node | column content |
<Compare leftTitle="MSE" rightTitle="Cross-Entropy" left="…" right="…" />
Steps prop | Type | Notes |
|---|
items | array | each item is a string, or { title, text } |
Timeline prop | Type | Notes |
|---|
items | array | each item is { time, title, text } |
Term / MathDerivation
Term prop | Type | Notes |
|---|
term | string | visible text (dotted underline) |
children | node | tooltip content on hover/focus |
MathDerivation prop | Type | Notes |
|---|
title | string | summary label, default Derivation |
steps | array | each step is { math, text }; collapsed by default |
<MathDerivation
title="MSE gradient"
steps={[
{ math: "L = (\\hat{y} - y)^2", text: "Loss." },
{ math: "\\frac{\\partial L}{\\partial \\hat{y}} = 2(\\hat{y} - y)" },
]}
/>
Figure prop | Type | Default | Notes |
|---|
src | string | — | image URL |
alt | string | — | required for accessibility |
caption | string | — | below the image |
source | string | — | attribution line |
zoom | boolean | true | click-to-zoom via medium-zoom |
Gallery prop | Type | Notes |
|---|
images | array | each { src, alt, caption, source } |
Reference prop | Type | Notes |
|---|
title | string | paper / book title |
authors, year | string | metadata line |
source | string | e.g. arXiv, MIT Press |
url | string | when set, renders as an external link |
AnnotatedFigure prop | Type | Notes |
|---|
src, alt, caption | string | as Figure |
hotspots | array | each { x, y, label, description }; x,y are percentages 0–100 |
<AnnotatedFigure
src="/img/diagram.png"
alt="Architecture"
hotspots={[{ x: 20, y: 50, label: "Encoder", description: "Compresses the input." }]}
/>
5. Learning components
Quiz prop | Type | Notes |
|---|
question | string | prompt |
options | string[] | answer choices |
answer | number | 0-based index of the correct option |
explanation | string | shown after checking |
<Quiz
question="What is the output shape?"
options={["3 × 4", "4 × 3"]}
answer={1}
explanation="Transpose swaps the two dimensions."
/>
| Component | Props | Notes |
|---|
Hint | title (default Hint), children | collapsible |
Solution | title (default Solution), children | collapsible, closed |
Flashcard | front, back | click to flip |
LearningObjectives | items (string[]) | objectives block |
Prerequisites | items (string[] or { label, to }) | links to prerequisite notes |
6. Math & AI components
TensorViewer
| Prop | Type | Default | Notes |
|---|
shape | [rows, cols] | [3, 4] | input tensor shape |
operations | string[] | ["original", "transpose"] | any of original, transpose, reshape, indexing, slicing, broadcasting |
targetShape | [rows, cols] | — | for reshape |
showIndices | boolean | true | show (row, col) under each cell |
broadcastValue | number | 0 | initial scalar offset for broadcasting |
<TensorViewer shape={[3, 4]} operations={["original", "transpose", "slicing"]} />
MatrixViewer / MatrixOperation
MatrixViewer prop | Type | Notes |
|---|
matrix | number[][] | values |
highlight | [r, c] or [[r, c], …] | highlighted cells |
showIndices | boolean | show index labels |
MatrixOperation prop | Type | Notes |
|---|
left, right | number[][] | operands of A × B |
showIndices | boolean | default true |
Click a result cell to see the dot-product expansion.
<MatrixOperation left={[[1, 2], [3, 4]]} right={[[1, 0], [0, 1]]} />
NeuralNetwork
| Prop | Type | Default | Notes |
|---|
layers | number[] | [3, 4, 3, 2] | neuron count per layer |
activation | string | "relu" | label used in the step equation |
showEquations | boolean | true | show the per-step formula |
stepControls | boolean | true | previous / next stepping |
FunctionPlot (mafs)
| Prop | Type | Default | Notes |
|---|
functions | string[] | ["relu"] | relu, sigmoid, tanh, linear, sin, cos, square |
parameters | { w, b } | { w: 1, b: 0 } | initial values of f(wx + b) |
interactive | boolean | false | adds weight/bias sliders |
height | number | 320 | plot height in px |
<FunctionPlot functions={["relu", "tanh"]} interactive />
:::caution Assumptions
FunctionPlot evaluates f(w·x + b); it is a schematic view, not a fitted model.
The gradient-descent lab assumes L(θ) = θ² with ∇L = 2θ, so a learning rate
η ≥ 1 diverges — that is mathematically correct, not a bug.
:::
7. Data & graph components
DataChart prop | Type | Notes |
|---|
option | object | full ECharts option |
height | number | default 360 |
<DataChart
option={{
xAxis: { type: "category", data: ["1", "2", "3"] },
yAxis: { type: "value" },
series: [{ type: "line", data: [3, 2, 1] }],
}}
/>
AttentionMap prop | Type | Notes |
|---|
matrix | number[][] | values (rows × cols) |
rowLabels, colLabels | string[] | tick labels |
height | number | default 360 |
ArchitectureDiagram prop | Type | Notes |
|---|
nodes | { id, position: {x,y}, data: { label, explanation? } }[] | React Flow nodes |
edges | { id, source, target }[] | React Flow edges |
height | number | default 400 |
selectable | boolean | click a node to show data.explanation below |
ComputationGraph is an alias of ArchitectureDiagram.
Reveal prop | Type | Notes |
|---|
children | node | content |
delay | number | seconds |
y | number | initial vertical offset |
once | boolean | animate once (default true) |
:::note SSR
ECharts and React Flow draw after hydration. In the static HTML you will see the
container only — that is expected and does not affect SEO of the surrounding text.
:::
8. 3D components
All 3D components render client-side only and show a placeholder before hydration.
CoordinateFrame prop | Type | Notes |
|---|
rotation | [x, y, z] radians | draws a second, rotated frame |
size | number | axis length, default 2 |
showGrid | boolean | default true |
height | number | default 360 |
PointCloudViewer prop | Type | Notes |
|---|
points | [x, y, z][] | omit for a unit-sphere sample |
color, size | string, number | point rendering |
height | number | default 360 |
LossSurface prop | Type | Notes |
|---|
fn | (x, y) => z | surface function |
color, wireframe | string, boolean | material |
height | number | default 380 |
RobotViewer prop | Type | Notes |
|---|
links | number[] | segment lengths, default [1, 0.9, 0.6] |
initialAngles | number[] | radians |
interactive | boolean | joint-angle sliders |
height | number | default 380 |
<RobotViewer links={[1, 0.9, 0.6]} />
9. Interactive lab framework
A lab separates a pure computational model (.mjs, unit-testable) from the
rendering components, and shares state through React Context.
InteractiveLab
| Prop | Type | Notes |
|---|
title | string | panel heading |
parameters | object | { name: { value, min, max, step, label } } |
compute | (values) => result | pure function, memoized per value change |
children | node | sliders, player, diagrams |
compute must return at least states, an array of steps:
{
name: "Step 2 — …",
description: "…",
equation: "\\theta_{k+1} = …",
calculation: [
{ label: "θ", formula: "θ − η∇L", value: "1.200" },
],
code: "theta -= lr * 2 * theta",
}
Any extra keys on the result (e.g. path, weights) are available through
useInteractive().result.
Companion components
| Component | Props | Notes |
|---|
PlaybackControls | — | previous / play / next / reset + step counter |
ParameterSlider | name, label | bound to a lab parameter |
CalculationInspector | — | renders current.calculation |
AlgorithmPlayer | renderStep(current) | step title, prose, equation, calculation, code |
useInteractive() | — | { values, setParameter, stepIndex, stepCount, goToStep, playing, setPlaying, reset, states, current, result } |
Ready-made labs
| Component | Props | Model assumptions |
|---|
GradientDescentLab | — | L(θ) = θ², ∇L = 2θ, θ ← θ − η∇L |
AttentionLab | — | softmax(QKᵀ/√dₖ)V on 2×2 Q,K,V |
NeuralNetworkLab | — | 2→2→1 MLP, ReLU hidden, MSE loss, analytic backprop |
10. Curriculum (page-level)
A reusable syllabus renderer. It takes all content as props, so text lives in
the note's own data file rather than inside the component.
| Prop | Type | Notes |
|---|
chapters | array | { title, zh, weeks, color, question, formula, sources, project, lab, gate, optional, lessons } |
lessons | array | inside a chapter: [id, week, title, scope, practice] |
resources | array | [title, description, url, pdfUrl] |
papers | array | [title, url] |
skills | array | [title, description] |
protocolCards | array | [title, description] |
statuses | object | { key: label }, default four English statuses |
durations | number[] | weeks per chapter |
timeLegend | array | [label, color, hours] |
defaultStatus | object | { lessonId: statusKey } |
labels | object | UI strings; deep-merged over English defaults |
Import the page component and keep its content next to the note:
import Curriculum from "@site/src/components/NnCurriculum";
import * as curriculum from "./curriculum-data";
<Curriculum {...curriculum} />
Progress is stored in localStorage; no account is required. Adding labels
lets one component render an English, Chinese, or Japanese syllabus.
11. Standalone lesson pages
Add lesson: true to a doc's front matter to render it as a standalone course
page: full width, no outline, no breadcrumbs, no paginator, opaque navbar, and a
paper palette that stays light in both themes. The page then supplies its own hero
and section navigation.
---
title: "Lesson 1.1 — Tensor Fundamentals"
hide_title: true
hide_table_of_contents: true
lesson: true
---
Live example: Lesson 1.1.
Layout components
| Component | Props | Notes |
|---|
LessonHero | eyebrow, title (\n breaks lines), description, meta[] | full-bleed dark header |
LessonNav | items: { id, label }[] | sticky under the navbar; anchors to heading ids |
SectionHead | number, label | small "01 / CONCEPTS" marker above an h2 |
Intro | children | muted section intro (renders a div) |
Panel | children, className | white card |
Callout | children | teal left-border note |
LessonGrid | columns (2 or 3), children | two/three-column layout |
Formula | children | monospace formula block |
Because Intro and Panel are divs, markdown paragraphs and tables inside them
are valid HTML. Do not wrap multi-line markdown in a raw JSX <p> — MDX nests
another paragraph inside it.
Interactive lab components
| Component | Props | Notes |
|---|
CodeLab | title, code, output?, question?, hint?, open? | copy button, collapsible expected output |
FreeResponseQuiz | questions: { prompt, answer, explanation }[], checkLabel, checkAllLabel, resetLabel, gatePassed, gatePending | normalized answer checking, progress bar, per-question feedback |
RankCards | items? ([title, shape, description]) | 0-D to 3-D SVG previews |
TensorShapeLab | — | rank 0–3, per-axis sliders, axis highlight, slice animation, live shape/ndim/numel and generated PyTorch code |
RobotTensorLab | — | B/T/J/S sliders, hierarchy diagram, index/time/merge operations |
TensorOpDemo | — | transpose / reshape / indexing with a step-by-step element-mapping animation |
<SectionHead number="02" label="INTERACTIVE EXPLORER" />
<h2 id="explorer">Tensor Shape Lab</h2>
<TensorShapeLab />
FreeResponseQuiz answers accept brackets, commas, spaces and full-width
punctuation: (32, 100, 7, 3) and 32 100 7 3 both normalize to 32,100,7,3.
12. Authoring checklist
- Use components without imports — they are global.
- Prefer a component over raw HTML: it is themed, responsive, and accessible.
- Keep prose in Markdown; keep data (chapters, matrices, options) in props or a
co-located data file.
- Put math in
$…$ / $$…$$ in Markdown; use the math prop inside components.
- Do not paste large JSON into an MDX file — import it from a sibling
.js file.
- Run
yarn test && yarn build before publishing; the build validates links.