Skip to content

Instantly share code, notes, and snippets.

@vviikk
Last active November 13, 2018 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vviikk/0ca561b7cadfa6ea32d873552c14bd98 to your computer and use it in GitHub Desktop.
Save vviikk/0ca561b7cadfa6ea32d873552c14bd98 to your computer and use it in GitHub Desktop.
:element {
--[?specificity]-[context]-[?unit]--[?modifier]: 2rem;
/* Examples */
/* constants: */
--PADDING-REM: 1rem;
--COLOR-PRIMARY: palevioletred;
--COLOR-SECONDARY: papayawhip;
--COLOR-FOREGROUND: darkgray;
--COLOR-BACKGROUND: snow;
/* with modifier (--HOVER) */
--COLOR--HOVER: var(--COLOR-SECONDARY, silver);
}
button {
--button-color-background: var(--COLOR-FOREGROUND);
--button-color-foreground: var(--COLOR-BACKGROUND);
/* Dynamic variable with specificity, context and modifier */
--button-padding-rem--large: calc(var(--PADDING) / 2) calc(var(--PADDING));
/* have regular properties after the custom properties */
background-color: var(--button-color-background);
foreground: var(--button-color-background);
}
button:hover {
--button-color-background: var(--COLOR--HOVER);
}
button.default {
--button-color-background: var(--COLOR-SECONDARY);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment