Skip to content

Alpha ​

ewColorPickerAlpha adds an alpha slider (0–1). Registering it changes how the core normalizes colors:

  • Registered: hex defaultColor becomes rgba()
  • Not registered: rgba() defaultColor becomes hex
ItemValue
Package@ew-color-picker/alpha
pluginNameewColorPickerAlpha
applyOrderPost
Mount pointpanelContainer
Instancecore.plugins.ewColorPickerAlpha

Options ​

OptionTypeDefaultDescription
alphabooleantruefalse hides the slider
alphaDirection'horizontal' | 'vertical''vertical'Orientation
disabledbooleanfalseBlocks interaction

Methods ​

Method / propertySignatureDescription
enableAlpha(enable = true) => voidShow/hide
updateAlpha(alpha: number) => voidApply alpha (0–1) via setColor()
updateAlphaThumbPosition(alpha: number) => voidMove thumb only
hasAlphaboolean getter/setterRe-renders on change
alphaBar / alphaThumbHTMLElement | nullDOM
isHorizontalbooleanOrientation flag

updateAlpha also syncs ColorMode inputs when the current mode is not hex.

Behaviour ​

ActionResult
ClickAlpha computed from position (horizontal: right → left increases)
DragThrottled 16ms
External changeThumb syncs

Return early when no current color exists.

Events ​

ts
picker.on('change', (color) => console.log(color)) // rgba(...)

DOM ​

html
<div class="ew-color-picker-slider ew-alpha ew-color-picker-is-vertical">
  <div class="ew-color-picker-alpha-slider-wrapper">
    <div class="ew-color-picker-alpha-slider-bg"></div>
    <div class="ew-color-picker-alpha-slider-bar"></div>
  </div>
  <div class="ew-color-picker-alpha-slider-thumb"></div>
</div>

Example ​

ts
const picker = new ewColorPicker({
  el: '#app',
  defaultColor: 'rgba(99, 102, 241, 0.6)',
  alphaDirection: 'horizontal',
})

picker.plugins.ewColorPickerAlpha.updateAlpha(0.5)