Configuring the Colour Picker
Summary
- AdapTable provides its own Colour Picker component used when choosing colours for AdapTable Styles
- The Colour Picker contains 2 tabs:
- Custom - allows users to choose any colour via a picker
- Palette - offers active theme's palette (
--ab-color-palette-*) and its key theme colours
- Colour Picker is very configurable, including setting which colours are displayed in Palette tab
- Theme colours come from Customising Themes — tune palette slots in DevTools — Theme Builder or CSS
Topics on this Page
| Topic | Summary |
|---|---|
| Palette tab | Theme vs palette swatches |
| colourPickerOptions | Tabs, filter, ordering |
| Demos | Filter and restrict colours |
Find Out More
AdapTable provides its own Colour Picker component.
It's used when users need to select colours when creating an Adaptable Style (e.g. styling a Format Column).
Colour Picker Contents
The Colour Picker has 2 tabs:
| Tab | Contents |
|---|---|
| Palette | The colours of the active theme |
| Custom | Free colour picker (with opacity), hex field and (where supported by browser) an eyedropper |
Hint
- The tab last used is shared by every Colour Picker on the page, until the page reloads
- So a user who works from the palette does not have to switch to it in every picker
Palette Tab
The Palette tab displays a series of colours as swatches.
These colours come from 2 sources (both of which are CSS variables):
| Colour Set | Examples |
|---|---|
| Theme | var(--ab-color-accent), var(--ab-color-success) |
| Palette | --ab-color-palette-1 upwards, 32 by default |
Note
- By default the Palette colours are merged, and then ordered using the colour wheel, and duplicates are filtered out
- However all of this is configurable - see below
A colour picked from the Palette tab is stored as its CSS variable (e.g. var(--ab-color-palette-3)).
This means that it follows the light / dark theme and any override of that variable.
Theme Colours
By default the Colour Picker will show these 15 theme colours in the Palette tab:
| Colour | Label | Light Theme | Dark Theme |
|---|---|---|---|
--ab-color-accent | Accent | (#07c) | (#07c) |
--ab-color-success | Success | (#419641) | (#419641) |
--ab-color-info | Info | (#17a2b8) | (#17a2b8) |
--ab-color-warn | Warning | (#eb9316) | (#eb9316) |
--ab-color-destructive | Destructive | (#dc3545) | (#dc3545) |
--ab-color-destructive-foreground | Destructive text | (#ffffff) | (#ffffff) |
--ab-color-action-edit | Edit action | (#17a2b8) | (#17a2b8) |
--ab-color-action-share | Share action | (#eb9316) | (#eb9316) |
--ab-color-action-delete | Delete action | (#dc3545) | (#dc3545) |
--ab-color-action-clone | Clone action | (#419641) | (#419641) |
--ab-color-primary | Primary | (#e9e9e9) | (#262d2f) |
--ab-color-primary-foreground | Primary text | (#656565) | (#e2e2e2) |
--ab-color-background | Background | (#ffffff) | (#474c52) |
--ab-color-muted | Muted | (#f5f5f5) | (#3d3e3f) |
--ab-color-muted-foreground | Muted text | (#656565) | (#e2e2e2) |
Note
- Surface colours change between the
lightanddarkthemes; the others keep the same default in both - Muted follows
--ab-color-primarylight, and Muted text follows--ab-color-primary-foreground
Colour Palette Colours
The Colour Palette contains 32 colours - all defined in CSS Variables.
The first 12 palette colours are theme-aware slots for muted cell highlights:
| Colour | Typical Use | Light Theme | Dark Theme |
|---|---|---|---|
--ab-color-palette-1 | Error / breach highlight | (#fde8e8) | (#5c1a1a) |
--ab-color-palette-2 | Error / breach highlight | (#9b2c2c) | (#ffb4b4) |
--ab-color-palette-3 | Warning / pending highlight | (#fff8e1) | (#4a3b00) |
--ab-color-palette-4 | Warning / pending highlight | (#975a16) | (#ffd966) |
--ab-color-palette-5 | Success / booked highlight | (#e6f4ea) | (#1b4332) |
--ab-color-palette-6 | Success / booked highlight | (#276749) | (#95d5b2) |
--ab-color-palette-7 | Informational highlight | (#e6f2ff) | (#1a365d) |
--ab-color-palette-8 | Informational highlight | (#2b6cb0) | (#90cdf4) |
--ab-color-palette-9 | Neutral / inactive highlight | (#edf2f7) | (#2d3748) |
--ab-color-palette-10 | Neutral / inactive highlight | (#4a5568) | (#e2e8f0) |
--ab-color-palette-11 | Accent / stage highlight | (#f3e8ff) | (#44337a) |
--ab-color-palette-12 | Accent / stage highlight | (#553c9a) | (#d6bcfa) |
Note
- These can be categorised into 6 pairs with background and matching foreground
- They are used for error, warn, success, info, neutral, and accent respectively
The next 20 Colour Palette colours are plain, the same in light and dark themes:
| Variable | Default | Variable | Default |
|---|---|---|---|
--ab-color-palette-13 | (#000000) | --ab-color-palette-23 | (#00008B) |
--ab-color-palette-14 | (#FFFFFF) | --ab-color-palette-24 | (#0000FF) |
--ab-color-palette-15 | (#D3D3D3) | --ab-color-palette-25 | (#87CEFA) |
--ab-color-palette-16 | (#808080) | --ab-color-palette-26 | (#00FFFF) |
--ab-color-palette-17 | (#A52A2A) | --ab-color-palette-27 | (#FF00FF) |
--ab-color-palette-18 | (#006400) | --ab-color-palette-28 | (#800080) |
--ab-color-palette-19 | (#008000) | --ab-color-palette-29 | (#8B0000) |
--ab-color-palette-20 | (#32CD32) | --ab-color-palette-30 | (#FF0000) |
--ab-color-palette-21 | (#FFFF00) | --ab-color-palette-31 | (#DC143C) |
--ab-color-palette-22 | (#FFFFE0) | --ab-color-palette-32 | (#FFA500) |
Note
- Palette variables only feed the Colour Picker
- The colours AdapTable applies on its own (e.g. Flashing Cells, Quick Search) have their own Module Colours
Find Out More
- Customising Themes shows how to override theme variables in CSS
- Referencing Themes shows how to use those variables in Format Columns and other Adaptable Styles
Customising Colour Picker
The Colour Picker is very configurable - options include:
- Setting Palette Colors — replace the palette colours, or add colours after
--ab-color-palette-32 - Configuring Tabs — choose the Custom and Palette tabs, and the order they appear
- Filtering Colours — choose which theme colours and palette colours the Palette tab shows
- Configuring Colour Palette Tab — order the colours, remove duplicates, display labels
Caution
- Most configuration is done using properties in the
colourPickerOptionsobject in User Interface Options - However setting the intitial colours is done in the Theme itself using CSS variables
Setting Palette Colors
You can customise the Palette by overriding CSS variables on the shipped light and/or dark themes.
For example, to replace the first seven palette colours in dark mode:
html.ab--theme-dark {
--ab-color-palette-1: #660033;
--ab-color-palette-2: #ccffff;
--ab-color-palette-3: #ffccff;
--ab-color-palette-4: #b2ff66;
--ab-color-palette-5: #ff3333;
--ab-color-palette-6: #ffffff;
--ab-color-palette-7: #0000ff;
}Hint
- The Colour Picker offers every palette colour from
--ab-color-palette-1upwards until one is not defined - So a theme can also add colours after
--ab-color-palette-32if required
You can also override the theme colours the same way — see Customising Themes and Referencing Themes.
styles.cssreplaces the first 7 palette colours on the dark theme- It also defines
--ab-color-palette-33and--ab-color-palette-34, so the Colour Picker offers two colours after the default 32 - The grid uses the dark theme, and the Colour Picker shows the Palette tab
- Create a new Format Column; in the Style section click a colour to open the Colour Picker
- The replaced colours and the two added colours (deep pink and gold) are in the palette
Managing Tabs
AdapTable allows you to set which tabs the Colour Picker shows, and in which order.
This is done using the tabs property in colourPickerOptions section of User Interface Options.
tabs
Default: ['Custom', 'Palette']ColourPickerTab[]
Configuring Palette Tab
There are 3 properties available that allow you configure the look and feel of the Palette Tab
orderPaletteColours- orders the colours using a colour-wheel orderremoveDuplicates- ensures that each colour only appears onceshowGroupLabels- show Theme and Palette headings
Hint
There is also an option to set which colours are displayed - see below for details
orderPaletteColours
Default: truebooleanremoveDuplicates
Default: truebooleanshowGroupLabels
Default: falsebooleanorderPaletteColoursisfalse, so swatches stay in the order the theme lists themremoveDuplicatesisfalse, so colours that paint the same hex both appear (for example Info and Edit action)showGroupLabelsistrue, so the Palette tab shows Theme and Palette headings
- Create a new Format Column; in the Style section click a colour to open the Colour Picker
- Compare the Theme group with the default colour-wheel order, and note the repeated swatches
Filtering Colours
By default the 15 theme colours and all 32 colour palette variables are displayed in the Colour Palette tab.
However sometimes a developer might want to restrict which colours are displayed, or change the order.
This can be done using the filterColours property.
filterColours
(context: ColourPickerFilterContext) => ColourPickerFilterResult | void
filterColoursreturns no theme colours and only the first 7 palette colours- Anything else in the lists passed to the function is left out
- The Colour Picker shows the Palette tab
- Create a new Format Column; in the Style section click a colour to open the Colour Picker
- Only palette colours 1 to 7 are offered
FAQ
Palette vs Custom tab?
- Palette stores
var(--ab-color-…)so colours follow the active theme - Custom picks any colour (often stored as hex/rgba)
Picker vs theme CSS?
colourPickerOptionscontrols the picker UI- changing swatches users see still means overriding
--ab-color-palette-*in theme CSS