{"id":17624597,"url":"https://github.com/vkalinichev/postcss-rtl","last_synced_at":"2025-04-08T11:08:11.301Z","repository":{"id":49538163,"uuid":"67859925","full_name":"vkalinichev/postcss-rtl","owner":"vkalinichev","description":"PostCSS plugin for RTL-adaptivity","archived":false,"fork":false,"pushed_at":"2023-01-09T16:31:46.000Z","size":931,"stargazers_count":174,"open_issues_count":18,"forks_count":33,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-01T09:29:07.587Z","etag":null,"topics":["arabic","css","hebrew","left-to-right","postcss","postcss-plugin","postcss-rtl","right-to-left","rtl","rtl-adaptivity","rtlcss"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vkalinichev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-10T08:27:42.000Z","updated_at":"2024-12-11T10:56:06.000Z","dependencies_parsed_at":"2023-02-08T13:00:23.463Z","dependency_job_id":null,"html_url":"https://github.com/vkalinichev/postcss-rtl","commit_stats":null,"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vkalinichev%2Fpostcss-rtl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vkalinichev%2Fpostcss-rtl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vkalinichev%2Fpostcss-rtl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vkalinichev%2Fpostcss-rtl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vkalinichev","download_url":"https://codeload.github.com/vkalinichev/postcss-rtl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247829491,"owners_count":21002995,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arabic","css","hebrew","left-to-right","postcss","postcss-plugin","postcss-rtl","right-to-left","rtl","rtl-adaptivity","rtlcss"],"created_at":"2024-10-22T22:04:44.075Z","updated_at":"2025-04-08T11:08:11.279Z","avatar_url":"https://github.com/vkalinichev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PostCSS-RTL\n\n[![npm][npm-img]][npm]\n[![Build Status][ci-img]][ci]\n[![npm][npm-dwnlds-img]][npm]\n[![Package Quality][quality-img]][quality]\n[![license][lic-img]][lic]\n\n[ci-img]:  https://img.shields.io/travis/vkalinichev/postcss-rtl.svg\n[ci]:      https://travis-ci.org/vkalinichev/postcss-rtl\n\n[npm-img]: https://img.shields.io/npm/v/postcss-rtl.svg\n[npm]:     https://npmjs.org/package/postcss-rtl\n\n[quality-img]: http://npm.packagequality.com/shield/postcss-rtl.svg\n[quality]: http://packagequality.com/#?package=postcss-rtl\n\n[lic-img]: https://img.shields.io/github/license/vkalinichev/postcss-rtl.svg\n[lic]:     https://github.com/vkalinichev/postcss-rtl/blob/master/License\n\n[npm-dwnlds-img]: https://img.shields.io/npm/dt/postcss-rtl.svg\n\n[PostCSS]-plugin for RTL-adaptivity\n\nGenerates RTL rules with flipped properties.\nUse one file for both directions!\n\n* [Examples](#examples)\n    * [Simple properties](#simple-properties)\n    * [Animations](#animations)\n    * [Value directives](#value-directives)\n    * [Property directives](#property-directives)\n    * [Ignoring specific declarations](#ignoring-specific-declarations)\n* [Usage](#usage)\n    * [With Webpack](#with-webpack)\n    * [With Gulp](#with-gulp)\n    * [Options](#options)\n* [Thanks](#thanks)\n\n## Examples\n\n### Simple properties\n\nIn most cases all you need is flip property name or value\nfrom `left` to `right` or change values order in full-valued shorthand\nfrom `top-right-bottom-left` to `top-left-bottom-right`.\n\nLTR input:\n```css\n.foo {\n    float: right;\n    margin-left: 13px;\n    text-align: right;\n    font-size: 13px;\n    border-color: lightgray;\n    border-width: 2px 0 2px 2px;\n    border-style: solid dashed solid solid\n}\n\n.foo {\n    text-align: center;\n}\n```\n\nLTR+RTL output:\n```css\n.foo {\n    font-size: 13px\n}\n\n[dir] .foo {\n    border-color: lightgray\n}\n\n[dir=\"ltr\"] .foo {\n    float: right;\n    margin-left: 13px;\n    text-align: right;\n    border-width: 2px 0 2px 2px;\n    border-style: solid dashed solid solid\n}\n\n[dir=\"rtl\"] .foo {\n    float: left;\n    margin-right: 13px;\n    text-align: left;\n    border-width: 2px 2px 2px 0;\n    border-style: solid solid solid dashed\n}\n\n[dir] .foo {\n    text-align: center\n}\n```\n\n### Animations\nFlippable keyframes-animations will be splitted to two\ndirection-based rules with `-ltr` or `-rtl` suffixes\n\nLTR input:\n```css\n.foo {\n    animation: 1s slide 0s ease-in-out\n}\n\n@keyframes slide {\n    from {\n        transform: translate( -1000px )\n    }\n    to {\n        transform: translate( 0 )\n    }\n}\n```\n\nLTR+RTL output:\n```css\n[dir=\"ltr\"] .foo {\n    animation: 1s slide-ltr 0s ease-in-out\n}\n\n[dir=\"rtl\"] .foo {\n    animation: 1s slide-rtl 0s ease-in-out\n}\n\n@keyframes slide-ltr {\n    from {\n        transform: translate( -1000px )\n    }\n    to {\n        transform: translate( 0 )\n    }\n}\n\n@keyframes slide-rtl {\n    from {\n        transform: translate( 1000px )\n    }\n    to {\n        transform: translate( 0 )\n    }\n}\n```\n\n### Value directives\n\nTo transform declaration values use value directives:\n\n* `/* rtl:prepend:{value} */` - to prepend the {value} before the current value\n* `/* rtl:append:{value} */` - to append the {value} after the current value\n* `/* rtl:{value} */` - to replace the current value with the supplied value\n\n**Source**\n\n```css\n.foo {\n    font-weight: bold;\n    font-family: \"Droid Sans\", \"Helvetica Neue\", Arial, sans-serif/*rtl:prepend:\"Droid Arabic Kufi\",*/;\n    transform: rotate(45deg)/* rtl:append: scaleX(-1) */;\n    flex-direction: row/* rtl: row-reverse */;\n}\n```\n\n**Result**\n\n```css\n.foo {\n    font-weight: bold;\n}\n\n[dir=ltr] .foo {\n    font-family: \"Droid Sans\", \"Helvetica Neue\", Arial, sans-serif/*rtl:prepend:\"Droid Arabic Kufi\",*/;\n    transform: rotate(45deg)/* rtl:append: scaleX(-1) */;\n    flex-direction: row/* rtl: row-reverse */;\n}\n\n[dir=rtl] .foo {\n    font-family: \"Droid Arabic Kufi\", \"Droid Sans\", \"Helvetica Neue\", Arial, sans-serif;\n    transform: rotate(45deg) scaleX(-1);\n    flex-direction: row-reverse;\n}\n```\n\n### Property directives\n\nTo transform declaration property name use property directives:\n\n* `/* rtl:as:{prop} */` - to process the property as {prop}. Usable for custom properties (uses [rtlcss aliases][aliases documentation] under the hood)\n\n**Source**\n\n```css\n:root {\n    --padding /* rtl:as:padding */: 1rem 2rem 3rem 4rem;\n}\n```\n\n**Result**\n\n```css\n[dir=ltr]:root {\n    --padding /* rtl:as:padding */: 1rem 2rem 3rem 4rem;\n}\n\n[dir=rtl]:root {\n    --padding /* rtl:as:padding */: 1rem 4rem 3rem 2rem;\n}\n```\n\n### Ignoring specific declarations\nTo skip flipping specific declarations use some of supported directives:\n\n* `/* rtl:ignore */` - to ignore the following rule *or* the containing declaration\n* `/* rtl:begin:ignore */` and `/* rtl:end:ignore */` - to ignore rules within scope\n\nIgnore one rule:\n```css\n/* rtl:ignore */\n.foo {\n    padding-left: 0\n}\n```\n\nBlock-syntax to ignore rules within scope:\n```css\n/* rtl:begin:ignore */\n.foo {\n    padding-left: 0\n}\n.bar {\n    direction: ltr\n}\n/* rtl:end:ignore */\n```\n\nValue-syntax to ignore a single CSS declaration:\n```css\n.foo {\n    margin-left: 20px;\n    padding-right: 20px /* rtl:ignore */;\n}\n```\n\n`/*!` notation will work too:\n```css\n/*! rtl:ignore */\n.foo {\n    padding-left: 0\n}\n```\n\n## Usage\n1. Plug it to PostCSS\n\n    ```js\n    const postcss = require('postcss')\n    const rtl = require('postcss-rtl')\n\n    postcss([ rtl( options ) ])\n    ```\n\n    See [PostCSS] docs for examples for your environment.\n\n2. Manage direction by switching between `dir=\"ltr\"` and `dir=\"rtl\"` on `\u003chtml\u003e` element.\n\n### With Webpack:\n```js\nmodule.exports = {\n  module: {\n    rules: [ {\n      test: /\\.css$/,\n      use: [\n        { loader: 'style-loader' },\n        { loader: 'css-loader' },\n        { loader: 'postcss-loader',\n          options: {\n            plugins: function () {\n              return [ require( 'postcss-rtl' )( options ) ]\n            }\n          }\n        }\n      ]\n    } ]\n  }\n}\n```\n\n### With Gulp:\n```js\ngulp.src( 'style.css' )\n    .pipe( postcss( [ rtl( options ) ]) )\n    .pipe( gulp.dest( './dest' ) )\n```\n\n### Options\n* `addPrefixToSelector`: Custom function for adding prefix to selector. Optional.\n    Example:\n    ```js\n    function addPrefixToSelector ( selector, prefix ) {\n        return `${prefix} \u003e ${selector}` // Make selectors like [dir=rtl] \u003e .selector\n    }\n    ```\n  **note:** the returned string _must_ include `prefix` to avoid an infinite recursion\n\n* `onlyDirection`: generate only one-direction version: `ltr` or `rtl`\n\n* `prefixType`: Switches between adding attributes and classes. Optional:\n    * `attribute` (by default, recommended): `.foo` =\u003e `[dir=rtl] .foo`\n    * `class` (useful for IE6): `.foo` =\u003e `.dir-rtl .foo`\n\n* `prefix`: Uses a custom string, instead of 'dir', for the added attribute and class selectors\n    * e.g. `'data-my-custom-dir'` (for attribute prefixType): `.foo` =\u003e `[data-my-custom-dir=rtl] .foo`\n    * e.g. `'my-custom-dir'` (for class prefixType): `.foo` =\u003e `.my-custom-dir-rtl .foo`\n\n* `removeComments` (default: `true`): remove `rtl:*` comments after process them\n\n* `fromRTL` (default: `false`): assume all styles are written in RTL direction and generate corresponding LTR styles for them\n\n* `blacklist`: the array of css properties which processing will be ignored\n    Example:\n    ```js\n    ['padding-left', 'padding-right']\n    ```\n* `whitelist`: the array of css properties which (and only them) will be processed\n    Example:\n    ```js\n    ['margin', 'border-color']\n    ```\n* `aliases`: check rtlcss [aliases documentation][aliases documentation]\n    Example:\n    ```js\n    {\n        `--spacing`: 'padding'\n    }\n    ```\n## Thanks\nGreat thanks to projects:\n* [PostCSS][PostCSS]\n* [RTLCSS][RTLCSS]\n\n[PostCSS]: https://github.com/postcss/postcss\n[RTLCSS]: https://github.com/MohammadYounes/rtlcss\n[rtlcss-directives]: http://rtlcss.com/learn/getting-started/why-rtlcss/#processing-directives\n[aliases documentation]: https://rtlcss.com/learn/usage-guide/aliases/","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvkalinichev%2Fpostcss-rtl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvkalinichev%2Fpostcss-rtl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvkalinichev%2Fpostcss-rtl/lists"}