Skip to main content

<ExportControlsComponent/>

Provides a set of buttons allowing your users to export a given canvas as SVG, PNG or JPG.

info

This component only works when your surface is using a ShapeLibrary to render elements, or if you are using a Diagram.

Usage​

This component is context aware and will discover the Surface to attach itself to if it is either a child element of a SurfaceComponent. Alternatively you can wrap your surface and controls inside a SurfaceProvider. In the code below we've shown the controls as a child of the surface.

info

The SVG/image exporter will only work if you're using a shape library in your app to render your nodes as SVG.


<script>
import {SurfaceComponent, ExportControlsComponent} from "@visuallyjs/browser-ui-svelte"
import {FLOWCHART_SHAPES} from "@visuallyjs/browser-ui";

const renderOptions = {
shapes: {
sets: [FLOWCHART_SHAPES]
}
}
const viewOptions = {...}
</script>

<SurfaceComponent renderOptions={renderOptions} viewOptions={viewOptions}>
<ExportControlsComponent/>
</SurfaceComponent>

Props​

ExportControlsComponentProps
NameTypeDescription
allowJpgExport?booleanDefaults to true.
allowPngExport?booleanDefaults to true.
allowSvgExport?booleanDefaults to true.
className?stringOptional class name to set on the element.
imageOptions?ImageExportUIOptionsOptions for image exports.
label?stringWhat to show in the label, if visible. Defaults to "Export:".
showLabel?booleanWhether or not to show a label in front of the buttons. Defaults to true.
svgOptions?SvgExportUIOptionsOptions for SVG exports.