A themable colour field: the palette of your theme in a panel, and any hex typed by hand.
A brand colour
The value is a hex string. The panel offers the named colours of the active theme.
Used for buttons and links in your emails.
defbrand_colour()->None:withui.form_field(label="Brand colour",hint="Used for buttons and links in your emails.",classes="w-full max-w-xs"):ui.color_picker(value="#2f5fd0")
Calendar colours
clearable with a placeholder for “no colour”, and disabled for one the user cannot change.
Calendars
Set by the calendar owner.
defcalendar_colours()->None:withui.card(padding="md",classes="w-full max-w-md"),ui.vstack(gap="md"):ui.heading("Calendars",level=3,size="md")withui.grid(cols=2,gap="md"):withui.form_field(label="Work"):ui.color_picker(value="#0f766e",name="work")withui.form_field(label="Personal"):ui.color_picker(value="#c2410c",name="personal")withui.form_field(label="Holidays"):ui.color_picker(value="",placeholder="No colour",clearable=True,name="holidays")withui.form_field(label="Shared with me",hint="Set by the calendar owner."):ui.color_picker(value="#7c3aed",disabled=True,name="shared")
on_change sends the colour to Python, and the preview zone re-renders with it.
Needs design review#d97706
classLabelDraft(PageState):name:str=field(default="Needs design review")colour:str=field(default="#d97706")defupdate_label(draft:LabelDraft)->None:"""The new name or colour is already in ``draft``; the preview follows."""@refreshable(deps=[LabelDraft])deflabel_preview()->None:draft=LabelDraft()withui.hstack(gap="sm"):ui.icon("tag",size="lg",style=f"color: {draft.colour}")ui.text(draft.nameor"Untitled label",weight="medium")ui.text(draft.colour,color="muted",size="sm",classes="font-mono")deflabel_editor()->None:draft=LabelDraft()withui.card(padding="md",classes="w-full max-w-md"),ui.vstack(gap="md"):withui.grid(cols=2,gap="md"):withui.form_field(label="Label"):ui.input(value=draft.name,on_change=update_label)withui.form_field(label="Colour"):ui.color_picker(value=draft.colour,color="secondary",on_change=update_label)ui.divider()label_preview()