Inline Style Prefixer

7.0.1 · active · verified Sun Apr 19

inline-style-prefixer is a JavaScript library designed to automatically add vendor prefixes to CSS properties within JavaScript style objects at runtime. Currently stable at version 7.0.1, the library has seen sporadic major releases (e.g., a jump from v3 to v7) but maintains active development within its major versions. Its primary function is to ensure cross-browser compatibility for modern CSS properties by intelligently applying prefixes only where necessary for its supported browser matrix (e.g., Chrome 55+, Firefox 52+), rather than prefixing all properties indiscriminately. Key differentiators include its small footprint, speed, and simplicity, offering a functional API. It is widely adopted by popular styling-in-JS libraries such as Aphrodite, Fela, Material UI, and styled-components, providing a reliable solution for managing vendor prefixes in complex web applications.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to import and use the `prefix` function to automatically add vendor prefixes to a JavaScript style object.

import { prefix } from 'inline-style-prefixer';

const style = {
  transition: '200ms all linear',
  boxSizing: 'border-box',
  display: 'flex',
  color: 'blue',
  // Example of a property that won't be prefixed in modern browsers
  borderRadius: '5px'
};

const prefixedStyle = prefix(style);

console.log(prefixedStyle);
/* Example output (may vary based on userAgent and browserlist):
{
  WebkitTransition: '200ms all linear',
  transition: '200ms all linear',
  MozBoxSizing: 'border-box',
  boxSizing: 'border-box',
  display: [ '-webkit-box', '-moz-box', '-ms-flexbox', '-webkit-flex', 'flex' ],
  color: 'blue',
  borderRadius: '5px'
}*/

view raw JSON →