dorkhub

use-tweaks

πŸŽ›οΈ Tweak React components with Tweakpane

tweakpane
TypeScriptβ˜… 787β‘‚ 24 forksMITupdated 4 years ago
visit the demogit clone https://github.com/tweakpane/use-tweaks.gittweakpane/use-tweaks

A screenshot of the library in use npm npm Discord Shield

Use Tweakpane in React apps

Try it here on Codesandbox

npm install tweakpane use-tweaks

Basic example

import { useTweaks } from "use-tweaks"

function MyComponent() {
  const { speed, factor } = useTweaks({
    speed: 1,
    factor: { value: 1, min: 10, max: 100 },
  });

  return (
    <div>
      {speed} * {factor}
    </div>
  );
}

Misc

Folders

You can add a top-level folder by passing the name as first argument of the hook:

import { useTweaks } from "use-tweaks"

const { speed, factor } = useTweaks("My title!", { speed: 1, factor: 1 })

You can also nest folders by using the makeFolder helper:

import { useTweaks, makeFolder } from "use-tweaks"

const { speed, factor } = useTweaks("My Title!", {
  speed: 1,
  ...makeFolder(
    "Advanced",
    {
      factor: 1,
    },
    false
  ), // pass false to make the folder collapsed by default
})

Buttons

Use the makeButton helper to create and add a button

import { useTweaks, makeButton } from "use-tweaks"

const { speed, factor } = useTweaks({
  speed: 1,
  factor: { value: 1, min: 10, max: 100 },
  ...makeButton("Log!", () => console.log("Hello World!"))
})

Separator

Use the makeSeparator helper to add a separator

import { useTweaks, makeSeparator } from "use-tweaks"

const { speed, factor } = useTweaks({
  speed: 1,
  ...makeSeparator(),
  factor: { value: 1, min: 10, max: 100 },
})

License

This project is open source and available under the MIT License

more like this

q5xjs

A small and fast alternative (experimental) implementation of p5.js

JavaScriptβ˜… 574

r2

Free open-source Cloudflare R2 desktop client and S3 GUI for macOS, Windows, and Linux. Manage Cloudflare R2, AWS S3, M…

TypeScriptβ˜… 50

search

search projects, people, and tags