Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@microsoft/load-themed-styles

Package Overview
Dependencies
Maintainers
2
Versions
652
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.

  • 1.7.44
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
181K
decreased by-10.63%
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 22 Mar 2018

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc