# fela-plugin-rtl

> Fela plugin to convert styles to RTL

Latest version **12.2.1** (published 2022-11-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install fela-plugin-rtl
pnpm add fela-plugin-rtl
yarn add fela-plugin-rtl
bun add fela-plugin-rtl
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 12.2.1 |
| Published | 2022-11-16 |
| First published | 2017-08-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 14.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2281 |
| Author | Robin Weser |
| Maintainers | rofrischmann, txhawks |
| Keywords | fela, fela-plugin, rtl, accessibility |

## Links

- npm: https://www.npmjs.com/package/fela-plugin-rtl
- Repository: https://github.com/robinweser/fela
- Homepage: https://github.com/robinweser/fela#readme
- Issues: https://github.com/robinweser/fela/issues
- npm.io page: https://npm.io/package/fela-plugin-rtl

## Dependencies (1)

- [rtl-css-js](https://npm.io/package/rtl-css-js.md) ^1.1.3

## Recent versions

- 12.2.1 (latest) — 2022-11-16
- 12.0.0-rc.3.0 (next) — 2022-02-22
- 12.2.0 — 2022-07-06
- 12.1.2 — 2022-05-04
- 12.1.1 — 2022-04-07
- 12.1.0 — 2022-04-06
- 12.0.2 — 2022-02-23
- 12.0.1 — 2022-02-23
- 12.0.0 — 2022-02-23
- 12.0.0-y.0 — 2022-02-22
- 12.0.0-rc.2 — 2022-02-21
- 12.0.0-rc.1 — 2022-02-18
- 12.0.0-rc.0 — 2022-02-16
- 11.7.0 — 2021-09-24
- 11.6.1 — 2021-03-25
- … 46 more at https://npm.io/package/fela-plugin-rtl/versions

## README

# fela-plugin-rtl

<img alt="npm version" src="https://badge.fury.io/js/fela-plugin-rtl.svg"> <img alt="npm downloads" src="https://img.shields.io/npm/dm/fela-plugin-rtl.svg"> <a href="https://bundlephobia.com/result?p=fela-plugin-ftl@latest"><img alt="Bundlephobia" src="https://img.shields.io/bundlephobia/minzip/fela-plugin-rtl.svg"></a>

Uses [rtl-css-js](https://github.com/kentcdodds/rtl-css-js) to convert a style object to its right-to-left counterpart.

## Installation

```sh
yarn add fela-plugin-rtl
```

You may alternatively use `npm i --save fela-plugin-rtl`.

## Usage

Make sure to read the documentation on [how to use plugins](https://fela.js.org/docs/latest/advanced/plugins#using-plugins).

```javascript
import { createRenderer } from 'fela'
import rtl from 'fela-plugin-rtl'

const renderer = createRenderer({
  plugins: [rtl()],
})
```

### Configuration

##### Parameters

|  Parameter       | Value              | Default | Description                                                                                                                     |
| ---------------- | ------------------ | ------- | ------------------------------------------------------------------------------------------------------------------------------- |
| defaultDirection | _("rtl" \| "ltr")_ |  `rtl`  | The default direction which can be useful if one is using the `theme.direction` option to dynamically toggle rtl transformation |

## Example

#### Input

```javascript
{
  paddingLeft: 20,
  marginRight: '25px',
  cursor: 'w-resize',
  textShadow: 'red 2px 0'
}
```

#### Output

```javascript
{
  paddingRight: 20,
  marginleft: '25px',
  cursor: 'e-resize',
  textShadow: 'red -2px 0'
}
```

## Theme-Based Mode

Apart from enforcing rtl all the time, one can also leverage a special `props.theme.direction` property to enable/disable rtl transformation. This is especially useful together with React to disable transformation for subtrees.

```javascript
const rule = () => ({
  paddingLeft: 20,
  marginRight: '25px',
  cursor: 'w-resize',
  textShadow: 'red 2px 0',
})

// will be transformed
renderer.renderRule(rule)

// wont be transformed
renderer.renderRule(rule, { theme: { direction: 'ltr' } })
```

## License

Fela is licensed under the [MIT License](http://opensource.org/licenses/MIT).<br>
Documentation is licensed under [Creative Commons License](http://creativecommons.org/licenses/by/4.0/).<br>
Created with ♥ by [@robinweser](http://weser.io) and all the great contributors.

---
_Source: https://npm.io/package/fela-plugin-rtl · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
