# new Color(config)
Its a Custom Web Component. Do not use the constructor directly with the new keyword. Instead, use one of the 3 following methods:
Create the Web Component and call its init method:
const myColorField = document.createElement("a-color").init(config)
Or use the shorthand for it:
const myColorField = createColorField({
value: "#00aaee",
height: "32px"
})
myColorField.render()
myColorField.getValue() // #00aaee
myColorField.setValue("#ff0000")
myColorField.getValue() // #ff0000
Or directly declare the config inside a container component:
const myPanel = createPanel({
title: "My panel",
items: [
{
type: "color",
value: "#00aaee",
width: "32px"
height: "32px",
hideCode: true
}
]
})
myPanel.render()
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
config |
object
|
||
palette |
string
|
<optional> |
Use "default" to use the default HTML5 color palette, otherwise it will use KissJS custom palette. |
value |
string
|
<optional> |
Initial color value |
hideCode |
boolean
|
<optional> |
Set to true to hide the hexa color code |
display |
string
|
<optional> |
|
width |
number
|
string
|
<optional> |
A number (in pixels) or any valid CSS value |
minWidth |
*
|
<optional> |
A number (in pixels) or any valid CSS value |
labelWidth |
*
|
<optional> |
A number (in pixels) or any valid CSS value |
height |
*
|
<optional> |
A number (in pixels) or any valid CSS value |
fieldWidth |
*
|
<optional> |
A number (in pixels) or any valid CSS value |
fieldHeight |
*
|
<optional> |
A number (in pixels) or any valid CSS value |
colorWidth |
*
|
<optional> |
Color selector width |
colorHeight |
*
|
<optional> |
Color selector height |
padding |
string
|
<optional> |
|
margin |
string
|
<optional> |
|
border |
string
|
<optional> |
|
borderStyle |
string
|
<optional> |
|
borderWidth |
string
|
<optional> |
|
borderColor |
string
|
<optional> |
|
borderRadius |
string
|
<optional> |
|
boxShadow |
string
|
<optional> |
|
readOnly |
boolean
|
<optional> |
this
Generated markup
<a-color class="a-color">
<label class="field-label"></label>
<div class="field-color-container">
<div class="field-color-palette"></div>
<div class="field-color-input"></div>
</div>
</a-color
Methods
# setFieldWidth(width)
Set the color selector field width
Parameters:
Name | Type | Description |
---|---|---|
width |
*
|
this
# setLabelPosition(position)
Set label position
Parameters:
Name | Type | Description |
---|---|---|
position |
string
|
"left" (default) | "right" | "top" | "bottom" |
this
# setValue(color, rawUpdateopt)
Set the fieldl value
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
color |
string
|
Hex color like #aa00ee |
|
rawUpdate |
boolean
|
<optional> |
If true, it doesn't update the associated record and doesn't trigger "change" event |
this