Cogent Core Docs

0%

Loading...

Static preview:

Colors

Colors can be specified in several different ways. Colors are used for styles, and can be represented with the color picker widget.

Color scheme

Colors should typically be specified using the color scheme, which automatically adapts to light/dark mode and is based on the theme color specified in the user settings or through core.AppColor. The color scheme is based on Material Design 3 and uses their HCT color format to ensure accessible color contrast.

Common scheme colors are explained below, with an interactive color scheme demo below that. You can also see the API documentation for an exhaustive list of all colors/matcolor.Scheme colors.

  • • Surface colors are relatively neutral colors often used for backgrounds and text
    • Surface is the basic background color
    • OnSurface is the color for text and other such things on top of backgrounds with Surface color
    • SurfaceContainer and other similar colors like SurfaceContainerHigh are for widgets that contrast some with the background, like text fields and dialogs
    • ◦ As for almost all scheme colors, there are On versions of SurfaceContainer colors, such as OnSurfaceContainer, which serves a similar purpose as OnSurface
  • • Accent colors are colorful colors used to convey something
    • ◦ All accent colors come with four versions:
      • Base for high-emphasis content
      • On for text/content on top of Base
      • Container for lower emphasis content
      • OnContainer for text/content on top of Container
    • ◦ The commonly used accents are:
      • Primary for important elements like filled buttons
      • Select for selected elements
      • Error for error indicators or delete buttons
      • Success for success indicators
      • Warn for warnings

Color scheme demo

Here is an interactive demo of all scheme colors. For example, try editing the first color below (primary base) and see the links on this page change to that color.

Primary

Base

Edit color

On

Edit color

Container

Edit color

On container

Edit color

Secondary

Base

Edit color

On

Edit color

Container

Edit color

On container

Edit color

Tertiary

Base

Edit color

On

Edit color

Container

Edit color

On container

Edit color

Select

Base

Edit color

On

Edit color

Container

Edit color

On container

Edit color

Error

Base

Edit color

On

Edit color

Container

Edit color

On container

Edit color

Success

Base

Edit color

On

Edit color

Container

Edit color

On container

Edit color

Warn

Base

Edit color

On

Edit color

Container

Edit color

On container

Edit color

Custom

Surface dim

Edit color

Surface

Edit color

Surface bright

Edit color

Surface container lowest

Edit color

Surface container low

Edit color

Surface container

Edit color

Surface container high

Edit color

Surface container highest

Edit color

Surface variant

Edit color

On surface

Edit color

On surface variant

Edit color

Inverse surface

Edit color

Inverse on surface

Edit color

Inverse primary

Edit color

Background

Edit color

On background

Edit color

Outline

Edit color

Outline variant

Edit color

Shadow

Edit color

Surface tint

Edit color

Scrim

Edit color

Named colors

You can also use named colors (see the list of named colors below):

Note that the color is wrapped in colors.Uniform. That is because all colors in Cogent Core are specified as images, which allows for easy use of gradients and background images. For the color scheme above, scheme colors are automatically converted to images, so you don’t need to use colors.Uniform. You can use colors.ToUniform to convert a scheme color back from an image to a color.

Named colors do not adjust to light/dark mode and user settings, so you should use the color scheme instead when possible. However, if you do need colors outside of the color scheme, you can use color normalization functions as explained below.

Color normalization

You can use color normalization functions to make your colors adapt to the color scheme, ensuring sufficient contrast. Each color normalization function corresponds to a color scheme accent color version as documented above: Base, On, Container, and OnContainer.

For example, to make a color suitable for a high emphasis filled button, you can use colors.ToBase:

Gradient

You can specify a color as a gradient:

You can make a radial gradient:

You can rotate a gradient:

Image

You can use any image as a color, including all those supported by the image widget:

List of named colors

Aliceblue

Antiquewhite

Aqua

Aquamarine

Azure

Beige

Bisque

Black

Blanchedalmond

Blue

Blueviolet

Brown

Burlywood

Cadetblue

Chartreuse

Chocolate

Coral

Cornflowerblue

Cornsilk

Crimson

Cyan

Darkblue

Darkcyan

Darkgoldenrod

Darkgray

Darkgreen

Darkgrey

Darkkhaki

Darkmagenta

Darkolivegreen

Darkorange

Darkorchid

Darkred

Darksalmon

Darkseagreen

Darkslateblue

Darkslategray

Darkslategrey

Darkturquoise

Darkviolet

Deeppink

Deepskyblue

Dimgray

Dimgrey

Dodgerblue

Firebrick

Floralwhite

Forestgreen

Fuchsia

Gainsboro

Ghostwhite

Gold

Goldenrod

Gray

Green

Greenyellow

Grey

Honeydew

Hotpink

Indianred

Indigo

Ivory

Khaki

Lavender

Lavenderblush

Lawngreen

Lemonchiffon

Lightblue

Lightcoral

Lightcyan

Lightgoldenrodyellow

Lightgray

Lightgreen

Lightgrey

Lightpink

Lightsalmon

Lightseagreen

Lightskyblue

Lightslategray

Lightslategrey

Lightsteelblue

Lightyellow

Lime

Limegreen

Linen

Magenta

Maroon

Mediumaquamarine

Mediumblue

Mediumorchid

Mediumpurple

Mediumseagreen

Mediumslateblue

Mediumspringgreen

Mediumturquoise

Mediumvioletred

Midnightblue

Mintcream

Mistyrose

Moccasin

Oldlace

Olive

Olivedrab

Orange

Orangered

Orchid

Palegoldenrod

Palegreen

Paleturquoise

Palevioletred

Papayawhip

Peachpuff

Peru

Pink

Plum

Powderblue

Purple

Rebeccapurple

Red

Rosybrown

Royalblue

Saddlebrown

Salmon

Sandybrown

Seagreen

Seashell

Sienna

Silver

Skyblue

Slateblue

Slategray

Slategrey

Snow

Springgreen

Steelblue

Tan

Teal

Thistle

Tomato

Turquoise

Violet

Wheat

White

Whitesmoke

Yellow

Yellowgreen

Transparent