Skip to content

[filters] Proposal: color-filter #2875

@grorg

Description

@grorg

color-filter is a new inherited property that modifies color values used when rendering. It's syntax is similar to the filter property, and defines a transform function that is applied to a color.

Example:

.foo {
  color: blue;
  color-filter: invert();
}

This would apply a channel invert to all the colors in properties matching .foo. In this case the text color would render as an orangey-yellow.

The set of filters available are the same as the current filter property, with the exclusion of those that move pixels (i.e. drop-shadow and blur).

Notes:

  • Efficient because it only applies to color values at rendering time.
  • Very convenient way to do a "dark mode" version of your site.
  • Applies to color values, including those in gradients.
  • Leaves images and emoji untouched.
  • No nasty side effects of filter
    • No new stacking context
    • Because it is inherited, descendants can change the value

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions