How to Customize the Hand-Drawn Style of Elements in Excalidraw

You can customize Excalidraw's hand-drawn aesthetic by adjusting roughness (sloppiness), stroke style, fill style, and edge roundness via the AppState API or UI controls.

The excalidraw/excalidraw repository renders every shape with a sketchy, hand-drawn appearance powered by Rough.js. Whether you are embedding the canvas in a React application or building a custom UI, you can programmatically control this look by manipulating specific properties in the application state.

Understanding the Hand-Drawn Style Properties

Excalidraw exposes seven primary levers that control the visual style. These values are stored in AppState and default to the constants defined in DEFAULT_ELEMENT_PROPS located at packages/common/src/constants.ts.

Property Controls Default Implementation
Roughness (Sloppiness) Sketchiness level: 0 (Architect/precise), 1 (Artist), 2 (Cartoonist) 1 actionChangeSloppiness in packages/excalidraw/actions/actionProperties.tsx
Stroke Style Solid, dashed, or dotted outlines "solid" actionChangeStrokeStyle in packages/excalidraw/actions/actionProperties.tsx
Fill Style Hachure, cross-hatch, solid, or zigzag fill "hachure" actionChangeFillStyle in packages/excalidraw/actions/actionProperties.tsx
Edge Roundness Sharp corners vs. rounded corners "round" actionChangeRoundness in packages/excalidraw/actions/actionProperties.tsx
Stroke Width Thin, bold, or extra-bold lines 1 actionChangeStrokeWidth in packages/excalidraw/actions/actionProperties.tsx
Opacity Alpha transparency 1 (100%) actionChangeOpacity in packages/excalidraw/actions/actionProperties.tsx

The default AppState is initialized in packages/excalidraw/appState.ts via getDefaultAppState, which clones the values from DEFAULT_ELEMENT_PROPS.

Customizing Styles via the Excalidraw API

When embedding the <Excalidraw> component, you can customize the hand-drawn style either at initialization or dynamically at runtime.

Setting Initial Styles with initialData

Pass a pre-configured appState object through the initialData prop to lock the canvas into a specific aesthetic from the first render.

import Excalidraw from "@excalidraw/excalidraw";

function MyCanvas() {
  const initialAppState = {
    // Cartoonist style: maximum roughness
    currentItemRoughness: 2,
    currentItemStrokeStyle: "solid",
    currentItemFillStyle: "hachure",
    currentItemRoundness: "round",
  };

  return (
    <Excalidraw
      initialData={{ appState: initialAppState }}
      UIOptions={{ canvasActions: { changeStyle: false } }}
    />
  );
}

This approach is documented in the API reference at dev-docs/docs/@excalidraw/excalidraw/api/props/excalidraw-api.mdx.

Updating Styles at Runtime with updateScene

To switch styles programmatically after the canvas has mounted, use the updateScene method exposed via a React ref.

import { useRef } from "react";
import Excalidraw from "@excalidraw/excalidraw";

export default function Demo() {
  const excalidrawRef = useRef<any>(null);

  const setArchitectStyle = () => {
    excalidrawRef.current?.updateScene({
      appState: {
        currentItemRoughness: 0, // precise lines
        currentItemStrokeStyle: "solid",
        currentItemFillStyle: "solid",
        currentItemRoundness: "sharp",
      },
    });
  };

  const setCartoonistStyle = () => {
    excalidrawRef.current?.updateScene({
      appState: {
        currentItemRoughness: 2, // sketchy lines
        currentItemStrokeStyle: "dashed",
        currentItemFillStyle: "zigzag",
        currentItemRoundness: "round",
      },
    });
  };

  return (
    <>
      <button onClick={setArchitectStyle}>Architect Style</button>
      <button onClick={setCartoonistStyle}>Cartoonist Style</button>
      <Excalidraw ref={excalidrawRef} />
    </>
  );
}

The updateScene call delegates to the same action reducers—such as actionChangeSloppiness—that the toolbar buttons trigger internally.

How the Rendering Engine Applies These Values

Under the hood, Excalidraw delegates drawing to the @excalidraw/element package. The roughness value is passed directly to Rough.js in packages/element/src/shape.ts, which perturbs line coordinates to create the sketchy effect. Similarly, strokeStyle and fillStyle map to Rough.js pattern generators (hachure, zigzag, solid, etc.).

When you change any style property, the action reducer returns a new element list and updated AppState, triggering a re-render through React. The roundness descriptor is added to the element's style object before the path is generated, as seen in the shape generation logic around line 171 of packages/element/src/shape.ts.

Summary

Frequently Asked Questions

Can I make Excalidraw look completely precise like CAD software?

Yes. Set currentItemRoughness to 0 (Architect mode), currentItemStrokeStyle to "solid", and currentItemRoundness to "sharp". This combination disables line perturbation and corner rounding, producing geometrically perfect shapes.

How do I persist custom styles across sessions?

Serialize the appState object (which contains currentItemRoughness, currentItemFillStyle, etc.) to localStorage or your backend. When re-initializing the canvas, pass the saved state back into the initialData.appState prop. The appState.ts file defines the schema you need to preserve.

Can I customize the hand-drawn style for individual elements rather than globally?

Yes. While the AppState properties like currentItemRoughness act as defaults for new elements, each element object stores its own roughness, strokeStyle, fillStyle, and roundness values. You can mutate individual elements via the updateScene API or by directly modifying the scene elements array before rendering.

What file controls the default roughness values?

The default roughness and other style constants are defined in packages/common/src/constants.ts within the DEFAULT_ELEMENT_PROPS object. These values are then imported into packages/excalidraw/appState.ts by the getDefaultAppState function to populate the initial AppState.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →