.md →
ColorPicker API#
ColorPicker wraps the browser's native color input and syncs the chosen #RRGGBB
value back to Python as color, with an rgb property that hands you the three channels
as integers. Reach for it when a plot color, a brush color or a mask tint is easier to
choose by eye than to type as a literal; show_label controls whether the hex string is
printed next to the swatch.
See also: Paint for a canvas with the same picker built into its toolbar, CopyToClipboard for handing the resulting hex string to someone else, and TangleSlider for the same by-eye approach to numbers.
Bases: AnyWidget
Simple color picker syncing a #RRGGBB hex value back to Python.
Examples:
import marimo as mo
from wigglystuff import ColorPicker
picker = mo.ui.anywidget(ColorPicker(color="#ff5733"))
picker
Create a ColorPicker widget.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
color
|
Optional[str]
|
Optional starting hex color (e.g. |
None
|
show_label
|
bool
|
Whether to show the hex label next to the picker. |
True
|
**kwargs
|
Any
|
Forwarded to |
{}
|
Source code in wigglystuff/color_picker.py
Synced traitlets#
| Traitlet | Type | Notes |
|---|---|---|
color |
str |
Hex color string (e.g., #ff00aa). |