Skip to content

Panel ​

ewColorPickerPanel renders the 2D picking area. The horizontal axis is saturation, the vertical axis is value.

ItemValue
Package@ew-color-picker/panel
pluginNameewColorPickerPanel
applyOrderPost
Mount pointpanelContainer
Instancecore.plugins.ewColorPickerPanel

Options ​

OptionTypeDefaultDescription
hasPanelbooleantrueHide the 2D panel
ewColorPickerPanelbooleantrueLegacy switch: false disables the panel; pass other panel options at the top level
hueDirection'horizontal' | 'vertical''vertical'Affects width
alphaDirection'horizontal' | 'vertical''vertical'Affects width
autoPanelPositionbooleanfalseAuto placement
panelPlacementstring'bottom'See below
appendTostring | HTMLElementundefinedMount the panel container into an external container (e.g. document.body) to avoid overflow clipping
hasBoxbooleantrueAuto placement needs the Box trigger (reads its size)
alphabooleanderivedAffects default color format
disabledbooleanfalseBlocks dragging

panelPlacement ​

top-start top top-end left-start left left-end right-start right right-end bottom-start bottom bottom-end

Gap 5px; positions are adjusted to stay inside the viewport.

Width rules ​

HueAlphaWidth
verticalvertical285px
horizontalvertical (or vice versa)~302px
horizontalhorizontal320px

Height is 180px, injected as --panel-width / --panel-height.

Methods ​

MethodSignatureDescription
render() => voidRebuild DOM
updateCursorPosition(s, v) => voidMove cursor (0–100)
updateColor(s, v) => voidApply color via setColor()
updateHueBg(hue?) => voidUpdate base hue
calculateContainerSize() => voidMeasure container
handleAutoPosition() => voidApply placement
calculatePosition(position, align, boxW, boxH) => { left, top }Pure calculation
adjustForViewport(root, left, top) => { left, top }Viewport correction
destroy() => voidRemove

Properties: panel, cursor, whitePanel, blackPanel, panelWidth, panelHeight, isHueHorizontal, isAlphaHorizontal, isDragging.

Behaviour ​

ActionResult
ClickCursor jumps, color applies
DragThrottled to ~60fps
TouchSame as drag
External changeCursor and base hue sync

updateColor falls back to red when the current color is empty or contains NaN.

Emits change via core.setColor().

DOM ​

html
<div class="ew-color-picker-panel ew-color-picker-panel-dynamic-size"
     style="--panel-width:285px;--panel-height:180px">
  <div class="ew-color-picker-white-panel"></div>
  <div class="ew-color-picker-black-panel"></div>
  <div class="ew-color-picker-panel-cursor"></div>
</div>

Example ​

ts
const picker = new ewColorPicker({
  el: '#app',
  hueDirection: 'horizontal',
  alphaDirection: 'horizontal',
  autoPanelPosition: true,
  panelPlacement: 'bottom-start',
})

picker.plugins.ewColorPickerPanel.updateColor(20, 30)