Skip to content

Checkbox ​

@ew-color-picker/checkbox has two parts:

  1. Plugin ewColorPickerCheckbox — renders a checkbox in the bottom row when checkboxLabel is provided;
  2. Component Checkbox — a standalone controlled checkbox built on a native input for semantics and keyboard support, with a custom visual box.
ItemValue
Package@ew-color-picker/checkbox
pluginNameewColorPickerCheckbox
applyOrderPost
Mount pointpanelContainer → .ew-color-picker-bottom-row (renders only when checkboxLabel is set)
Access instancecore.plugins.ewColorPickerCheckbox

Additional styles required

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

Without it the checkbox has no visual.

Options ​

OptionTypeDefaultDescription
showCheckboxbooleantrueSet to false to hide the checkbox
checkboxLabelstringundefinedLabel text; nothing renders when empty
checkboxCheckedbooleanfalseInitial checked state
checkboxDisabledbooleanfalseDisable interaction
onCheckboxChange(checked: boolean) => void-Fired after the user toggles the checkbox
ts
import ewColorPicker from '@ew-color-picker/core'
import Checkbox from '@ew-color-picker/checkbox'

ewColorPicker.use(Checkbox)

new ewColorPicker({
  el: '#app',
  checkboxLabel: 'Repeating',
  checkboxChecked: true,
  onCheckboxChange: (checked) => console.log(checked),
})

Plugin methods ​

MethodSignatureDescription
createCheckbox(options) => CheckboxCreate a component instance
updateOptions() => voidRe-read options and re-render
run() => voidRender the checkbox when a label is present
destroy() => voidRemove the checkbox and release events

Checkbox component ​

ts
import { Checkbox } from '@ew-color-picker/checkbox'

Options ​

OptionTypeDefault
checkedbooleanfalse
labelstring''
disabledbooleanfalse
size'small' | 'default' | 'large''default'
prefixstring'ew-'
onChange(checked: boolean) => void-

Methods ​

MethodSignatureDescription
isChecked() => booleanCurrent checked state
setChecked(checked, triggerChange?) => voidSet state; pass false to skip onChange
setLabel(label) => voidReplace the label text
setDisabled(disabled) => voidToggle the disabled state
getElement() => HTMLLabelElementRoot node
destroy() => voidUnbind events and remove the node

Accessibility ​

The component keeps a native <input type="checkbox"> visually hidden inside a <label>, so clicking the box or the label toggles it and keyboard focus / Space work as expected. The native input drives the visual box through :checked and :focus-visible, while disabled states are mirrored with input.disabled and the ew-checkbox--disabled class.

DOM ​

html
<label class="ew-checkbox ew-checkbox--default ew-checkbox--checked">
  <input class="ew-checkbox__input" type="checkbox" checked />
  <span class="ew-checkbox__box">
    <svg class="ew-color-picker-icon ew-checkbox__check-icon">…</svg>
  </span>
  <span class="ew-checkbox__label">Repeating</span>
</label>