Socket
Socket
Sign inDemoInstall

style-inject

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

style-inject

Inject style tag to document head.


Version published
Weekly downloads
755K
increased by6.4%
Maintainers
2
Weekly downloads
 
Created

What is style-inject?

The 'style-inject' npm package is a utility for injecting CSS styles into the DOM. It is particularly useful for dynamically adding styles to a web page without needing to modify the HTML or CSS files directly. This can be useful in various scenarios, such as theming, dynamic styling, or when working with component-based frameworks.

What are style-inject's main functionalities?

Injecting CSS Styles

This feature allows you to inject a string of CSS styles directly into the DOM. The provided code sample demonstrates how to change the background color of the body to blue.

const styleInject = require('style-inject');
const css = 'body { background-color: blue; }';
styleInject(css);

Injecting CSS with Options

This feature allows you to inject CSS styles with additional options. In this example, the CSS is inserted at the top of the head element, which can be useful for ensuring that the styles take precedence over others.

const styleInject = require('style-inject');
const css = 'body { background-color: red; }';
const options = { insertAt: 'top' };
styleInject(css, options);

Other packages similar to style-inject

Keywords

FAQs

Package last updated on 31 Jan 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