CSS <dashed-function> Data Type
The <dashed-function> data type is the name of a custom function followed by an opening parenthesis, such as --fluid-size(, used with @function.
Description
The <dashed-function> CSS data type represents the name of a custom function followed by an opening parenthesis, for example --fluid-size(. It is the token used both to define a function with the @function at-rule and to call it in a property value. Like a <dashed-ident>, the name must start with two dashes, which guarantees it can never clash with a built-in CSS function.
A call to a custom function looks just like a call to a built-in one: padding: --spacing(2);. The arguments are separated by commas and can be any valid CSS values, including custom properties and other function calls. The browser replaces the call with the value the function returns, using the element's own context, so the same function can produce different results on different elements.
Names are case-sensitive, so --Size() and --size() are different functions. If a dashed function is called but no matching @function rule exists, or the browser does not support custom functions, the declaration becomes invalid at computed-value time, so include a plain fallback declaration first.
Examples:
@function --negate(--value) {
result: calc(-1 * var(--value));
}
@function --spacing(--step <number>: 1) {
result: calc(var(--step) * 0.5rem);
}
.card {
padding: 1.5rem; /* fallback */
padding: --spacing(3); /* dashed function call */
margin-top: --negate(1rem);
}
Syntax
<dashed-function> = --<ident>(
Values
- <dashed-function>A function name that starts with two dashes, followed immediately by an opening parenthesis, for example --brand-color(. The name is case-sensitive and must match a function defined with @function.
Example
Browser Support
The following information will show you the current browser support for the CSS dashed-function data type. Hover over a browser icon to see the version that first introduced support for this CSS data type.
Desktop





Tablets & Mobile





