PHPackages                             cssoft/rtl - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Localization &amp; i18n](/categories/localization)
4. /
5. cssoft/rtl

ActiveMagento2-module[Localization &amp; i18n](/categories/localization)

cssoft/rtl
==========

Magento2 RTL detection

1.3.6(1y ago)051MITPHP

Since Jan 22Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Cssoft-core/rtl)[ Packagist](https://packagist.org/packages/cssoft/rtl)[ RSS](/packages/cssoft-rtl/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (1)

Magento RTL
===========

[](#magento-rtl)

Magento module that helps to add RTL support to your modules and themes PHP and LESS sources:

```
@import '_modrtl.less';

.sidebar-popup {
    .left(0);
    .modrtl(transform, translateX(-100%), translateX(100%));

    &.shown {
        transform: translateX(0);
    }

    .close {
        .right(0);
    }
}
```

Contents
--------

[](#contents)

1. [Installation](#installation)
    1. [Get the sources](#get-the-sources)
    2. [Add a dependency](#add-a-dependency)
    3. [Create inject point for mixins](#create-inject-point-for-mixins)
2. [Usage](#usage)
    1. [CSS class](#css-class)
    2. [Less mixins](#less-mixins)
    3. [PHP helper](#php-helper)
3. [License](#license)
4. [Credits](#credits)

Installation
------------

[](#installation)

### Get the sources

[](#get-the-sources)

```
composer require cssoft/module-rtl
bin/magento setup:upgrade
```

### Add a dependency

[](#add-a-dependency)

If you want to use RTL mixins in your module sources, you must add a requirement into your module or theme:

```
{
    "require": {
        "cssoft/module-rtl": "^1.3.0"
    }
}
```

### Create inject point for mixins

[](#create-inject-point-for-mixins)

> This step is required if you want to use RTL mixins in your source code.

1. Create `_modrtl.less` inside your module or theme with the following content:

    ```
    // @modrtl
    ```
2. Open your main `less` file, import created `_modrtl.less` file, and save it:

    ```
    @import '_modrtl.less';
    ```

Usage
-----

[](#usage)

### CSS class

[](#css-class)

Module automatically adds `rtl` class name to the body element when current language is detected as RTL. This allows you to write plain RTL-specific styles in your css/less files:

```
.my-element {
    right: 20px;
}
.rtl .my-element {
    right: auto;
    left: 20px;
}
```

While this approach is nice for the small files, it becomes a headache when dealing with large portion of css that should be adjusted. Additionally, this approach make your style files larger.

We recommend to use [mixins](#less-mixins) for the best experience.

### Less mixins

[](#less-mixins)

> [Inject point](#create-inject-point-for-mixins) is required to use mixins.

A set of useful mixins can be injected into your less styles! This approach allows to keep original size of generated css file and doesn't bloat your sources with separate styles for RTL languages:

```
@import '_modrtl.less';

.my-element {
    .right(20px); // Will generate "right: 20px;" for LTR, and "left: 20px;" for RTL.
}
```

Don't like mixins? Use `@modrtl-dir` variable in `& when` statements:

```
@import '_modrtl.less';

.my-element {
    right: 20px;
}
& when (@modrtl-dir = rtl) {
    .my-element {
        right: auto;
        left: 20px;
    }
}
```

**Mixins list**

MixinExample**Misc**.modrtl(@property, @ltrValue, @rtlValue).modrtl(display, block, inline).direction().direction() // will output current direction.direction(@value).direction(rtl).background-position(@ltrValue, @rtlValue).background-position(100% 50%, 0 50%).text-align(@direction).text-align(left)**Padding**.padding(@value).padding(10px 25px 10px 5px).padding-left(@value).padding-left(5px).padding-right(@value).padding-right(25px)**Margin**.margin(@value).margin(10px 25px 10px 5px).margin-left(@value).margin-left(5px).margin-right(@value).margin-right(25px)**Positioning**.float(@direction).float(left).clear(@direction).clear(left).left(@distance).left(20px).right(@distance).right(20px)**Border**.border-radius(@value).border-radius(5px 0 0 5px).border-\[top|right|bottom|left\]-radius(@radius).border-top-radius(5px).border-\[top|bottom\]-\[left|right\]-radius(@radius).border-top-left-radius(5px).border-left(@border-style).border-left(1px solid #f4f4f4);.border-right(@border-style).border-right(1px solid #f4f4f4);.border-color(@value).border-color(#f4f4f4 transparent #eee #f4f4f4).border-left-color(@color).border-left-color(#f4f4f4).border-right-color(@color).border-right-color(transparent).border-style(@value).border-style(dotted dashed none solid).border-left-style(@style).border-left-style(solid).border-right-style(@style).border-right-style(none).border-width(@value).border-width(1px 0 1px 2px).border-left-width(@width).border-left-width(0).border-right-width(@width).border-right-width(2px)### PHP helper

[](#php-helper)

Need a serverside RTL detection? Inject `\CSSoft\Rtl\Helper\Data` into your class and use `isRtl` method:

```
// Check current locale
$helper->isRtl();

// Check custom locale
$helper->isRtl('en_US');
```

License
-------

[](#license)

Distributed under the [MIT license](http://opensource.org/licenses/MIT)

Credits
-------

[](#credits)

Mixins are taken from [anasnakawa/bi-app-sass](https://github.com/anasnakawa/bi-app-sass). Thanks!

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance42

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

482d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/800689ac80f92516544096d69f8a5876763b698097af8c145807f09244c33204?d=identicon)[prashat](/maintainers/prashat)

---

Top Contributors

[![Cssoft-core](https://avatars.githubusercontent.com/u/181851483?v=4)](https://github.com/Cssoft-core "Cssoft-core (1 commits)")

---

Tags

languagemagento2rtlright-to-left

### Embed Badge

![Health badge](/badges/cssoft-rtl/health.svg)

```
[![Health](https://phpackages.com/badges/cssoft-rtl/health.svg)](https://phpackages.com/packages/cssoft-rtl)
```

###  Alternatives

[codezero/laravel-localized-routes

A convenient way to set up, manage and use localized routes in a Laravel app.

543638.1k4](/packages/codezero-laravel-localized-routes)[gettext/languages

gettext languages with plural rules

7530.3M11](/packages/gettext-languages)[lajax/yii2-translate-manager

Translation management extension for Yii 2

227578.8k13](/packages/lajax-yii2-translate-manager)[akaunting/laravel-language

Language switcher package for Laravel

223285.2k1](/packages/akaunting-laravel-language)[vanderlee/syllable

Text syllable splitting and hyphenation using Frank M. Liang's TeX algorithm.

124432.6k8](/packages/vanderlee-syllable)[josiasmontag/laravel-redis-mock

This Laravel package provides a Redis mock for your tests

471.8M16](/packages/josiasmontag-laravel-redis-mock)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
