@function
An experimental at-rule that lets you define your own custom CSS functions with logic and return values, very similar to functions in programming languages like JavaScript.
This is an experimental technology. The syntax and behavior are still subject to change.
Syntax
/* Usage Example */
@function --get-vibrant-bg(--color-base) {
/* Experimental: logic to generate a color variant */
result: color-mix(in srgb, var(--color-base), #fff 20%);
}
.card{
background: --get-vibrant-bg(#3b82f6);
}
@function Browser support
Limited availability
Since
2020 67% global usage
This feature is not Baseline because it does not work in some of the most widely-used browsers.
139+
139+