npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

postcss-rtl-logical-properties

v2.0.1

Published

This plugin is a PostCSS plugin that replaces supported horizontal direction properties (LTR/RTL) with logical CSS properties (start/end) to add RTL support.

Readme

🌍 postcss-rtl-logical-properties

NPM Version License GitHub

postcss-rtl-logical-properties is a PostCSS plugin that replaces physical CSS properties (left, right, margin-left, padding-right, etc.) with logical CSS properties (start, end, margin-inline-start, etc.) for better RTL support with reduced CSS size.

🚀 Features

  • Converts physical direction properties to logical properties automatically.
  • Reduces final CSS size by eliminating redundant LTR/RTL selector duplication.
  • Compatible with postcss-rtl and rtlcss for comprehensive RTL support.
  • ESM & CommonJS support for modern environments.
  • Zero dependencies – lightweight and fast.

📦 Installation

npm install postcss-rtl-logical-properties --save-dev

🔧 Usage

ESM Example

Add the plugin to your PostCSS configuration:

import postcss from "postcss";
import postcssRtlLogicalProperties from "postcss-rtl-logical-properties";
import postcssRTL from "postcss-rtl";

const css = `
.foo {
    margin-left: 10px;
    margin-right: 20px;
    border-radius: 5px 10px 15px 20px;
    }
`;

postcss([
  plugin,
  postcssRTL({
    blacklist: plugin.ignoreDeclarationList,
  }),
])
  .process(css, { from: false })
  .then((result) => {
    console.log(result.css);
  });
const postcssRtlLogicalProperties = require("postcss-rtl-logical-properties");

module.exports = {
  plugins: [postcssRtlLogicalProperties()],
};

🌍 Usage with postcss-rtl

For multi-direction support (LTR + RTL) using the [dir] attribute:

import postcss from "postcss";
import plugin from "postcss-rtl-logical-properties";
import postcssRTL from "postcss-rtl";

const css = `
.foo {
    margin-left: 10px;
    margin-right: 20px;
    border-radius: 5px 10px 15px 20px;
}
`;

postcss([plugin, postcssRTL({ blacklist: plugin.ignoreDeclarationList })])
  .process(css, { from: false })
  .then((result) => console.log(result.css));

⚡ CommonJS Example (One-Way Direction Support)

const postcssRtlLogicalProperties = require("postcss-rtl-logical-properties");
const rtlcss = require("rtlcss");
const postcss = require("postcss");

const result = postcss([postcssRtlLogicalProperties(), rtlcss()]).process(`
    .test {
        padding-left: 10px;
        border-right: 20px;
        margin: 10px 1px 10px 29px;
    }
`);

console.log(result.css);

🛠 Plugin Options

| Option | Description | Default | | ------------ | ----------------------------------------------- | ------------- | | hDirection | Sets the horizontal writing direction (LTR/RTL) | LeftToRight | | vDirection | Sets the vertical writing direction (TTB/BTB) | TopToBottom |

🎯 Supported Properties

This plugin replaces the following physical properties with their logical counterparts:

  • Padding: padding-left, padding-right
  • Margin: margin-left, margin-right
  • Border: border-left, border-right, border-left-width, border-right-width, border-left-color, border-right-color, border-left-style, border-right-style
  • Radius: border-bottom-left-radius, border-bottom-right-radius, border-top-left-radius, border-top-right-radius
  • Positioning: left, right
  • Float & Clear: float, clear
  • Text Alignment: text-align

🌍 Browser Support

Global support: ~89% (Can I Use)

Note: This plugin does not transform complex properties like transform, background-position, or border-radius. For these, use rtlcss.

🤔 Why Use This Plugin?

Many RTL processors like postcss-rtlcss generate duplicate selectors with [dir] attributes, significantly increasing CSS file size. This plugin eliminates redundant rules by leveraging native logical properties, reducing final CSS size while maintaining full RTL support.

📝 License

MIT License © Artyom Gorlovetskiy

🔗 Links