Tweak panels for numbers, colors, vectors and more.
Tweak UI lets you quickly build panels with input controls for JavaScript objects you change at runtime, e.g. the settings of a renderer, a camera or an animation.
- Builder: builds panels with controls and containers. Binds the controls to plain objects, signals or stores.
- Solid components: each control is a solid-js component. No virtual DOM. Use the components with JSX, or without a compiler.
- Isolated styles: a precompiled stylesheet with css variables for the theme. It does not change the styles of the application.
Install the library and its peer dependency solid-js:
npm install tweak-ui solid-jsImport the stylesheet:
import 'tweak-ui/style.css'The package is an ES module with type declarations.
Without a bundler, load the module from a CDN that resolves the dependencies, e.g. esm.sh:
<link rel="stylesheet" href="https://unpkg.com/tweak-ui@x.x.x/dist/style.css" />
<script type="module">
import { mount } from 'https://esm.sh/tweak-ui@x.x.x'
</script>Mount a panel into a host element:
import { mount } from 'tweak-ui'
const camera = { fov: 60, near: 0.1, far: 1000 }
const panel = mount('#tools', (ui) => {
ui.group('Camera', (ui) => {
ui.scalar(camera, 'fov', { min: 10, max: 120, range: true })
ui.scalar(camera, 'near', { step: 0.01 })
ui.scalar(camera, 'far', { step: 10 })
})
})
// call after code outside of the panel changed the camera
panel.redraw()Or use the components directly, with JSX:
const [fov, setFov] = createSignal(60)
<ScalarWidget label="FOV" value={fov()} onInput={setFov} min={10} max={120} />or without JSX, with the shorthand of a component:
uiScalarWidget({ label: 'FOV', value: fov, onInput: setFov, min: 10, max: 120 })pnpm install
pnpm dev # documentation with live examples
pnpm test # specs in a headless browser
pnpm build # library and documentation