Math made beautiful
for React
Build interactive coordinate planes, function plots, geometric shapes, and vector fields with a delightful declarative API.
See what you can build
Every visualization is interactive, accessible, and renders beautifully. Drag points, zoom in, and explore.
Everything you need to visualize math
A complete toolkit for interactive mathematical visualizations, designed for React developers.
Declarative API
Build complex visualizations with simple JSX. Compose components like any React app.
Built-in Interactions
Draggable points, pan, and zoom out of the box. useMovablePoint makes everything interactive.
TypeScript Native
Full TypeScript support with precise types for every component, prop, and callback.
SSR Compatible
Works with Next.js App Router, Pages Router, Remix, and any React SSR framework.
Accessible
SVG-based rendering is screen-reader friendly. Keyboard navigation for all interactive elements.
Composable
Mix coordinate systems, plots, shapes, and interactions. Wrap in Transform for complex layouts.
Delightfully simple API
A few lines of JSX is all it takes to create interactive mathematical visualizations.
1import { Mafs, Coordinates, Plot, Theme,2 useMovablePoint } from "mafs"3 4function InteractiveSine() {5 // Drag to change amplitude (y) and frequency (x)6 const point = useMovablePoint([1.5, 1.5])7 const freq = point.point[0]8 const amp = point.point[1]9 10 return (11 <Mafs height={340}>12 <Coordinates.Cartesian subdivisions={2} />13 <Plot.OfX14 y={(x) => amp * Math.sin(x * freq)}15 color={Theme.indigo}16 />17 {point.element}18 </Mafs>19 )20}Component gallery
A rich set of primitives that compose together to create any visualization.
<Plot.OfX />Plot any f(x) function
<Plot.Parametric />Parametric curves and Lissajous figures
<Point />Plot points on the plane
<Vector />Direction and magnitude
<Circle />Center and radius
<Polygon />N-sided filled shapes
<Line.Segment />Segments between two points
<Ellipse />Ellipses with semi-axes
<Text />Positioned labels
Powerful hooks for interactivity
React hooks that make math interactive. Drag, constrain, compute — all reactive.
useMovablePointCreate interactive draggable points that update on drag. Provides the point coordinates and a renderable element.
const p = useMovablePoint([1, 1]) // p.point → [x, y] // p.element → <DraggablePoint />
vec utilitiesVector math helpers: add, subtract, scale, rotate, normalize. Visualize vector addition by dragging the two input vectors.
const sum = vec.add(a.point, b.point) const scaled = vec.scale(v, 2) const unit = vec.normalize(v)
constrainConstrain points to curves, axes, or arbitrary paths. This point is locked to the sine curve.
useMovablePoint([1, 0], {
constrain: ([x]) => [x, Math.sin(x)]
})Bring math to life
The useStopwatch hook gives you a time value that ticks every frame — perfect for animations.
Orbital Motion
Two points orbiting at different speeds with a connecting line. Press play to start.
Traveling Waves
Three phase-shifted sine waves propagating through space. Press play to start.
40 interactive math demos
From calculus to fractals, from statistics to physics. Every demo is interactive and includes copyable code.
Quadratic Explorer
AlgebraDrag the vertex and a second point to reshape the parabola. The equation updates live.
Tangent Line
CalculusDrag the point along sin(x) to see the tangent line and its slope in real time.
Riemann Sums
CalculusDrag to increase the number of rectangles and watch the area converge to the integral.
Unit Circle
GeometryDrag the point around the circle to see sin, cos, and angle values update.
Bezier Curve
GeometryDrag 4 control points to shape a cubic Bezier curve with De Casteljau's algorithm.
Taylor Series
CalculusDrag to add more terms and watch the polynomial approximate sin(x) further from the origin.
Determinant as Area
Linear AlgebraDrag two vectors to see the parallelogram they form. The determinant equals the signed area.
Projectile Motion
PhysicsDrag the velocity vector to set launch angle and speed. Watch the projectile fly!
Fractal Tree
FractalsDrag to change the branch angle and watch the recursive tree transform.
Normal Distribution
StatisticsDrag two boundary points to shade the probability area under the bell curve.
Linear Regression
StatisticsDrag 6 data points and see the least-squares best-fit line update with residuals.
Spirals
GeometryArchimedes spiral (linear growth) vs Golden spiral (exponential growth) side by side.
Pendulum
PhysicsA damped pendulum swinging with decreasing amplitude. Uses useStopwatch for animation.
Lissajous Curves
GeometryDrag to change integer frequencies a and b to explore Lissajous figures.
Epsilon-Delta
CalculusDrag epsilon to see the corresponding delta for the limit of x² at x=1.
Matrix Transform
Linear AlgebraDrag î and ĵ basis vectors to see how the 2x2 matrix warps space. Grid lines transform too.
Vector Field Flow
Vector CalculusAnimated particles follow the rotation field F(x,y) = (-y, x). Watch them orbit!
Slope Field
Diff. EquationsDrag the initial condition point to see the Euler method solution curve follow the slope field.
Lotka-Volterra
Diff. EquationsPhase portrait of predator-prey dynamics. The pink dot traces the orbit over time.
Galton Board
ProbabilityPegs + bins form a binomial distribution, demonstrating the Central Limit Theorem.
Bayes' Theorem
ProbabilityDrag the prior probability to see how the posterior updates via Bayes' rule.
Probability Tree
ProbabilityInteractive probability tree with draggable P(A). Shows all branch probabilities.
Modular Multiplication
Number TheoryConnect points on a circle by multiplication mod n. Drag to change the multiplier and see cardioids emerge.
Prime Sieve
Number TheorySieve of Eratosthenes visualized. Dark points are primes, light are composite.
Fourier Series
Signal ProcessingDrag to add harmonics and watch the series converge to a square wave. See Gibbs phenomenon!
Convex Hull
GeometryDrag 8 points and watch the convex hull (Graham scan) update in real time.
Circle Packing
GeometryRandomly packed non-overlapping circles filling the coordinate plane.
Gradient Descent
OptimizationWatch gradient descent find the minimum of f(x,y) = x² + 3y² on a contour plot.
Partial Derivatives
Vector CalculusDrag a point to see the gradient vector and its ∂f/∂x and ∂f/∂y components.
Prisoner's Dilemma
Game TheoryDrag to set opponent's cooperation probability. Compare cooperate vs defect payoffs.
Complex Mapping z²
Complex AnalysisSee how the map w = z² transforms a rectangular grid into curves in the complex plane.
Julia Set
Complex AnalysisFractal boundary of z² + c iteration for c = -0.7 + 0.27i. Points that don't escape are plotted.
Galton Board Sim
SimulationWatch 100 balls fall through pegs and accumulate into a bell curve. Each ball takes a random path.
Spring-Mass System
SimulationDamped harmonic oscillator. Drag to adjust damping and watch the transition from underdamped to overdamped.
Double Pendulum
SimulationA chaotic double pendulum with trailing path. Tiny changes in initial conditions lead to wildly different trajectories.
Wave Interference
SimulationTwo wave sources with expanding wavefronts. Drag sources to see constructive and destructive interference.
Random Walks
Simulation5 independent random walks starting from the origin. Watch them spread out over time (Brownian motion).
N-Body Gravity
Simulation4 bodies interacting via gravity. One heavy central mass and 3 orbiting smaller masses with trails.
Logistic Map
SimulationCobweb diagram for x_{n+1} = r*x*(1-x). Drag r to explore period doubling and chaos.
Electric Field
SimulationDrag positive (+) and negative (-) charges to see the electric field vectors update in real time.
Built for every use case
From classrooms to production apps, Mafs powers interactive math everywhere.
Math Education
Build interactive lessons where students can drag, explore, and discover mathematical concepts. From elementary fractions to calculus, Mafs makes abstract ideas tangible.
Documentation
Embed live, interactive examples in your docs, blog posts, or READMEs. Readers can manipulate the math to build intuition instead of just reading about it.
Data Visualization
Plot scientific data, statistical distributions, or algorithm visualizations. Mafs' SVG rendering produces crisp output at any resolution.
Creative & Artistic
Generate mathematical art with polar curves, parametric equations, and fractals. Combine Mafs with animation hooks for stunning visual experiences.
Ready to get started?
Install Mafs in seconds and start building interactive math visualizations.