You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

@microsoft/load-themed-styles

Package Overview
Dependencies
Maintainers
2
Versions
671
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@microsoft/load-themed-styles

Loads themed styles.

2.1.1
latest
Source
npm
Version published
Weekly downloads
233K
0.12%
Maintainers
2
Weekly downloads
 
Created

What is @microsoft/load-themed-styles?

@microsoft/load-themed-styles is a utility library for loading and applying CSS styles dynamically in a way that supports theming. It is particularly useful in scenarios where styles need to be adjusted based on a theme, such as in web applications that support multiple themes or dynamic style changes.

What are @microsoft/load-themed-styles's main functionalities?

Load Styles

This feature allows you to load CSS styles dynamically. The `loadStyles` function takes a string of CSS and injects it into the document's head.

const { loadStyles } = require('@microsoft/load-themed-styles');

loadStyles('.myClass { color: red; }');

Load Themed Styles

This feature allows you to load styles that are theme-aware. The `loadTheme` function sets the theme, and `loadStyles` can then use theme tokens to apply the correct styles based on the current theme.

const { loadTheme, loadStyles } = require('@microsoft/load-themed-styles');

const theme = {
  palette: {
    themePrimary: '#0078d4',
    themeSecondary: '#2b88d8'
  }
};

loadTheme(theme);
loadStyles('.myClass { color: [theme:themePrimary]; }');

Clear Styles

This feature allows you to clear all dynamically loaded styles. The `clearStyles` function removes all styles that were injected using `loadStyles`.

const { clearStyles } = require('@microsoft/load-themed-styles');

clearStyles();

Other packages similar to @microsoft/load-themed-styles

FAQs

Package last updated on 17 Apr 2025

Did you know?

Socket

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.

Install

Related posts