Are you ready for Cyber Week Deals?
Up to 70% discount for CoreUI PRO Admin Templates and UI Components.
Learn how to enable support for right-to-left text in CoreUI for Bootstrap across our layout, components, and utilities.
We recommend getting familiar with CoreUI for Bootstrap first by reading through our Getting Started Introduction page. Once you’ve run through it, continue reading here for how to enable RTL.
You may also want to read up on the RTLCSS project, as it powers our approach to RTL.
There are two strict requirements for enabling RTL in Bootstrap-powered pages.
- Add an appropriate
lang="ar", on the
From there, you’ll need to include an RTL version of our CSS. For example, here’s the stylesheet for our compiled and minified CSS with RTL enabled:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@coreui/[email protected]/dist/css/coreui.rtl.min.css" integrity="sha384-7W1eMOzj3wRp1Oat/SJe+uPZ3lBB5YWlrjI9zeLbto2KkseMeJKSGAs4844qZPjz" crossorigin="anonymous">
You can see the above requirements reflected in this modified RTL starter template.
Our approach to building RTL support into CoreUI comes with two important decisions that impact how we write and use our CSS:
First, as in CoreUI 3 we decided to build it with our own mixins This gives us full control and allows us to generate LTR and RTL separately, or if needed one stylesheet with both versions without any style’s duplicates.
Second, in CoreUI 3 we introduced a handful of directional classes ex.
mfs-auto, but in CoreUI 4 we’ve simplified them ex.
ms-auto, and renamed all directional classes to adopt a logical properties approach. Most of you have already interacted with logical properties thanks to our flex utilities—they replace direction properties like
end. That makes the class names and values appropriate for LTR and RTL without any overhead.
For example, instead of
Working with RTL, through our source Sass or compiled CSS, shouldn’t be much different from our default LTR though.
Customize from source
When it comes to customization, the preferred way is to take advantage of variables, maps, and mixins.
LTR and RTL at the same time
Need both LTR and RTL on the same page? All you have to do is set following variables:
$enable-ltr: true; $enable-rtl: true;
After running Sass, each selector in your CSS files will be prepended by
*[dir=rtl] for RTL files. Now you’re able to use both files on the same page.
By default LTR is enable and RTL is disable, but you can easily change it and use only RTL.
$enable-ltr: false; $enable-rtl: true;