An example of a default Color Picker without any extra properties.
from dash import Dash, html, Input, Output, callback
import dash_daq as daq
app = Dash(__name__)
app.layout = html.Div([
daq.ColorPicker(
id='my-color-picker-1',
label='Color Picker',
value=dict(hex='#119DFF')
),
html.Div(id='color-picker-output-1')
])
@callback(
Output('color-picker-output-1', 'children'),
Input('my-color-picker-1', 'value')
)
def update_output(value):
return f'The selected color is {value}.'
if __name__ == '__main__':
app.run(debug=True)
Set the size (width) of the color picker in pixels using the size
property.
import dash_daq as daq
daq.ColorPicker(
label="Small",
size=164,
)
Define the label and label position using the label
and labelPosition
properties.
import dash_daq as daq
daq.ColorPicker(
label="Label",
labelPosition="bottom"
)
To disable the Color Picker set disabled
to True
.
import dash_daq as daq
daq.ColorPicker(
label='Color Picker',
disabled=True,
)
Use hex values with the Color Picker by setting value=dict(hex='#<hex_color>')
import dash_daq as daq
daq.ColorPicker(
label='Color Picker',
value=dict(hex="#0000FF"),
)
Use RGB color values with the Color Picker by setting:
value=(rgb=dict(r=<r_value>, g=<g_value>, b=<b_value>, a=<a_value>))
import dash_daq as daq
daq.ColorPicker(
label='Color Picker',
value=dict(rgb=dict(r=255, g=0, b=0, a=0))
)
Access this documentation in your Python terminal with:
```pythonhelp(dash_daq.ColorPicker)
```
Our recommended IDE for writing Dash apps is Dash Enterprise’s
Data Science Workspaces,
which has typeahead support for Dash Component Properties.
Find out if your company is using
Dash Enterprise.
id
(string; optional):
The ID used to identify the color picker in Dash callbacks.
value
(dict; optional):
Color value of the picker.
value
is a dict with keys:
hex
(string; optional):
Hex string.
rbg
(dict; optional):
RGB/RGBA object.
rbg
is a dict with keys:
a
(number; optional)
b
(number; optional)
g
(number; optional)
r
(number; optional)
disabled
(boolean; optional):
If True, color cannot be picked.
size
(number; default 225
):
Size (width) of the component in pixels.
theme
(dict; default light
):
Theme configuration to be set by a ThemeProvider.
label
(dict; optional):
Description to be displayed alongside the control. To control styling,
pass an object with label and style properties.
label
is a string | dict with keys:
label
(string; optional)
style
(dict; optional)
labelPosition
(a value equal to: ‘top’ or ‘bottom’; default 'top'
):
Where the indicator label is positioned.
className
(string; optional):
Class to apply to the root component element.
style
(dict; optional):
Style to apply to the root component element.
persistence
(boolean | string | number; optional):
Used to allow user interactions in this component to be persisted when
the component - or the page - is refreshed. If persisted
is truthy
and hasn’t changed from its previous value, a value
that the user
has changed while using the app will keep that change, as long as the
new value
also matches what was given originally. Used in
conjunction with persistence_type
.
persisted_props
(list of values equal to: ‘value’; default ['value']
):
Properties whose user interactions will persist after refreshing the
component or the page. Since only value
is allowed this prop can
normally be ignored.
persistence_type
(a value equal to: ‘local’, ‘session’ or ‘memory’; default 'local'
):
Where persisted user changes will be stored: memory: only kept in
memory, reset on page refresh. local: window.localStorage, data is
kept after the browser quit. session: window.sessionStorage, data is
cleared once the browser quit.