
Security News
PodRocket Podcast: Inside the Recent npm Supply Chain Attacks
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
@magnesium/theme
Advanced tools
The Magnesium Sass Framework helps you easily develop your Web Design System.
npm install @magnesium/theme
The theme component help you to easily manage theme styles with generate CSS custom properties declarations from user-provided theme's tokens map.
Option | Description |
---|---|
$prefix | Add global prefix name on any custom properties. Default mg . Set to false for disable. |
@use "@magnesium/theme" with (
$prefix: "foo" // Set to `false` for disabled.
);
emit-custom-props($tokens, $prefix)
Emits CSS custom properties declarations from a user-provided theme's.
@use "@magnesium/theme";
$tokens: (
"text-color": darkcyan
);
.foo {
@include theme.emit-custom-props($tokens, "button");
}
.foo {
--mg-button-text-color: darkcyan;
}
emit-variable($tokens, $token, $fallback, $prefix)
Emits CSS variable declaration from a user-provided theme's.
@use "@magnesium/theme";
$tokens: (
"text-color": darkcyan
);
.foo {
color: theme.emit-variable($tokens, "text-color", false, "button");
}
.foo {
color: var(--mg-button-text-color);
}
validation($reference, $tokens)
Validates a user-provided theme's token and throws an error if tokens are invalid.
@use "@magnesium/theme";
$reference: (
"text-color": darkcyan
);
$tokens: (
"text-color": darkorange
);
$tokens: theme.validation($reference, $tokens); // Return `$tokens` map if true or error if false.
If variables are already configured on top-level using @use ... with
, by another dependency for example, you can't use
this solution anymore, because the module can only be setup once, this is a Sass restriction with Module System, but
another solution exist for override the main configuration, with a mixin!
See official documentation about override configuration with mixins.
Mixin | Description |
---|---|
config($prefix) | Override top-level prefix configuration. |
theme.config()
The following Sass will configure new parameters:
@use "@magnesium/theme";
@include theme.config("fr");
FAQs
The Sass Framework for Web Design System.
We found that @magnesium/theme 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
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.