Git Product home page Git Product logo

react-mathquill's Introduction

React component wrapper for Mathquill

npm version

Examples

Editable Math Field

import React, { useState } from 'react'
import { addStyles, EditableMathField } from 'react-mathquill'

// inserts the required css to the <head> block.
// you can skip this, if you want to do that by yourself.
addStyles()

const EditableMathExample = () => {
  const [latex, setLatex] = useState('\\frac{1}{\\sqrt{2}}\\cdot 2')

  return (
    <div>
      <EditableMathField
        latex={latex}
        onChange={(mathField) => {
          setLatex(mathField.latex())
        }}
      />
      <p>{latex}</p>
    </div>
  )
}

Static Math Field

import React from 'react'
import { addStyles, StaticMathField } from 'react-mathquill'

// inserts the required css to the <head> block.
// you can skip this, if you want to do that by yourself.
addStyles()

const StaticMathExample = () => (
  <StaticMathField>{'\\frac{1}{\\sqrt{2}}\\cdot 2'}</StaticMathField>
)

Documentation

addStyles (function)

This function, when called, will append a <style id="react-mathquill-styles"> tag to the <head> of the document. The style tag includes all the required styles for Mathquill to work.

This function is not necessary, provided you include the styles in another way. See Mathquill Docs - Download and Load

EditableMathField (React Element)

Wrapper for Mathquill MathField

Props

  • latex: String - Initial latex value for the input field
  • config: Object - A mathquill config object
  • onChange(mathField) - A function that is called on change events.
  • mathquillDidMount(mathField) - A function that is called when the Mathquill element is initalized.

Other props will be passed to the wrapping span element, this can be useful for custom classNames or styles

StaticMathField (React Element)

Wrapper for Mathquill StaticField

Props

  • children: String - A string of latex to render statically on the page

Other props will be passed to the wrapping span element, this can be useful for custom classNames or styles

react-mathquill's People

Contributors

alx-ppv avatar christineoo avatar cubedeye avatar dependabot[bot] avatar entkenntnis avatar mdolsma avatar mrwwalmsley avatar serenalynas avatar viktorstrate avatar xamohsen avatar

Forkers

numberworks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.