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

pixrem

Package Overview
Dependencies
Maintainers
3
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pixrem

A CSS post-processor that generates pixel fallbacks for rem units.

  • 5.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created

What is pixrem?

The pixrem npm package is a PostCSS plugin that converts pixel units to rem units in CSS. This is particularly useful for responsive web design, where rem units can provide more flexibility and scalability compared to fixed pixel units.

What are pixrem's main functionalities?

Convert px to rem

This feature converts pixel units to rem units in the provided CSS. The rootValue option specifies the root font size, which is used as the base for the conversion.

const postcss = require('postcss');
const pixrem = require('pixrem');

const css = 'body { font-size: 16px; }';
const options = { rootValue: 16 };

postcss([pixrem(options)])
  .process(css)
  .then(result => {
    console.log(result.css);
  });

Custom root value

This feature allows you to specify a custom root value for the conversion. In this example, the root value is set to 10, so 32px will be converted to 3.2rem.

const postcss = require('postcss');
const pixrem = require('pixrem');

const css = 'h1 { margin: 32px 0; }';
const options = { rootValue: 10 };

postcss([pixrem(options)])
  .process(css)
  .then(result => {
    console.log(result.css);
  });

Replace only specific properties

This feature allows you to replace only specific properties or at-rules. The options object can be configured to target specific CSS properties or at-rules for conversion.

const postcss = require('postcss');
const pixrem = require('pixrem');

const css = 'h1 { margin: 32px 0; padding: 16px; }';
const options = { rootValue: 16, replace: true, atrules: true, html: true, browsers: 'last 2 versions' };

postcss([pixrem(options)])
  .process(css)
  .then(result => {
    console.log(result.css);
  });

Other packages similar to pixrem

Keywords

FAQs

Package last updated on 30 Dec 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