ex-excalidraw
v0.18.3
Published
Excalidraw as a React component
Maintainers
Readme
Excalidraw
Excalidraw is exported as a component to be directly embedded in your project.
Installation
Use npm or yarn to install the package.
npm install react react-dom ex-excalidraw
# or
yarn add react react-dom ex-excalidrawNote: If you don't want to wait for the next stable release and try out the unreleased changes, use
ex-excalidraw@next.
Self-hosting fonts
By default, Excalidraw will try to download all the used fonts from the CDN.
For self-hosting purposes, you'll have to copy the content of the folder node_modules/ex-excalidraw/dist/prod/fonts to the path where your assets should be served from (i.e. public/ directory in your project). In that case, you should also set window.EXCALIDRAW_ASSET_PATH to the very same path, i.e. / in case it's in the root:
<script>window.EXCALIDRAW_ASSET_PATH = "/";</script>Dimensions of Excalidraw
Excalidraw takes 100% of width and height of the containing block so make sure the container in which you render Excalidraw has non zero dimensions.
Demo
Go to CodeSandbox example.
Customization
The component now exposes additional props so host applications can fully control the surrounding UI and network integrations:
brandinglets you disable the bundled Excalidraw branding or provide your own replacements for the welcome screen logo and the default main menu section.remoteConfigcentralises all remote endpoints (library browser URLs, publish backend, documentation links, and the font CDN fallback) so they can point to your self-hosted infrastructure.renderTopToolbar,renderBottomToolbar,renderMainMenu, andrenderMainMenuItemsallow you to extend or replace the default toolbars and menu content on both desktop and mobile layouts.toolbartoggles individual controls within the default toolbars (desktop and mobile) and lets you prepend or append custom UI without reimplementing the layout.mainMenucontrols the built-in menu entries so you can hide the stock actions or inject your own items around the defaults.<Excalidraw toolbar={{ top: { items: { penModeButton: false }, append: <MyCustomToolbarButton />, }, }} mainMenu={{ items: { loadScene: false, links: false }, append: <MainMenu.Item onSelect={handleAbout}>About</MainMenu.Item>, }} />onTelemetryEventexposes the internal action logging so you can wire it to your own analytics pipeline while keeping telemetry disabled by default.
See the API docs for detailed typings and usage examples.
Integration
Head over to the docs.
API
Head over to the docs.
Contributing
Head over to the docs.
