Plugins
Tweakpane is enriched by a variety of first- and third-party component plugins.
To keep these close at hand and to ensure plugin compatibility with Tweakpane version 4, this library includes a number of popular plugins optimized for use in the Svelte Tweakpane UI style (while still allowing tree-shaking to keep the bundle size in check.)
Svelte Tweakpane UI takes a slightly different approach to plugins than the underlying vanilla JS Tweakpane API. Instead of explicitly npm
installing, importing, and then registering plugins on a Pane
object, Svelte Tweakpane UI manages plugin import and registration automatically the first time they’re used.
From the library user’s perspective, they’re regular components.
To keep bundle size down, it’s recommended to use per-component imports when you’re ready to go to production.
Many of the most popular Tweakpane plugins are already bundled with Svelte Tweakpane UI, and have been “wrapped” according to the conventions of the library. Plugins not currently bundled with the Svelte Tweakpane UI library will not work seamlessly unless they are explicitly wrapped.
Adding a component in vanilla Tweakpane involves grabbing the dependency:
Then importing, registering, and using the plugin:
The result should be the same:
The following plugins are included with Svelte Tweakpane UI, and are ready to use out of the box:
*Tweakpane version 4 is a relatively recent release, and it introduced a number of breaking changes for plugin developers. I’ve ported the asterisked plugins above from Tweakpane 3 to Tweakpane 4, and and submitted PRs to the project owners. As soon as the PRs are merged, I will update the dependencies in Svelte Tweakpane UI to point to the source instead of my fork.
Each of the included Tweakpane plugins has been forked to incorporate build process tweaks that dramatically reduce the final bundle size of projects using Svelte Tweakpane UI.
The forks will be kept in sync with the upstream version of the plugin, with minimal changes other than the build optimizations.
The optimization involves externalizing certain dependencies to prevent duplication and ensure that code can be shared effectively in the final build of a project.
Specifically, the Rollup configuration provided in the Tweakpane plugin template does not externalize @tweakpane/core
as a production dependency. Instead, it’s embedded into the single-file plugin artifact, which is what’s published to NPM and imported by plugin consumers.
Externalizing this dependency allows build to share a single instance of the @tweakpane/core
code across multiple plugins, which amounts to savings of about 75% (~780 K) in a SvelteKit project production build incorporating all available components.
For more on bundle size optimization, please see the section on importing components.
If you’d like to see additional Tweakpane plugins either integrated with Svelte Tweakpane UI or added to the list of candidates below, please open an issue or a pull request:
- tweakpane-plugin-thumbnail-list (forked from donmccurdy and ported to v4) v4
- tweakpane-plugin-infodump v3
- tweakpane-plugin-chromatic v3
- tweakpane-table v3
- tweakpane-plugin-search-list v3
- midi-control v3
- tweakpane-plugin-media v3
- tweakpane-plugin-audio-player v3
- tweakpane-plugin-grouplist v3
- tweakpane-media v3
- tweakpane-multiple-select-plugin v3
Note that some of the above plugins target Tweakpane v3, and will need to be updated to work with Tweakpane v4 before they can be integrated with Svelte Tweakpane UI.