SvgExportContext

See source code
Table of contents
interface SvgExportContext {}

Properties

isDarkMode

readonly

Whether the export should be in dark mode.

readonly isDarkMode: boolean

pixelRatio

readonly

Use this value to optionally downscale images in the export. If we're exporting directly to an SVG, this will usually be null, and you shouldn't downscale images. If the export is to a raster format like PNG, this will be the number of raster pixels in the resulting bitmap per CSS pixel in the resulting SVG.

readonly pixelRatio: null | number

scale

readonly

The scale of the export - how much CSS pixels will be scaled up/down by.

readonly scale: number

Methods

addExportDef

Add contents to the <defs> section of the export SVG. Each export def should have a unique key. If multiple defs come with the same key, only one will be added.

Parameters

NameDescription

def

Returns

void

resolveAssetUrl

Resolve an asset URL in the context of this export. Supply the asset ID and the width in shape-pixels it'll be displayed at, and this will resolve the asset according to the export options.

Parameters

NameDescription

assetId

width

number

Returns

Promise<null | string>

waitUntil

Cause the SVG export to be delayed until the returned promise is resolved. This is useful if e.g. your shape loads data dynamically, and you need to prevent the export from happening until after the data is loaded.

See also the useDelaySvgExport hook, which may be a more convenient way to use this method depending on your use-case.

Parameters

NameDescription

promise

Promise<void>

Returns

void

Prev
SnapData
Next
SvgExportDef
hi

We use cookies on this website.
Learn more in our Cookie Policy.