0.0.11 • Published 3 years ago

@baldwinbarry/react-knob v0.0.11

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

@baldwinbarry/react-knob

Knob component built with React. Inspired by a codepen by Ed Hicks.

Installation

npm

npm install @baldwinbarry/react-knob --save

yarn

yarn add @baldwinbarry/react-knob 

Properties

PropertyDefaultDescription
valueCurrent knob value
onChangeFunction to call when value changes
minValue0Minimum knob value
maxValue255Maximum knob value
minLabelMinMinimum label
maxLabelMaxMaximum label
minMaxLabelstrueRender min/max labels
ticks28Number of ticks
keyStepPct10Percent increase/decrease for key events
classNameOverride styles
labelText to render below knob

Example

import React, { useState } from 'react'
import ReactKnob from '@baldwinbarry/react-knob'

const Example = () => {
    const [volume, setVolume] = useState(0)
    return (
        <ReactKnob value={volume} onChange={setVolume} />
    )
}

export default Example

Styling: Size

By default, the knob component renders inside a 200px square container. Control the size of the knob by overriding width and height rules on the knob-container class:

.my-knob {
  .knob-container {
    width: 150px;
    height: 150px;
  }
}

<ReactKnob className="my-knob" />

###Styling: Color Change knob colors by overriding CSS custom properties. Color values must be provided as comma-separated RGB values.

PropertyDefaultDescription
--color-knob-dial24, 24, 24Dial color
--color-knob-light168, 216, 248Color of active ticks and knob light
--color-knob-tick200, 200, 200Color of inactive ticks
--color-knob-label200, 200, 200Color of knob labels
.my-knob {
  __color-knob-light: 255, 0, 0;
}

<ReactKnob className="my-knob" />
0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago