You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to share an idea and ask a question regarding the future of CSS functions, especially in the context of relative colors, CSS types, and conditional logic (such as if()).
Idea: Contrast Text CSS Function
I'm interested in a native CSS function that would calculate a contrasting text color based on a given background color. Here is a conceptual example of how such a function might look if CSS functions supported variables, relative colors, and conditional logic:
Question
Will it be possible in the future CSS specification to define and use custom CSS properties (variables or constants) directly inside CSS functions, similar to the example above? Specifically, can we expect support for:
Declaring local variables within a function's scope
Using relative color syntax and CSS types within functions
Conditional logic (like if()) in CSS functions
I believe this would greatly enhance the expressiveness and power of CSS, especially for design systems and accessibility.
The text was updated successfully, but these errors were encountered:
Luko248
changed the title
[Proposal][css-2025]
[Proposal][css-2025] CSS if() and CSS custom properties nested inside CSS function
May 15, 2025
I think the only thing missing is a way to extract e.g. the l from a color as a percentage? Everything else you're asking for is either already possible, or coming soon.
I would like to share an idea and ask a question regarding the future of CSS functions, especially in the context of relative colors, CSS types, and conditional logic (such as if()).
Idea: Contrast Text CSS Function
I'm interested in a native CSS function that would calculate a contrasting text color based on a given background color. Here is a conceptual example of how such a function might look if CSS functions supported variables, relative colors, and conditional logic:
Question
Will it be possible in the future CSS specification to define and use custom CSS properties (variables or constants) directly inside CSS functions, similar to the example above? Specifically, can we expect support for:
I believe this would greatly enhance the expressiveness and power of CSS, especially for design systems and accessibility.
The text was updated successfully, but these errors were encountered: