DrawsmithComing soonالعربية

Coming soon

Diagrams,
yours in code.

Drawsmith is a headless diagram library for React. Stream a drawing from a model, show it, let people edit it, run a workflow on it. The nodes, the theme and the editor are yours.

Watch the teaserSee what it does

01Streaming

It draws while the model is still typing.

Hand it a reply that is still arriving. Nothing half written is drawn, and what is already on the page holds its place while the rest comes in.

The model’s replyMermaid

Here is the refund flow as you described it:```mermaidflowchart TD  ask([Refund requested]) --> found{Order found?}  found -->|no| number[Ask for the order number]  found -->|yes| window{Within 30 days?}  window -->|yes| unused{Item unused?}  window -->|no| credit[Offer store credit]  unused -->|yes| card[Refund to card]  unused -->|no| review[Send to an agent]  card --> receipt([Send the receipt])  credit --> receipt  review --> receipt  receipt --> done([Close the request])```

<Diagram source={reply} streaming={!done} />

FlowchartFlowchart, top to bottom, with 10 steps and 11 connections. Refund requested leads to Order found? Order found? leads to Ask for the order number (labelled “no”) and Within 30 days? (labelled “yes”). Within 30 days? leads to Item unused? (labelled “yes”) and Offer store credit (labelled “no”). Item unused? leads to Refund to card (labelled “yes”) and Send to an agent (labelled “no”). Offer store credit leads to Send the receipt. Refund to card leads to Send the receipt. Send to an agent leads to Send the receipt. Send the receipt leads to Close the request.noyesyesnoyesnoRefund requestedOrder found?Ask for the ordernumberWithin 30 days?Item unused?Offer store creditRefund to cardSend to an agentSend the receiptClose the request

Drawn as the text arrives

02View mode

One component. Pan it. Zoom it. Ship it.

Drag to pan, pinch to zoom, and the page keeps scrolling over it. Its colours are CSS variables, so it wears your page. This one is live.

schema.tsxReact

import '@drawsmith/core/theme.css';import { Diagram } from '@drawsmith/react'; export function Schema({ doc }: { doc: DiagramDoc }) {  return <Diagram doc={doc} onNodeClick={id => open(id)} />;}
Entity relationship diagramEntity relationship diagram with 11 entities and 12 relationships. organization: attributes PK id uuid; name text; country_code char(2); created_at timestamptz. organization 1 — 0..∞ workspace. organization 1 — 1 billing_account. workspace: attributes PK id uuid; FK organization_id uuid; UK slug text; region text. workspace 1 — 0..∞ usage_event. billing_account: attributes PK id uuid; FK organization_id uuid; UK processor_customer_id text; currency char(3); tax_id text. billing_account 1 — 0..∞ subscription. billing_account 1 — 0..∞ invoice. plan: attributes PK code text; name text; seat_limit int. plan 1 — 0..∞ subscription. plan 1 — 1..∞ plan_price. plan_price: attributes PK id uuid; FK plan_code text; interval text; unit_amount_cents int; currency char(3). plan_price 1 — 0..∞ subscription_item. subscription: attributes PK id uuid; FK billing_account_id uuid; FK plan_code text; status text; current_period_end timestamptz. subscription 1 — 0..∞ subscription_item. subscription_item: attributes PK id uuid; FK subscription_id uuid; FK plan_price_id uuid; quantity int. subscription_item 1 — 0..∞ usage_event. invoice: attributes PK id uuid; FK billing_account_id uuid; UK number text; total_cents int; status text; due_on date. invoice 1 — 1..∞ invoice_line. invoice 1 — 0..∞ payment. invoice_line: attributes PK id uuid; FK invoice_id uuid; description text; amount_cents int. payment: attributes PK id uuid; FK invoice_id uuid; method text; amount_cents int; paid_at timestamptz. usage_event: attributes PK id bigint; FK workspace_id uuid; FK subscription_item_id uuid; metric text; quantity bigint; occurred_at timestamptz.1 — 0..∞1 — 11 — 0..∞1 — 0..∞1 — 1..∞1 — 0..∞1 — 0..∞1 — 0..∞1 — 1..∞1 — 0..∞1 — 0..∞1 — 0..∞«table»organizationPKiduuidnametextcountry_codechar(2)created_attimestamptz«table»workspacePKiduuidFKorganization_iduuidUKslugtextregiontext«table»billing_accountPKiduuidFKorganization_iduuidUKprocessor_customer_id textcurrencychar(3)tax_idtext«table»planPKcodetextnametextseat_limitint«table»plan_pricePKiduuidFKplan_codetextintervaltextunit_amount_centsintcurrencychar(3)«table»subscriptionPKiduuidFKbilling_account_iduuidFKplan_codetextstatustextcurrent_period_endtimestamptz«table»subscription_itemPKiduuidFKsubscription_iduuidFKplan_price_iduuidquantityint«table»invoicePKiduuidFKbilling_account_iduuidUKnumbertexttotal_centsintstatustextdue_ondate«table»invoice_linePKiduuidFKinvoice_iduuiddescriptiontextamount_centsint«table»paymentPKiduuidFKinvoice_iduuidmethodtextamount_centsintpaid_attimestamptz«table»usage_eventPKidbigintFKworkspace_iduuidFKsubscription_item_iduuidmetrictextquantitybigintoccurred_attimestamptz

A still of the drawing, until the viewer loads.

03Editor mode

Build your own editor.

The engine brings selection, handles, guides, undo, the keyboard and the clipboard. You bring the interface. Two small editors are running below, each laid out its own way. Try them.

FlowchartFlowchart, left to right, with 6 steps and 6 connections. Cart leads to Pay now? Pay now? leads to Take the payment (labelled “Card”) and Send an invoice (labelled “Later”). Take the payment leads to Pack the order. Send an invoice leads to Pack the order. Pack the order leads to Ship it.CardLaterCartPay now?Take the paymentSend an invoicePack the orderShip it
Live. A canvas with one bar floating over it. Drag a box, draw a line, then undo it.

floating-editor.tsxReact

'use client'; import {  Canvas,  EditorRoot,  useHistory,  useTool,  useViewport,} from '@drawsmith/react/edit'; // One bar, floating over the canvas. Every button is a hook away.function Bar() {  const { tool, tools, setTool } = useTool();  const { undo, redo, canUndo, canRedo } = useHistory();  const { zoom, zoomIn, zoomOut } = useViewport();  return (    <div className='ed-float' role='toolbar' aria-label='Tools'>      {tools.slice(0, 4).map(t => (        <button          key={t.name}          type='button'          aria-pressed={tool === t.name}          onClick={() => setTool(t.name)}        >          {t.label}        </button>      ))}      <i />      <button type='button' onClick={undo} disabled={!canUndo}>        Undo      </button>      <button type='button' onClick={redo} disabled={!canRedo}>        Redo      </button>      <i />      <button type='button' onClick={zoomOut} aria-label='Zoom out'>        −      </button>      <span>{Math.round(zoom * 100)}%</span>      <button type='button' onClick={zoomIn} aria-label='Zoom in'>        +      </button>    </div>  );} export function FloatingEditor({ doc }: { doc: unknown }) {  return (    <EditorRoot defaultDoc={doc}>      <Canvas className='ed-canvas' title='A checkout flow' />      <Bar />    </EditorRoot>  );}

04Workflows

Your nodes are React components.

Draw each step as a card of your own. Say which lines may connect. Then let a run light up the drawing, step by step.

A workflow builder made with Drawsmith. Six step cards are joined by lines, with a run log beside them.A workflow builder made with Drawsmith. Six step cards are joined by lines, with a run log beside them.
A workflow builder made on the same parts. A run has just finished here, and each card shows whether it was done, failed or skipped.

workflow.tsxReact

import { Canvas, EditorRoot } from '@drawsmith/react/edit'; export function Workflow({ workflow, steps, marks, card }: Parts) {  return (    <EditorRoot      defaultDoc={workflow}      shapes={steps}      marks={marks}      canConnect={({ to }) =>        to.port === 'in'          ? true          : { allowed: false, reason: 'A line ends at an input.' }      }    >      <Canvas renderNode={card} />    </EditorRoot>  );} // A run says what happens as marks:// marks.update({ charge: 'running', 'e-yes': 'passed' });

05Formats

Mermaid in. PlantUML in. draw.io in.

Bring the diagrams you already have. Each becomes one JSON document, and that document is yours to keep, change and draw.

checkout.mmdMermaid

1flowchart LR2  cart([Cart]) --> pay{Pay now?}3  pay -- Card --> take[Take the payment]4  pay -- Later --> inv[Send an invoice]5  take --> pack[Pack the order]6  inv --> pack7  pack --> ship([Ship it])

<Diagram source={text} />

