Skip to content

Instantly share code, notes, and snippets.

@ManUtopiK
Created September 21, 2024 19:36
Show Gist options
  • Save ManUtopiK/23b90e86d8b1285cf5b178d2d65d1eac to your computer and use it in GitHub Desktop.
Save ManUtopiK/23b90e86d8b1285cf5b178d2d65d1eac to your computer and use it in GitHub Desktop.
unocss make variable
export const shades = [
50,
...Array.from({ length: 9 }).map((_, i) => (i + 1) * 100),
950,
];
export const makeVariable = ({ fallbackValue, name, shade, withVar }) => {
const variable = `--${name}-${shade}`;
const value = fallbackValue ? variable + ", " + fallbackValue : variable;
return withVar ? `var(${value})` : variable;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment