@function
Limited availability70% of usersExperimental
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.
What's modern
From web-features, MDN's browser data and our snippets, checked dailyComingNot in Firefox or Safari yet, so not every major browser supports it.
The old way and the modern waySee the snippet: Reusable CSS logic without Sass mixins →
Old way 9 lines
// Sass / SCSS
@use "sass:math";
@function fluid($min, $max) {
@return clamp( /* [!code --] */
$min,
calc(#{$min} + #{math.div($max - $min, 1rem)} * ((100vw - 20rem) / 60)),
$max
);
}Modern 10 lines
@function --fluid( /* */
--min <length>, /* */
--max <length> /* */
) returns <length> {
result: clamp( /* [!code ++] */
var(--min), /* [!code ++] */
50vi, /* [!code ++] */
var(--max) /* [!code ++] */
);
}See how modern your own CSS is.Check your CSS →
Quick 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);
}Related snippet
Reusable CSS logic without Sass mixinsWorkflow →@function browser support
BaselineLimited availabilityThis feature is not Baseline because it does not work in some of the most widely-used browsers.Not ready for production without a fallback.
Usage70%of people can use this30% use a browser without it.
Browsers
139+
139+Mobile
139+Android
Interop 2027 candidate. Tracked for Interop 2027. Official focus areas publish early 2027; proposals are open through September 2026. See Interop 2027 →