FlowchartFlowchart, left to right, with 6 steps and 6 connections. Cart leads to Pay now? Pay now? leads to Take the payment (labelled “Card”) and Send an invoice (labelled “Later”). Take the payment leads to Pack the order. Send an invoice leads to Pack the order. Pack the order leads to Ship it.CardLaterCartPay now?Take the paymentSend an invoicePack the orderShip it

06Themes

Every colour is a variable.

Sizes, weights and corners sit in one theme object. Change it and the same drawing follows, in light and in dark.

clay.tsTypeScript

import { createTheme } from '@drawsmith/core/svg'; export const clay = createTheme({  node: { color: 'amber', fontWeight: 600, radii: { rect: 3, round: 8 } },  edge: { strokeWidth: 2 },  light: {    background: '#fbf5ef',    ink: '#3a2417',    edge: '#8a5a3c',    palette: { amber: '#b5522b' },  },}); // <Diagram doc={doc} theme={clay} />
FlowchartFlowchart, top to bottom, with 6 steps and 6 connections. Cart leads to Pay now? Pay now? leads to Take the payment (labelled “Card”) and Send an invoice (labelled “Later”). Take the payment leads to Pack the order. Send an invoice leads to Pack the order. Pack the order leads to Ship it.CardLaterCartPay now?Take the paymentSend an invoicePack the orderShip it
GalleyThe design system’s light mode.
FlowchartFlowchart, top to bottom, with 6 steps and 6 connections. Cart leads to Pay now? Pay now? leads to Take the payment (labelled “Card”) and Send an invoice (labelled “Later”). Take the payment leads to Pack the order. Send an invoice leads to Pack the order. Pack the order leads to Ship it.CardLaterCartPay now?Take the paymentSend an invoicePack the orderShip it
LampblackIts dark mode.
FlowchartFlowchart, top to bottom, with 6 steps and 6 connections. Cart leads to Pay now? Pay now? leads to Take the payment (labelled “Card”) and Send an invoice (labelled “Later”). Take the payment leads to Pack the order. Send an invoice leads to Pack the order. Pack the order leads to Ship it.CardLaterCartPay now?Take the paymentSend an invoicePack the orderShip it
BlueprintPale lines on deep blue.
FlowchartFlowchart, top to bottom, with 6 steps and 6 connections. Cart leads to Pay now? Pay now? leads to Take the payment (labelled “Card”) and Send an invoice (labelled “Later”). Take the payment leads to Pack the order. Send an invoice leads to Pack the order. Pack the order leads to Ship it.CardLaterCartPay now?Take the paymentSend an invoicePack the orderShip it
ClayA warm ground, heavier lines.

07Anywhere

No browser needed.

One function turns text into a string of SVG in Node, Bun, workers and build steps. The command line does the same for a folder of files. Arabic is measured in its own script and laid out from the right.

picture.tsNode, Bun, workers

import { writeFile } from 'node:fs/promises';import { renderDiagram } from '@drawsmith/core/render'; // No React. No DOM. One string of SVG.export async function picture(input: string) {  const result = await renderDiagram(input, { colors: 'page' });  if (result.status === 'ok') await writeFile('flow.svg', result.svg);}

TerminalCI

npx drawsmith render 'docs/**/*.mmd' --out docs/img --colors light,dark
FlowchartFlowchart, right to left, with 7 steps and 6 connections. طلب استرداد leads to هل الطلب موجود؟. هل الطلب موجود؟ leads to اطلب رقم الطلب (labelled “لا”) and خلال ٣٠ يومًا؟ (labelled “نعم”). خلال ٣٠ يومًا؟ leads to أعد المبلغ إلى البطاقة (labelled “نعم”) and حوّل إلى موظف (labelled “لا”). أعد المبلغ إلى البطاقة leads to أرسل الإيصال.لانعمنعملاطلب استردادهل الطلبموجود؟اطلب رقم الطلبخلال ٣٠ يومًا؟أعد المبلغ إلى البطاقةحوّل إلى موظفأرسل الإيصال

Drawn by the command line when this page was built.

Watch it move.

Under a minute of the engine, the viewer, the editor and a workflow.

Muted until you turn the sound on

Drawsmith

Coming soon.

Draws
Flowcharts, sequence, class, entity and state diagrams, mind maps, org charts and more
Reads
Its own JSON document, Mermaid, PlantUML and draw.io
Gives back
SVG in the page or as a string, PNG, its JSON document and Mermaid
Scripts
Latin and Arabic, left to right and right to left
Licence
Open source, MIT