ColorPicker

A color picker that displays a list of colors which the user can select by using mouse or keyboard.

Color picker
//<code-header>
fiddle.title = 'Color picker';
//</code-header>
new Button({
    appendTo  : targetElement,
    rendition : 'filled',
    text      : 'Show menu',
    menu      : {
        colorMenu : {
            type : 'colorpicker',
            colorSelected({ color }) {
                colorBox.style.color = color;
            }
        }
    }
});

const colorBox = DomHelper.createElement({
    parent : targetElement,
    class  : 'b-color-box',
    style  : {
        width             : '2em',
        height            : '2em',
        color             : '#fff',
        borderRadius      : '4px',
        marginInlineStart : '1em'
    }
});

new ColorPicker({
   appendTo : 'container',
   width    : '10em',
   colorSelected(...args) {
       console.log(...args);
   }
});

Configs

97

Common

listenersEvents

Other

Adds an option to set no background color

The colors property can be an array of string CSS colors or of objects with color and text properties from which the user can chose from.

Provide an array of string CSS colors:

new ColorMenu({
    colors : ['#00FFFF', '#F0FFFF', '#89CFF0', '#0000FF', '#7393B3']
});

The colors can also be named. To do that, put them in an object with a color and a text property, like:

new ColorMenu({
   colors : [
       { color : '#000000', text : 'Black'},
       { color : '#FF0000', text : 'Red'},
       { color : '#00FF00', text : 'Green'},
       { color : '#0000FF', text : 'Blue'},
       { color : '#FFFFFF', text : 'White'},
   ]
});

Default colors are:

Red
Pink
Magenta
Purple
Violet
Indigo
Blue
Light-blue
Cyan
Teal
Green
Light-green
Lime
Yellow
Amber
Orange
Deep-orange
Brown
Lighter-gray
Light-gray
Gray
Black
colorSelected: function

A callback function that will be called when the user selects a color in the picker.

ParameterTypeDescription
eventObject

Object containing event data

event.recordModel

The selected color's record instance

event.colorString

The string color value

Returns: void

The color items is displayed in a grid layout with 6 columns as default. Change this to another number to affect appearance.

columnWidget
itemsList
rtlRTL
spanWidget
storeList
titleList

Accessibility

ariaLabelWidget
keyMapKeyMap

CSS

clsWidget
colorWidget
htmlClsWidget
styleWidget
uiWidget

DOM

adoptWidget
appendToWidget
contentWidget
datasetWidget
htmlWidget
idWidget
tagWidget

Float & align

alignWidget
anchorWidget
centeredWidget
draggableWidget
floatingWidget
xWidget
yWidget

Layout

alignSelfWidget
dockWidget
flexWidget
heightWidget
hiddenWidget
marginWidget
maxHeightWidget
maxWidthWidget
minHeightWidget
minWidthWidget
textAlignWidget
weightWidget
widthWidget

Misc

dataFieldWidget
disabledWidget
localeClassLocalizable
localizableLocalizable
maskedWidget
ownerWidget
readOnlyWidget
refWidget
rippleWidget
tabWidget
tooltipWidget

Scrolling

Properties

81

Class hierarchy

isColorPicker: Boolean= truereadonly
Identifies an object as an instance of ColorPicker class, or subclass thereof.
isColorPicker: Boolean= truereadonlystatic
Identifies an object as an instance of ColorPicker class, or subclass thereof.
isDelayableDelayable
isEventsEvents
isKeyMapKeyMap
isListList
isLocalizableLocalizable
isWidgetWidget

Other

Adds an option to set no background color

The colors property can be an array of string CSS colors or of objects with color and text properties from which the user can chose from.

Provide an array of string CSS colors:

new ColorMenu({
    colors : ['#00FFFF', '#F0FFFF', '#89CFF0', '#0000FF', '#7393B3']
});

The colors can also be named. To do that, put them in an object with a color and a text property, like:

new ColorMenu({
   colors : [
       { color : '#000000', text : 'Black'},
       { color : '#FF0000', text : 'Red'},
       { color : '#00FF00', text : 'Green'},
       { color : '#0000FF', text : 'Blue'},
       { color : '#FFFFFF', text : 'White'},
   ]
});

Default colors are:

Red
Pink
Magenta
Purple
Violet
Indigo
Blue
Light-blue
Cyan
Teal
Green
Light-green
Lime
Yellow
Amber
Orange
Deep-orange
Brown
Lighter-gray
Light-gray
Gray
Black

The color items is displayed in a grid layout with 6 columns as default. Change this to another number to affect appearance.

$namestaticWidget
columnWidget
countList
itemsList
rtlRTL
spanWidget
storeList
titleList
typestaticWidget

Accessibility

keyMapKeyMap

CSS

clsWidget

DOM

appendToWidget
contentWidget
datasetWidget
elementWidget
htmlWidget
idWidget
styleWidget

Float & align

xWidget
yWidget

Layout

alignSelfWidget
flexWidget
heightWidget
marginWidget
maxHeightWidget
maxWidthWidget
minHeightWidget
minWidthWidget
widthWidget

Lifecycle

configBase

Misc

cellInfoWidget
disabledWidget
localeHelperLocalizable
localeManagerLocalizable
readOnlyWidget
refWidget
tabWidget
tooltipWidget

Visibility

hiddenWidget
isVisibleWidget

Widget hierarchy

ownerWidget
parentWidget

Functions

65

Configuration

applyDefaultsstaticBase

Events

Float & align

alignToWidget
setXYWidget
showByWidget
toFrontWidget

Lifecycle

createstaticWidget
destroystaticBase
initClassstaticWidget

Misc

attachTooltipstaticWidget
fromElementstaticWidget
fromSelectorstaticWidget
getByIdstaticWidget
isOfTypeNamestaticBase
mixinstaticBase
optionalLstaticLocalizable

Other

composeWidget
createOnFrameDelayable
disableWidget
enableWidget
focusWidget
LstaticLocalizable
maskWidget
onEvents
recomposeWidget
relayAllEvents
triggerEvents
unEvents
unmaskWidget

Selection

selectList

Visibility

hideWidget
showWidget

Widget hierarchy

closestWidget
containsWidget
ownsWidget
queryWidget
queryAllWidget
upWidget

Events

19

Event handlers

19

Typedefs

7

Describes a color in the color picker.

ParameterTypeDescription
colorString

The color value

textString

The text to display for the color

AlignSpecWidget
ColorWidget

CSS variables

47
NameDescription
--b-color-picker-color-border-radiusBorder radius for color swatches
--b-color-picker-color-sizeSize of color swatches
--b-color-picker-gapGap between swatches
--b-color-picker-paddingColor picker padding
--b-color-picker-color-no-color-colorColor used for no color
--b-color-picker-columnsNumber of columns in the picker layout (overridden for combo pickers)
Focused
--b-color-picker-color-active-outlineOutline for currently active/focused (when navigating using keyboard) color swatch
Hovered
--b-color-picker-color-hover-outlineOutline for hovered & selected color swatches
--b-color-picker-color-outline-offsetOutline offset for hovered & selected color swatches

Inherited