Features
A handful of additional features have been implemented in the Svelte layer of the project.
With a single prop, you can make a <Pane>
draggable and resizable. Position and size are persisted in local storage. (This is the default behavior for <Pane>
components.)
What a time to be alive.
Pains were taken during development of this feature to ensure that draggable components behave appropriately on touch devices. Itโs true that Tweakpaneโs hit-zones are decidedly โmouse-firstโ, but the scale
property on <Pane>
can be used to make things more touch-friendly.
You can make a <Pane>
appear inline with the rest of your content. (This is the default for standalone components.)
In several places, additional value types are transparently supported.
Throughout the library, almost anything that takes an object will now also tolerate a tuple, and vice versa.
For example, <Point>
can be used with a tuple, and <CubicBezier>
can be used with an object.
This is particularly useful for interoperability with tuple-loving libraries like Three.js / Threlte.
Tweakpane is nearly bitmap-free, so it scales up very nicely. Svelte Tweakpane UI adds a scale
prop to <Pane>
s to allow you to scale your panes to any size you like.
Svelte Tweakpane UI manages applying and overriding CSS variables at the right points in the dom to allow multiple panes to be styled independently on a single page.
A setGlobalDefaultTheme()
helper function makes it easy to define a default theme for all panes on a page. (While still allowing individual panes to override the global default.)
Sometimes you want to embed an arbitrary chunk of HTML in one of your panes. The <Element>
component simplifies this.
<Text>
and <Textarea>
components update their bound values every keystroke, not just on blur. (Though the old behavior remains is available via a prop.)
Wrapping Tweakpane components in <Pane>
components is optional. If you donโt wrap a component in a <Pane>
, it will be automatically wrapped in an implicit inline <Pane>
with default settings.
Very, very, early and experimental support around SSR pre-rendering of pane width and height only. This is not true SSR, just some calculations to minimize CLS after hydration.
Folders and inline pickers inside a draggable <Pane>
can be set to automatically collapse if the screen is short on vertical space via the collapseChildrenToFit
prop.
If you want to prevent the user from collapsing chunk of pane, you can set the userExpandable
prop to false
. The section will remain programmatically collapsible via the expanded
property.
Pane titles and blade labels are truncated with ellipses if theyโre too long to fit in their containers.
Though binding to a componentโs value
is generally the best way to react to changes, sometimes you need to know how a valueโs change originated.
To this end, all value-manipulating components provide a change
event that includes the โoriginโ of the change in the event.details
payload.
Changes resulting from the userโs direct manipulation of the control are marked as internal
, while those resulting from a change to the bound value from outside the component are marked as external
.
The example below tallies internal
vs. external
changes to the <Slider>
:
See example code
Hiroki Kokubunโs CameraKit plugin includes a wide
option on its<Ring>
and <Wheel>
controls to optionally hide the numeric input text field.
This came up in an issue, and is also a nice idea in general, so support has been added to the <Slider>
and <IntervalSlider>
components in Svelte Tweakpane UI:
See example code
Certain aspects of the Tweakpane API donโt make a ton of sense in the Svelte context, and have been removed or hidden from the API.
The container
PaneConfig option is not exposed, because correct placement in the containing DOM is managed by Svelte Tweakpane UI, and <Pane position="inline" ...>
may be used where youโd like a pane to become part of the normal document flow.
The hidden
/ visibility accessor is not exposed, because visibility a pane and its components may be managed directly in Svelte by adding / removing elements from the Svelte component markup through {#if}
conditionals and similar.
index is not exposed. The order of controls appearance matches their position in the Svelte component markup.
Svelte Tweakpane UI full manages the lifecycle of the underlying Tweakpane objects, obviating the need for manual calls to dispose.
Abstractions around importState()
and exportState()
are not yet implemented. For now, Svelte provides many ways to load and persist values (stores, etc.).
A curation of first- and third-party Tweakpane Plugins have been wrapped in components and bundled with Svelte Tweakpane UI. These plugins are automatically registered on demand, and work just like other components.
The vanilla Tweakpane Tab
is referred to as a <TabGroup>
in Svelte Tweakpane UI, and the vanilla Tweakpane Page
is referred to as a <TabPage>
.
The Vanilla Tweakpane API organizes control configuration into Params
interfaces and objects. Svelte Tweakpane UI pushes these values up into top-level props on each component.