Static assets

Replace individual fonts and icons, or self-host all of them, with the assetUrls prop.

import { Tldraw, TldrawProps } from 'tldraw'
import 'tldraw/tldraw.css'

// [1]
const assetUrls: TldrawProps['assetUrls'] = {
	fonts: {
		tldraw_draw: '/ComicMono.woff',
	},
	icons: {
		'tool-arrow': '/custom-arrow-icon.svg',
	},
}

export default function StaticAssetsExample() {
	return (
		<div className="tldraw__editor">
			<Tldraw persistenceKey="static-assets" assetUrls={assetUrls} />
		</div>
	)
}

/*
[1]
By default the `Tldraw` component loads its fonts, icons, and translations from tldraw's
asset CDN. `assetUrls` overrides individual URLs; anything you don't list keeps its
default. Both relative and absolute URLs work.

Here the "draw" font and the arrow tool icon are replaced with files served from this
Vite project's public folder. Check your framework's docs for how it serves static files.

Define this object outside the component (or memoize it with `useMemo`). A fresh object
on every render would make `Tldraw` re-resolve its assets each time.
*/

The Tldraw component needs fonts, icons, and translations, which it fetches from tldraw's CDN by default. The assetUrls prop lets you point any of them at your own files, either to customize the look or to serve everything from your own origin. Entries you don't override keep their defaults.

This example swaps the "draw" font for Comic Mono and replaces the arrow tool's toolbar icon with a custom SVG. Select the draw font from the style panel and type some text, and look at the arrow tool in the toolbar, to see both in effect. To self-host every asset rather than a few, see the @tldraw/assets options in the installation docs.

Is this page helpful?
Prev
Persist to storage
Next
Custom records