Is Named CSS Colour
Added in: @sardine/colour@2.4.0
Description
Determines whether a string represents a valid named CSS colour.
Signature
function isNamedCSSColour(colour: string): boolean;
Parameters
colour:string— The string to test (e.g.,"red","navy").
Returns
boolean—trueif the string represents a valid named CSS colour,falseotherwise.
Examples
import { isNamedCSSColour } from "@sardine/colour";
isNamedCSSColour("red");
// => true
isNamedCSSColour("navy");
// => true
isNamedCSSColour("notacolour");
// => false
Error Handling
- Returns
falsefor any string that is not a valid named CSS colour.
Interactive Demo
Try the function yourself with our interactive playground: