There have been quite a few dicussions around this in Bootstrap, and it's probably been asked more often than any other feature.
Pre-requisites
- Should work in all supported browsers, meaning Edge Legacy and Safari 10 for the oldest.
- Should work seamlessly with all our components and utilities.
- Should be tested, probably with new examples templates.
- Should be maintainable, thus not lay on hacky things.
Am I missing any pre-requisite, @twbs/team?
FWIW, one of the best resource I ever read about RTL is very recent: RTL Styling 101 by Ahmad Shadeed.
Solutions
Let me try to sum up the various ways to tackle this in v5.
Another dist file
This is what we used in Boosted v4, using rtlcss.
Pros
- another file, not a single bloated one
- easy to setup
Cons
Logical properties
They're meant to be the standard way to do. However Edge Legacy doesn't support them, so we're kinda stuck with this.
PostCSS-logical is meant to handle this in two ways:
- each logical property results in two new declarations, suffixed with
:dir()
- each logical property only gets a LTR fallback:
text-align: left; text-align: start;
Both of them will result in a bloated filesize, and the second—despite being the ordinary fallback—won't allow Edge Legacy to handle RTL.
Pros
- future-proof
- standardized and CSS-y
Cons
- Lack of support
- Filesize (directly due to the lack of support)
Resources
Sassy way
As suggested in the most recent issue about RTL— #28797— a sassy way is possible.
I'd be in favor of a simpler way to handle things:
- using a mixin, like we do for media queries:
@include rtl()
- checking for a boolean before going ahead, like we do for shadows or rounded:
@if $enable-rtl {}
- then wrapping mixin content in
:dir(rtl) using @content
- and then, just use CSS.
Pros
- Sass only
- Consistent with our current way to do things
- Can be
false by default
Cons
- Requires that we write the RTL styles by ourselves
- Source code bloat
- A single bloated output when enabled
So…
My CSS geekery would like to go with Logical properties; rtlcss seems simpler to me since I'm already used to it and it's a robust and proven solution; the sassy way looks a bit naive…
I'd like to hear opinions and suggestions before trying something.
Related issues
Thanks @zaidbarghouthi for listing this!
#28797 #28238 #24807 #27123 #27122 #26879 #26818 #19545 #26299 #25422 #24662 #23703 #24332 #23117 #22708 #22137 #21619 #21180 #20293 #19555 #20075 #19787 #19703 #19668 #19643 #19545 #19379 #18184 #17595 #16455 #16419 #15717 #15700 #15509 #15479 #15433 #14717 #14510 #13564
There have been quite a few dicussions around this in Bootstrap, and it's probably been asked more often than any other feature.
Pre-requisites
Am I missing any pre-requisite, @twbs/team?
FWIW, one of the best resource I ever read about RTL is very recent: RTL Styling 101 by Ahmad Shadeed.
Solutions
Let me try to sum up the various ways to tackle this in v5.
Another
distfileThis is what we used in Boosted v4, using rtlcss.
Pros
Cons
transforms and inlined SVGsLogical properties
They're meant to be the standard way to do. However Edge Legacy doesn't support them, so we're kinda stuck with this.
PostCSS-logical is meant to handle this in two ways:
:dir()text-align: left; text-align: start;Both of them will result in a bloated filesize, and the second—despite being the ordinary fallback—won't allow Edge Legacy to handle RTL.
Pros
Cons
Resources
Sassy way
As suggested in the most recent issue about RTL— #28797— a sassy way is possible.
I'd be in favor of a simpler way to handle things:
@include rtl()@if $enable-rtl {}:dir(rtl)using@contentPros
falseby defaultCons
So…
My CSS geekery would like to go with Logical properties; rtlcss seems simpler to me since I'm already used to it and it's a robust and proven solution; the sassy way looks a bit naive…
I'd like to hear opinions and suggestions before trying something.
Related issues
Thanks @zaidbarghouthi for listing this!
#28797 #28238 #24807 #27123 #27122 #26879 #26818 #19545 #26299 #25422 #24662 #23703 #24332 #23117 #22708 #22137 #21619 #21180 #20293 #19555 #20075 #19787 #19703 #19668 #19643 #19545 #19379 #18184 #17595 #16455 #16419 #15717 #15700 #15509 #15479 #15433 #14717 #14510 #13564