ColorSchema
constColorSchema:ZodEffects<ZodString,string,string>
Defined in: packages/core/src/schemas/base.schema.ts:147
CSS color value.
Remarks
Section titled “Remarks”Supports multiple color formats:
- Hex:
#rgb,#rrggbb,#rrggbbaa - RGB:
rgb(255, 0, 0) - RGBA:
rgba(255, 0, 0, 0.5) - HSL:
hsl(0, 100%, 50%) - HSLA:
hsla(0, 100%, 50%, 0.5) - Named:
red,blue,transparent, etc.
Examples
Section titled “Examples”YAML
paint: circle-color: "#ff0000" fill-color: "rgba(255, 0, 0, 0.5)" line-color: "hsl(120, 100%, 50%)" text-color: "blue"TypeScript
const hex = ColorSchema.parse("#ff0000");const rgba = ColorSchema.parse("rgba(255, 0, 0, 0.5)");const named = ColorSchema.parse("red");