Pane
The root <Pane> component, used for organizing controls into a single group and controlling how
and where the Tweakpane is displayed.
This component is a wrapper around Tweakpane's
Pane class.
Important: Unlike the vanilla JS Tweakpane API, wrapping components in a <Pane> is not mandatory.
Pane-less components will be automatically nested in a <Pane position="inline"> component and
displayed in the regular block flow of the page. <Pane> is only necessary when you want to
explicitly group a number of components, or when you want convenient means to control how and where
the Tweakpane is shown on the page. (See an important
exception
regarding Svelte Tweakpane UI in island frameworks like Astro.)
Multiple <Pane> components of different modes may be added to a single page. If the panes are in
fixed or draggable mode, you might want to set the x or y properties to prevent overlap.
Note that <Pane> is a dynamic component, and availability of additional props will vary depending
on the defined position value.
Position mode overview:
<Pane position="draggable" ...>
This is an extension of Tweakpane's core functionality, which reasonably considers pane dragging outside of the library's scope. See discussion in Tweakpane issues #88 and #301.
By default, the pane's last position and width will be saved to the browser's local storage and re-applied across page reloads. (Set thestorePositionLocallyprop to false to prevent this.)
If multiple<Pane position="draggable" ...>components are used on the same page withstorePositionLocallyset to true, then each must have a uniquelocalStoreIdprop set to avoid collisions.
Double-clicking the width drag handle will expand or contract the pane between to itsminWidthandmaxWidthsizes.<Pane position="inline" ...>
Provides an inline version of the pane component, allowing the Tweakpane window to appear in the normal flow of the document.
All other Svelte Tweakpane UI components which are created without a containing<Pane>are nested implicitly inside a title-less<Pane position="inline">component. As such, you do not necessarily need create<Pane position="inline">components in most cases.
This mode's behavior is similar to creating a Pane in the vanilla JS Tweakpane with itscontainerproperty set to a specific element where you want the Pane to appear.<Pane position="fixed" ...>
This mode uses the standard vanilla JS Tweakpane behavior of displaying in a fixed position over the top-right of the page.
Example
Section titled “Example”<script lang="ts"> import { Pane, type PanePosition, RadioGrid } from 'svelte-tweakpane-ui'
const options: PanePosition[] = ['inline', 'fixed', 'draggable'] let position: PanePosition = options[0]</script>
<Pane {position} title="Pane" y={position === 'inline' ? undefined : 110}> <RadioGrid bind:value={position} columns={1} label="Pane Position Prop" values={options} /></Pane>{#if position === 'fixed'} <p>Pane is fixed at the top-right of the page.</p>{:else if position === 'draggable'} <p>Pane is draggable at the top-right of the page.</p>{/if}
<style> p { display: grid; place-content: center; width: 100%; height: 96px; }</style>Dynamic Props
This component has dynamic props, which means the available props can change depending on the value or type of other props.
Props contingent on certain conditions are annotated below with a dynamic flag, and include explanations of the “conditions” affecting the prop’s availability. More Info →
positionSection titled “position” | |
| Description | Pane mode, one of three options:
|
|---|---|
| Type | 'draggable' | 'fixed' | 'inline' |
| Default | 'draggable' |
| bindableoptional | |
| Description | Width of the pane, in pixels. Width of the pane, in pixels. If undefined, the pane will fill the width of its container. (This behavior is unique to
This value is particularly important in combination with Setting explicitly via a passed prop will override saved user-specified width. Use this prop to set a starting width, or to monitor changes in the the pane's width when a user resizes it. Note that height is not exposed because it is determined dynamically by the pane's contents and state of its foldable elements. By default, the width value is saved to local storage for persistence across page loads. |
|---|---|
| Type | number |
| Default | 256 |
| optional | |
| Description | Text in the pane's title bar. |
|---|---|
| Type | string |
| Default | Tweakpane Unless position="inline", in which case the default is undefined and no title bar is
shown. |
userExpandableSection titled “userExpandable” | |
| Description | Allow users to interactively expand / contract the pane by clicking its title bar. Hides the collapse button from the title bar when |
|---|---|
| Type | boolean |
| Default | true |
expandedSection titled “expanded” | |
| Description | Expand or collapse the pane into its title bar. |
|---|---|
| Type | boolean |
| Default | true |
| optional | |
| Description | Custom color scheme. Applies to all child components, but note that setting a different Note that Simply pass a custom or default theme like See also the |
|---|---|
| Type | Theme |
| Default | undefined Inherits default Tweakpane theme equivalent to ThemeUtils.presets.standard, or the theme
set with setGlobalDefaultTheme(). |
| optional | |
| Description | Scales the pane's elements by a factor of Holds the width of the pane constant, so the pane will grow taller as it is scaled and will
continue to respect position- and size-related props. If you need more breathing room, set
the Note that the scaling prop is only available on Negative values are ignored. |
|---|---|
| Type | number |
| Default | 1 |
tpPaneSection titled “tpPane” | |
| Description | The internal Tweakpane This property is exposed for advanced use cases only. Direct manipulation of Tweakpane's internals can break Svelte Tweakpane UI abstractions. Note that the |
|---|---|
| Type | Pane |
collapseChildrenToFitSection titled “collapseChildrenToFit” | |
| Description | Automatically collapse open panels when the available window size is less than the height of the pane. |
|---|---|
| Type | boolean |
| Default | false |
| Conditions | Available when position="draggable". |
localStoreIdSection titled “localStoreId” | |
| Description | Identifier to be used if multiple |
|---|---|
| Type | string |
| Default | '1' |
| Conditions | Available when position="draggable". |
maxWidthSection titled “maxWidth” | |
| Description | Maximum pane width in pixels. |
|---|---|
| Type | number |
| Default | 600 |
| Conditions | Available when position="draggable". |
minWidthSection titled “minWidth” | |
| Description | Minimum pane width in pixels. |
|---|---|
| Type | number |
| Default | 200 |
| Conditions | Available when position="draggable". |
paddingSection titled “padding” | |
| Description | CSS padding property string to apply to the draggable pane container to prevent it from being dragged all the way to the edge of the window. Useful for keeping the pane away from of menu bars, etc. |
|---|---|
| Type | string |
| Default | '0' |
| Conditions | Available when position="draggable". |
resizableSection titled “resizable” | |
| Description | Allow the user to resize the width of the pane by dragging the right corner of the title bar. |
|---|---|
| Type | boolean |
| Default | true |
| Conditions | Available when position="draggable". |
storePositionLocallySection titled “storePositionLocally” | |
| Description | Store the pane's position and width when the user changes it interactively. Set the |
|---|---|
| Type | boolean |
| Default | true |
| Conditions | Available when position="draggable". |
| bindableoptionaldynamic | |
| Description | Horizontal position of the pane relative to the left edge of the window, in pixels. Not to be confused with the By default, this position is saved to local storage for persistence across page loads. |
|---|---|
| Type | number |
| Default | 0 |
| Conditions | Available when position="draggable" or position="fixed". |
| bindableoptionaldynamic | |
| Description | Vertical position of the pane relative to the top of the window, in pixels. Not to be confused with the By default, this position is saved to local storage for persistence across page loads. |
|---|---|
| Type | number |
| Default | 0 |
| Conditions | Available when position="draggable" or position="fixed". |
defaultSection titled “default” | |
| Description | Any Tweakpane component, except another |
|---|---|
| Type | {} |