An open API service indexing awesome lists of open source software.

https://github.com/eye-wave/svelte-knobs

Svelte component library for building customizable knob controls.
https://github.com/eye-wave/svelte-knobs

audio-production knobs svelte sveltekit ui-components

Last synced: 18 days ago
JSON representation

Svelte component library for building customizable knob controls.

Awesome Lists containing this project

README

        

# svelte-knobs

![Version](https://img.shields.io/npm/v/svelte-knobs)
![License](https://img.shields.io/badge/license-MIT-lightgrey)

`svelte-knobs` is a Svelte component library for building customizable knob controls.

Inspired by:

- [vital](https://vital.audio)
- [solid-knobs](https://github.com/tahti-studio/solid-knobs)
- [nih-plug](https://github.com/robbert-vdh/nih-plug)

[Web demo](https://eye-wave.github.io/svelte-knobs)

## Installation

Add the library to your project:

```bash
npm install [email protected]
```

## Usage

#### Basic Knob

```svelte

import { SvgKnob } from 'svelte-knobs';

let value = $state(0.0);

{value.toFixed(2)}
```

A basic knob control with parameter scaling.
```svelte

import { LinearParam, LogParam } from 'svelte-knobs/params';
import { SvgKnob } from 'svelte-knobs';

let value = $state(0.0);

const freqParam = new LogParam(20, 20_000, 10);
const linParam = new LinearParam(0, 100);

{freqParam.denormalize(value) | 0}hz

{linParam.denormalize(value) | 0}%
```

#### Snap Points

Set specific snap points and adjust snapping sensitivity using `snapThreshold`.

```svelte

import { SvgKnob } from 'svelte-knobs';

let value = $state(0.0);



{value.toFixed(2)}

```

#### Enum Parameter

Example usage of `EnumParam` for working with enumerated options.

```typescript
import { BoolParam, EnumParam } from 'svelte-knobs/params';
import { SvgKnob } from 'svelte-knobs';

let value = $state(0);

const fruitParam = new EnumParam(['🍍', '🍉', '🍌', '🍋', '🍇'] as const);
const filterTypeParam = new EnumParam([
'Low pass',
'High pass',
'Low shelf',
'High shelf',
'Bell',
'Notch',
'Allpass'
] as const);

const booleanParam = new BoolParam();
```

```svelte

{fruitParam.denormalize(value)}

{filterTypeParam.denormalize(value)}

{booleanParam.denormalize(value)}


```

#### Disabled Knob

Disable knob interactivity

```svelte

```

## License

MIT License