npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mathex-editor

v0.0.3

Published

A Desmos-like math equation editor component library for React

Readme

Mathex

A Desmos-like math equation editor component library for React. Build beautiful, interactive math input experiences for educational platforms.

Features

  • 🎨 Beautiful UI - Desmos-inspired design with light and dark themes
  • ⌨️ On-Screen Keyboard - Full math keyboard with symbols, functions, and operators
  • 📱 Context-Aware - Multi-input support with automatic keyboard routing
  • 🔢 13 Function Categories - Complete set of math functions from Trig to Calculus
  • TypeScript - Full type safety and IntelliSense support
  • 🎯 Lightweight - Tree-shakeable and optimized for production

Installation

npm install mathex

Quick Start

import { MathProvider, MathInput, MathKeyboard } from 'mathex';

function App() {
  const [latex, setLatex] = useState('x^2 + 3x + 1');

  return (
    <MathProvider theme="light">
      <MathInput
        value={latex}
        onChange={setLatex}
        placeholder="Enter equation..."
      />
      <MathKeyboard />
    </MathProvider>
  );
}

Theming

Mathex supports both light and dark themes out of the box.

Light Theme (Default)

<MathProvider theme="light">
  <MathInput />
  <MathKeyboard />
</MathProvider>

Dark Theme

<MathProvider theme="dark">
  <MathInput />
  <MathKeyboard />
</MathProvider>

Dynamic Theme Switching

function App() {
  const [theme, setTheme] = useState<'light' | 'dark'>('light');

  const toggleTheme = () => {
    setTheme(current => current === 'light' ? 'dark' : 'light');
  };

  return (
    <MathProvider theme={theme}>
      <button onClick={toggleTheme}>
        {theme === 'light' ? '🌙 Dark Mode' : '☀️ Light Mode'}
      </button>
      <MathInput />
      <MathKeyboard />
    </MathProvider>
  );
}

Custom Theme

You can customize the theme by providing a ThemeConfig object:

const customTheme = {
  colors: {
    primary: '#FF5722',
    background: '#FFF',
    text: '#000',
    border: '#CCC',
  },
  // ... more customization options
};

<MathProvider theme={customTheme}>
  <MathInput />
  <MathKeyboard />
</MathProvider>

Components

MathProvider

The context provider that manages global state and communication between components.

Props:

  • theme - 'light' | 'dark' | ThemeConfig - Theme configuration (default: 'light')
  • children - React components to wrap

MathInput

An input field for entering and displaying mathematical equations.

Props:

  • value - string - LaTeX string (controlled mode)
  • defaultValue - string - LaTeX string (uncontrolled mode)
  • onChange - (latex: string) => void - Callback when value changes
  • placeholder - string - Placeholder text
  • disabled - boolean - Disable input
  • className - string - Additional CSS classes
  • style - CSSProperties - Inline styles
  • onError - (error: Error) => void - Error callback

MathKeyboard

An on-screen keyboard for entering math symbols and functions.

Props:

  • isVisible - boolean - Control keyboard visibility
  • onVisibilityChange - (visible: boolean) => void - Visibility change callback
  • className - string - Additional CSS classes
  • style - CSSProperties - Inline styles

Multiple Inputs

Mathex automatically handles multiple inputs - the keyboard routes input to whichever field is focused:

<MathProvider theme="light">
  <div>
    <label>Equation 1:</label>
    <MathInput value={latex1} onChange={setLatex1} />
  </div>

  <div>
    <label>Equation 2:</label>
    <MathInput value={latex2} onChange={setLatex2} />
  </div>

  <div>
    <label>Equation 3:</label>
    <MathInput value={latex3} onChange={setLatex3} />
  </div>

  {/* One keyboard routes to all inputs */}
  <MathKeyboard />
</MathProvider>

Function Categories

The keyboard includes all 13 function categories from Desmos:

  1. Trig Functions - sin, cos, tan, csc, sec, cot
  2. Inverse Trig - sin⁻¹, cos⁻¹, tan⁻¹, csc⁻¹, sec⁻¹, cot⁻¹
  3. Calculus - exp, ln, log, d/dx, ∫, Σ, Π
  4. Number Theory - lcm, gcd, mod, ceil, floor, round, ⁿ√, nPr, nCr
  5. Hyperbolic Trig - sinh, cosh, tanh, csch, sech, coth
  6. Statistics - mean, median, min, max, stdev, var, corr, and more
  7. Probability - normaldist, tdist, binomialdist, pdf, cdf, random
  8. Inference - ztest, ttest, chisqtest, confidence intervals
  9. List Operations - repeat, join, sort, shuffle, unique
  10. Visualizations - histogram, dotplot, boxplot
  11. Geometry - polygon, distance, midpoint
  12. Custom Colors - rgb, hsv, oklab, oklch
  13. Sound - tone

Keyboard Modes

  • Default Mode - Numbers, operators, variables, and common symbols
  • ABC Mode - QWERTY keyboard for entering letters and Greek symbols

License

MIT

Contributing

Contributions welcome! Please open an issue or PR on GitHub.

Support

For questions or issues, please visit our GitHub Issues.