Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
@cobalt-ui/plugin-sass
Advanced tools
Generate Sass output for Cobalt from design tokens.
npm i -D @cobalt-ui/plugin-sass
// cobalt.config.mjs
import sass from '@cobalt-ui/plugin-sass';
export default {
plugins: [
sass({
/** set the filename inside outDir */
fileName: './index.scss',
/** use indented syntax? (.sass format) */
indentedSyntax: false,
/** modify values */
transformValue(value, token) {
return value;
},
/** rename variables */
transformVariables(namespaces) {
return namespaces.join('__');
},
}),
],
};
After Cobalt has built your Sass tokens, import it into any file with:
@use '../tokens' as *; // update '../tokens' to match your location of tokens/index.scss
.heading {
color: $color__blue;
font-size: $type__size__lg;
}
If some token variables conflict with local variables, you can always namespace them (Sass docs).
To use modes, use mode()
function that was generated with your tokens:
@use '../tokens' as *;
// "default" mode
.heading {
color: $color__blue;
font-size: $type__size__lg;
// "light" mode
body.theme--light & {
color: mode($color__blue, light);
font-size: mode($type__size__lg, light);
}
// "dark" mode
body.theme--dark & {
color: mode($color__blue, dark);
font-size: mode($type__size__lg, dark);
}
}
⚠️ Be warned that Sass will throw an error if that mode doesn’t exist for that token. This is done intentionally so that values aren’t silently falling back to their defaults.
To learn more about modes, see the documentation.
FAQs
Generate scss/sass from your design tokens schema (requires @cobalt-ui/cli)
We found that @cobalt-ui/plugin-sass demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.