Color

ReferenceSchema API

s.color()

A colour, picked with a colour picker and stored as a CSS colour string.

Use it for

  • Backgrounds and accents editors control
  • Brand colours kept as content

Reference

s.color(options?)

schema

A colour, picked with a colour picker. It is stored as a CSS colour string, so you can put it straight into a style attribute or a CSS custom property.

In Val Studio

Options

format"hsl" | "hex" | …

The notation it is stored in. Defaults to "hsl".

s.color({ format: "hex" })
alphaboolean

Allow transparency.

s.color({ alpha: true })

Example

A section background

TypeScript
const schema = s.object({
  background: s
    .color({ format: "hex" })
    .describe("Pick a dark colour: the text on it is white."),
});

// <section style={{ background: val.raw(section.background) }}>