GithubHelp home page GithubHelp logo

20lives / tailwindcss-rtl Goto Github PK

View Code? Open in Web Editor NEW
347.0 6.0 33.0 410 KB

Enabling bidirectional support on tailwindcss framework

License: MIT License

JavaScript 100.00%
css tailwindcss rtl logical direction tailwindcss-rtl ltr

tailwindcss-rtl's Introduction

tailwindcss-rtl

Total Downloads Latest Release

Introduction

Internationalization in semitic languages needs more than just translating texts, you would also need to mirror the layout horizontally. This can be done by adding dir="rtl" the the layout body tag, but this is propably not be enough and you will need to create a different style for RTL.

With tailwindcss-rtl plugin you will be able to support both RTL and LTR in the same style.

Live demo

Full live demo based on the official tailwindcss course project is available here:

Workcation live demo

Workcation-nuxt-i18n-rtl

Usage

Replace all utilities based on Right/Left with the new utilities specified below.

for example when you create an LTR layout and you would like to add left padding to an element you would normaly use pl-6, left is the start direction in LTR so you will replace it with ps-6.

Now add dir="rtl" or dir="ltr" attribute to your top level layout element:

<body dir="rtl">

Note: for all utilities to work as expected adding the dir attribute (both "rtl"/"ltr") to a top level tag is mandatory), even when "ltr" is assumed to be default.

Installation

Install tailwindcss-rtl package:

# Yarn
yarn add tailwindcss-rtl --dev

# NPM
npm install tailwindcss-rtl --save-dev

Require tailwindcss-rtl in the project tailwind.config.js file:

plugins: [
  require('tailwindcss-rtl'),
],

Utilities

*tailwindcss-rtl adds the start and end notations as substitue for left and right.

Class Description
ps-[X] padding on start direction
pe-[X] padding on end direction
ms-[X] margin on start direction
me-[X] margin on end direction
text-start text aligned at the start direction
text-end text aligned at the end direction
float-start float to start direction
float-end float to end direction
start-[X] placement of positioned elements on start
end-[X] placement of positioned elements on end
clear-start clear to start direction
clear-end clear to end direction
rounded-s-[X] rounded borders on start direction
rounded-e-[X] rounded borders on end direction
rounded-ts-[X] rounded borders on top start direction
rounded-te-[X] rounded borders on top end direction
rounded-bs-[X] rounded borders on bottom start direction
rounded-be-[X] rounded borders on bottom end direction
border-s-[X] border width on start direction
border-e-[X] bordern width on end direction
space-s-[X] space between child
divide-s-[X] border width between child elements

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.