An open API service indexing awesome lists of open source software.

https://github.com/saleh7/shadcnui-rtl

Transform shadcn/ui components to RTL - One command, full Arabic/farsi/urdu support
https://github.com/saleh7/shadcnui-rtl

arabic farsi react right-to-left rtl shadcn shadcn-ui tailwind transform urdu

Last synced: 14 days ago
JSON representation

Transform shadcn/ui components to RTL - One command, full Arabic/farsi/urdu support

Awesome Lists containing this project

README

          

# shadcnui-rtl ๐Ÿ”„

[![npm version](https://badge.fury.io/js/shadcnui-rtl.svg)](https://www.npmjs.com/package/shadcnui-rtl)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

> One-command RTL transformation for shadcn/ui components

Transform your shadcn/ui components to full RTL support with a single command. Perfect for Arabic, Persian, Urdu, and other RTL language applications.

## โœจ Features

- ๐Ÿš€ **One Command**: Transform all your shadcn/ui components instantly
- ๐ŸŽฏ **Smart Detection**: Automatically identifies and transforms LTR classes
- ๐Ÿ”„ **Comprehensive**: Handles padding, margin, positioning, borders, text alignment, and animations
- ๐Ÿ›ก๏ธ **Safe**: Dry-run mode to preview changes, backup option for safety
- ๐ŸŽจ **Icon Support**: Automatically rotates directional icons (ChevronLeft, ArrowRight, etc.)
- ๐Ÿ“ฆ **Zero Config**: Works out of the box with sensible defaults
- ๐Ÿงช **Battle-tested**: Comprehensive test suite with 80%+ coverage

## ๐Ÿ“ฆ Installation

### Global Installation (Recommended)
```bash
npm install -g shadcnui-rtl
```

### Using npx (No Installation)
```bash
npx shadcnui-rtl
```

### Local Installation
```bash
npm install --save-dev shadcnui-rtl
```

## ๐Ÿš€ Quick Start

```bash
# Run in your project root
npx shadcnui-rtl

# That's it! Your components now support RTL ๐ŸŽ‰
```

## ๐Ÿ“– Usage

### Basic Usage
```bash
# Transform components in default directory (src/components)
shadcnui-rtl

# Or use the short alias
scnrtl
```

### Custom Directory
```bash
shadcnui-rtl --path ./components
```

### Preview Changes (Dry Run)
```bash
shadcnui-rtl --dry-run
```

### Create Backups
```bash
shadcnui-rtl --backup
```

### Advanced Options
```bash
# Exclude specific files
shadcnui-rtl --exclude "dialog.tsx,modal.tsx"

# Disable icon rotation
shadcnui-rtl --no-rotate-icons

# Plain text output (no emojis)
shadcnui-rtl --no-icons

# Verbose output
shadcnui-rtl --verbose
```

## ๐Ÿ”„ What Gets Transformed?

### Tailwind Classes

| LTR Class | RTL Class | Description |
|-----------|-----------|-------------|
| `pl-*` | `ps-*` | Padding left โ†’ start |
| `pr-*` | `pe-*` | Padding right โ†’ end |
| `ml-*` | `ms-*` | Margin left โ†’ start |
| `mr-*` | `me-*` | Margin right โ†’ end |
| `left-*` | `start-*` | Left position โ†’ start |
| `right-*` | `end-*` | Right position โ†’ end |
| `rounded-l-*` | `rounded-s-*` | Border radius left โ†’ start |
| `rounded-r-*` | `rounded-e-*` | Border radius right โ†’ end |
| `border-l-*` | `border-s-*` | Border left โ†’ start |
| `border-r-*` | `border-e-*` | Border right โ†’ end |
| `text-left` | `text-start` | Text align left โ†’ start |
| `text-right` | `text-end` | Text align right โ†’ end |

### Special Components

- **Radio & Switch**: Adds proper RTL translation classes for checked states
- **Directional Icons**: Automatically adds `rtl:rotate-180` to:
- ChevronLeft/Right
- ArrowLeft/Right
- CaretLeft/Right
- PanelLeft/Right

### Data Attributes

Transforms Radix UI positioning:
- `data-side="left"` โ†’ `data-side="start"`
- `data-side="right"` โ†’ `data-side="end"`

## ๐ŸŽฏ Examples

### Before
```tsx


Click me

```

### After
```tsx


Click me

```

## ๐Ÿ›ก๏ธ Safety Features

- **Dry Run**: Preview all changes without modifying files
- **Backup**: Create `.backup` files before transformation
- **Exclusion**: Skip specific files from transformation
- **Validation**: Checks component structure before transforming
- **Error Recovery**: Graceful handling of parsing errors

## โš™๏ธ Configuration

### CLI Options

| Option | Alias | Description | Default |
|--------|-------|-------------|---------|
| `--path` | `-p` | Components directory path | `src/components` |
| `--dry-run` | `-d` | Preview changes only | `false` |
| `--backup` | `-b` | Create backup files | `false` |
| `--exclude` | `-e` | Files to skip (comma-separated) | `dialog.tsx` |
| `--verbose` | `-v` | Detailed output | `false` |
| `--no-icons` | | Disable emoji in output | `false` |
| `--no-rotate-icons` | | Skip icon rotation | `false` |
| `--help` | `-h` | Show help | |

## ๐Ÿงช Testing

```bash
# Run tests
npm test

# Watch mode
npm run test:watch

# Coverage report
npm run test:coverage
```

## ๐Ÿค Contributing

We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## ๐Ÿ“ Changelog

See [CHANGELOG.md](CHANGELOG.md) for a list of changes.

## ๐Ÿ“„ License

MIT ยฉ [Saleh7](https://github.com/Saleh7)

## ๐Ÿ™ Acknowledgments

- [shadcn/ui](https://ui.shadcn.com/) for the amazing component library
- [Tailwind CSS](https://tailwindcss.com/) for the utility-first CSS framework
- [Radix UI](https://www.radix-ui.com/) for accessible component primitives

## ๐Ÿ’ฌ Support

- ๐Ÿ› [Report bugs](https://github.com/Saleh7/shadcnui-rtl/issues)
- ๐Ÿ’ก [Request features](https://github.com/Saleh7/shadcnui-rtl/issues)
- ๐Ÿ“ง [Contact](mailto:Saleh7@protonmail.ch)

---


Made with โค๏ธ for the RTL community