Skip to content

InputNumber ​

@ew-color-picker/input-number ships two pieces:

  1. Plugin ewColorPickerInputNumber — creates a numeric input in the bottom row;
  2. Component InputNumber — a standalone controlled number input used by ColorMode for RGB/HSL channels.
ItemValue
Package@ew-color-picker/input-number
pluginNameewColorPickerInputNumber
applyOrderPost
Mount pointpanelContainer → .ew-color-picker-bottom-row
Instancecore.plugins.ewColorPickerInputNumber

Extra stylesheet required

ts
import '@ew-color-picker/style/dist/input-number.css'

Without it numeric inputs are unstyled.

Plugin options ​

OptionTypeDefaultDescription
disabledbooleanfalseDisable all managed inputs

Plugin methods ​

MethodSignatureDescription
createInputNumber(options) => InputNumberCreate a component
updateOptions() => voidReapply disabled
run() => voidCreate the default instance
destroy() => voidDestroy all instances

InputNumber component ​

ts
import { InputNumber } from '@ew-color-picker/input-number'

Options ​

OptionTypeDefault
valuenumber0
minnumber-Infinity
maxnumberInfinity
stepnumber1
precisionnumber0
disabledbooleanfalse
placeholderstring''
size'small' | 'default' | 'large''default'
onChange(value) => void—
onBlur(value) => void—
onFocus(event) => void—

onChange is debounced 300ms and is not called during construction.

Methods ​

MethodSignatureDescription
getValue() => numberRead value
setValue(value: number) => voidSet clamped value
setDisabled(disabled: boolean) => voidToggle disabled
getElement() => HTMLElementRoot element
destroy() => voidCleanup

Standalone example ​

ts
import { InputNumber } from '@ew-color-picker/input-number'
import '@ew-color-picker/style/dist/input-number.css'

const num = new InputNumber({
  value: 50,
  min: 0,
  max: 100,
  placeholder: 'Saturation',
  onChange: (v) => console.log(v),
})

document.body.appendChild(num.getElement())

DOM ​

html
<div class="ew-input-number ew-input-number--default">
  <input class="ew-input-number__input" type="text" inputmode="decimal" />
  <div class="ew-input-number__buttons">
    <button class="ew-input-number__button ew-input-number__button--up"></button>
    <button class="ew-input-number__button ew-input-number__button--down"></button>
  </div>
</div>