
Security News
Scaling Socket from Zero to 10,000+ Organizations
Socket CEO Feross Aboukhadijeh shares lessons from scaling a developer security startup to 10,000+ organizations in this founder interview.
@onfido/castor-tokens
Advanced tools
This is Castor addition providing design tokens, including (CSS/Sass) themes.
Install package:
npm install @onfido/castor-tokens
Then add a theme by following either approach from examples below.
In order to use a theme with plain HTML + CSS, you must make the source available to public, and include it.
For example, if you serve your app from "public" directory, you can copy day.css and/or night.css files from node_modules/@onfido/castor-tokens/dist to public (or your root assets folder), then choose and include one theme in your HTML file from the following options:
<link rel="stylesheet" href="./day.css" />
<link rel="stylesheet" href="./night.css" />
@use Castor Tokens within your main Sass file:
@use '~@onfido/castor-tokens' as theme;
One time only, choose and include one theme within your root element from the following options:
:root {
// "day" theme
@include theme.day();
// OR "night" theme
@include theme.night();
}
Choose and import one theme from the following options in your root JS file:
import '@onfido/castor-tokens/dist/day.css';
import '@onfido/castor-tokens/dist/night.css';
To be able to switch between one and another, use "classed" themes when importing, and switch with the helper:
import { switchTheme } from '@onfido/castor-tokens';
// switch to "day" theme
import '@onfido/castor-tokens/dist/day-class.css';
switchTheme('day');
// OR to "night" theme
import '@onfido/castor-tokens/dist/night-class.css';
switchTheme('night');
You can also include class themes within your Sass file instead:
@use '~@onfido/castor-tokens' as theme;
@include theme.day('class');
@include theme.night('class');
These themes are not applied to the root element but instead theme variables are scoped to CSS classes, which are then applied to the body element.
If you're using CSS modules, you must use a global scope when including class themes. For example, for PostCSS:
:global {
@include theme.day('class');
@include theme.night('class');
}
You can also switch a theme on any selectable elements, for example switching on a section using the custom theme:
.castor-theme--custom {
// ...theme CSS variables
}
switchTheme('custom', document.querySelector('.section'));
If you do not use JavaScript, you might consider including a different CSS theme file based on URL parameter.
Lastly, if you're extremely concerned about efficiency, you can shave off 1-3 KBs by not including base tokens twice, if they're shared between the themes you're switching:
@use '~@onfido/castor-tokens' as castor;
:root {
@include castor.tokens();
}
@include castor.day('class', 'raw');
@include castor.night('class', 'raw');
FAQs
Design tokens for Castor.
The npm package @onfido/castor-tokens receives a total of 9,237 weekly downloads. As such, @onfido/castor-tokens popularity was classified as popular.
We found that @onfido/castor-tokens demonstrated a not healthy version release cadence and project activity because the last version was released 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 shares lessons from scaling a developer security startup to 10,000+ organizations in this founder interview.

Research
Socket Threat Research maps a rare inside look at OtterCookie’s npm-Vercel-GitHub chain, adding 197 malicious packages and evidence of North Korean operators.

Research
Socket researchers identified a malicious Chrome extension that manipulates Raydium swaps to inject an undisclosed SOL transfer, quietly routing fees to an attacker wallet.