A Stylis 4.x plugin that translates pixel units to rem units

Overview

stylis-px2rem-plugin

A Stylis 4.x plugin that translates pixel units to rem units.

Installation

With npm

$ npm install stylis-px2rem-plugin

With yarn

$ yarn add stylis-px2rem-plugin

Options

{
  remSize?: number
  allowList?: string[]
  blockList?: string[]
} | undefined

Default

Transforms all px units to rem units on a 16:1 basis.

Example

stylisPx2RemPlugin()

font-size: 12px;
height: 64px;

... becomes ...

font-size: 0.75rem;
height: 8rem;

remSize

Changes the conversion basis of how many px units per rem unit.

Example

stylisPx2RemPlugin({ remSize: 10 })

font-size: 12px;
height: 64px;

... becomes ...

font-size: 1.2rem;
height: 6.4rem;

allowList

Only convert CSS properties in the allowlist.

Example

stylisPx2RemPlugin({ allowList: ['font-size'] })

font-size: 12px;
height: 64px;

... becomes ...

font-size: 0.75rem;
height: 64px;

blockList

Changes the conversion basis of how many px units per rem unit.

Example

stylisPx2RemPlugin({ blockList: ['font-size'] })

font-size: 12px;
height: 64px;

... becomes ...

font-size: 12px;
height: 8rem;

Using with emotion/cache

import { CacheProvider } from '@emotion/react'
import createCache from '@emotion/cache'
import { prefixer } from 'stylis'
import stylisPx2RemPlugin from 'stylis-px2rem-plugin'

const myCache = createCache({
  key: 'your-key',
  stylisPlugins: [stylisPx2RemPlugin()],
})

render(
  <CacheProvider value={myCache}>
  	...
  </CacheProvider>
)

Aknowledgements

Our thanks go out to stylis-pxtorem and stylis-rtl for inspiration when developing this plugin.

You might also like...

Babel-plugin-amd-checker - Module format checking plugin for Babel usable in both Node.js the web browser environments.

babel-plugin-amd-checker A Babel plugin to check the format of your modules when compiling your code using Babel. This plugin allows you to abort the

Jan 6, 2022

A variety of jQuery plugin patterns for jump starting your plugin development

jQuery Plugin Patterns So, you've tried out jQuery Boilerplate or written a few of your own plugins before. They work to a degree and are readable, bu

Dec 31, 2022

A tool to get plugin statistics of Obsidian plugin ecosystem.

A tool to get plugin statistics of Obsidian plugin ecosystem.

Obsidian Plugin Stats A tool to get plugin statistics of Obsidian plugin ecosystem. Usage You can use this tool to see the plugins that has hit commun

Dec 25, 2022

📦 Alpine JS plugin to extend the functionality of the official $persist plugin

Alpine JS Persist Extended Alpine JS magic method $storage extends the official $persist plugin to help you work with local storage 📦 Example 👀 div

Dec 28, 2022

kakaolink-plugin is a remote-kakao plugin for sending KakaoLinks instead of plain text

kakaolink-plugin is a remote-kakao plugin for sending KakaoLinks instead of plain text

kakaolink-plugin Discord Server About kakaolink-plugin is a remote-kakao plugin for sending KakaoLinks instead of plain text. Requirements Node.js v17

Oct 1, 2022

A markdown-it plugin that process images through the eleventy-img plugin. Can be used in any projects that uses markdown-it.

markdown-it-eleventy-img A markdown-it plugin that process images through the eleventy-img plugin. Can be used in any projects that use markdown-it. F

Dec 20, 2022

This is a simple Image popup Jquery plugin. With a very simple configuration, you can show a popup on your webpage. By the way, this plugin works after page load.

This is a simple Image popup Jquery plugin. With a very simple configuration, you can show a popup on your webpage. By the way, this plugin works after page load.

Jquery-SingleImagePopup This is a simple Image popup Jquery plugin. With a very simple configuration, you can show a popup on your webpage. By the way

Aug 22, 2022

An obsidian toolbar plugin, modified from the Cmenu plugin

An obsidian toolbar plugin, modified from the Cmenu plugin

obsidian-editing-toolbar Plugin Thanks to the cmenu plugin, which gave me a lot of inspiration, but this plugin has not been maintained for more than

Dec 29, 2022

Deploy WordPress plugin and theme to the wordpress.org plugin directory.

wp-deployer Deploy WordPress plugin and theme to the wordpress.org plugin directory. Install npm install --save-dev wp-deployer Settings slug : Plugin

Sep 6, 2022
Comments
  • Wrong package.json description

    Wrong package.json description

    Actually description is duplicated.

    - "description": "A Stylis 4.x plugin that translates pixel units to rem units.A Stylis 4.x plugin that translates pixel units to rem units.",
    + "description": "A Stylis 4.x plugin that translates pixel units to rem units.",
    

    https://github.com/oncarapp/stylis-px2rem-plugin/blob/main/package.json#L10

    documentation 
    opened by srvaz 1
Owner
oncar
oncar
A bot that instantly translates messages on Discord.

Translate Thing A bot that instantly translates messages on Discord. Here is a lil preview. Setup All you need to do is install NodeJS if you do not h

Amelia 2 Oct 23, 2022
Create amazing pixel art murals. 🐸

Pixelate Create amazing pixel art murals with sticky notes. Pixelate is a image editor that shows assembly guides to put art with sticky notes on your

Google 19 Dec 11, 2022
A web app that helps you create Pixel Art Masterpieces! ;)

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

Seyyed Mohammad Shobeiry 3 Jun 13, 2022
Scripts pour la fresque pixel art ZEvent Place 2022

Scripts pour la fresque pixel art ZEvent Place 2022 English: detailed documentation have been translated, see "documentation" folder above. Download t

null 7 Sep 11, 2022
Firefox plugin to automatically translate ° Fahrenheit and size measurements into european units

Eurofox ???? ?? ?? Firefox plugin to automatically translate ° Fahrenheit, weights, speed and size measurements into european units. To see the origin

Inga Feick 5 Oct 16, 2022
A simple calculator for how many units of insulin to take with a meal depending on current and target blood sugar levels.

Insulin-Calculator One of my first programs, made to try building javascript-read HTML forms. A simple calculator for how many units of insulin to tak

Athena 1 Dec 26, 2021
The ManageYourCompany 📈 project is a project that creates, deletes, updates companies, units and assets.

The ManageYourCompany ?? project is a project that creates, deletes, updates companies, units and assets. The rule is that every company has several units and the units have several assets, these assets are machines with several fields: Name, status, person in charge, image, among others... This is a project in order to exercise my Backend skills with NodeJs and front with react.

Bruno da Silva Leite 2 Feb 9, 2022
Explore units, stats and more

AoE 4 Explorer An useful visualization and UI to explore units, their stats and abilities and all possible upgrades and technologies for Age Of Empire

AoE4 World 20 Dec 8, 2022
Module to convert units for distances, weights and temperatures!

Unit Converter (Distance, Temperature, Weights) Every unit you can see in this file can be transformed into any of the other units. The Calculator wor

Niklas Koch 8 Jan 27, 2022
A dedicated desktop app that enables you to move items in and out of storage units in CSGO.

CASEMOVE Casemove is an open-source desktop application that helps you easily move items out of and into Storage Units in Counter-Strike: Global Offen

null 161 Dec 24, 2022