bezier-easing-editor

June 10, 2026 · View on GitHub

Cubic Bezier Curve editor made with React & SVG.

npm CI

Example

(click to open)

Install

npm install bezier-easing-editor

Requires React 17 or higher. TypeScript types are included.

Usage

Controlled

Provide value and an onChange handler:

import { useState } from "react";
import BezierEditor, { type BezierValue } from "bezier-easing-editor";

function MyEditor() {
  const [value, setValue] = useState<BezierValue>([0.25, 0.25, 0.75, 0.75]);
  return <BezierEditor value={value} onChange={setValue} />;
}

Uncontrolled

Just define a defaultValue:

<BezierEditor defaultValue={[0.2, 0.2, 0.8, 0.8]} onChange={console.log} />

Props

PropTypeDefaultDescription
value[x1, y1, x2, y2]current easing (controlled mode)
defaultValue[x1, y1, x2, y2][0.25, 0.25, 0.75, 0.75]initial easing (uncontrolled mode)
onChange(value) => voidcalled when a handle is dragged
widthnumber300svg width in pixels
heightnumber300svg height in pixels
padding[top, right, bottom, left][25, 5, 25, 18]padding around the grid
progressnumber0progress in [0,1] to visualize on the curve
readOnlybooleanfalsehide the handles and disable edition
backgroundstring"#fff"background color
gridColorstring"#eee"grid color
curveColorstring"#333"curve color
curveWidthnumber2curve stroke width
handleColorstring"#f00"handle color
handleRadiusnumber5handle circle radius
handleStrokenumber2handle stroke width
progressColorstring"#ccc"progress lines color
textStyleCSSPropertiessans-serif 10pxstyle of the axis labels
style / classNameapplied to the root svg
childrenReactNodeextra SVG elements rendered in the editor

Development

npm install
npm test          # run the test suite (vitest)
npm run build     # build the library (tsup: ESM + CJS + types)

cd example
npm install
npm run dev       # run the example app (vite)

The example app is deployed to GitHub Pages automatically on every push to master by the deploy workflow.

Release

Releases are automated with changesets. Run npx changeset in your PR to describe the change and pick a semver bump. On merge, the release workflow opens a "Version Packages" PR; merging it publishes to npm (via trusted publishing, no token) and creates the GitHub release.

See also