July 18th, 2024

New in CSS: Relative Colors

The article discusses CSS's new relative color feature, resembling Sass functions. It allows flexible color manipulation by deconstructing values into components like rgb, hsl, or lch. Available in Safari Tech Preview, it enables easy color transformations.

Read original articleLink Icon
New in CSS: Relative Colors

The article discusses the introduction of relative colors in CSS, a feature reminiscent of Sass functionalities like darken or lighten. This new syntax allows for flexible color manipulations by using the 'from' keyword to deconstruct color values into their components like rgb, hsl, or lch. The article highlights that this feature is currently only available in Safari Tech Preview and requires toggling a development flag. Developers can now transform color values into different formats for easy manipulation, enabling tasks like darkening colors using calculations. The addition of relative colors showcases the responsiveness of CSS to developer requests for functionalities like lighten and darken. The article also provides examples of how relative colors can be used to create color palettes by defining color steps. Overall, the new relative color syntax in CSS offers a promising way to manipulate colors efficiently and creatively.

Link Icon 3 comments