Bootstrap doesn't currently have rtl support. The solution should come from the rtl-interested community, but we need a plan. Maintaining a fork with rtl fixes is, in my opinion, wasted effort; there must be a better solution.
abc.rtl.scss).$rtl-support| Value | Meaning |
|-------|------------------------------|
| 0 | Original bootstrap (default) |
| 1 | Everything filpped |
| 2 | LTR and RTL** |
** When using 2 user will have to set the dir="rtl" or dir="ltr". i.e <html dir="ltr"> or <html dir="rtl">
.alert-dismissible {
padding-right: $close-font-size + $alert-padding-x * 2;
// Adjust close link position
.close {
position: absolute;
top: 0;
right: right;
padding: $alert-padding-y $alert-padding-x;
color: inherit;
}
}
lets have
.alert-dismissible {
@include padding-right($close-font-size + $alert-padding-x * 2);
// Adjust close link position
.close {
position: absolute;
top: 0;
@include right(0);
padding: $alert-padding-y $alert-padding-x;
color: inherit;
}
}
and the mixins would look like:
@mixin padding-right($value) {
@if ($rtl-support == 0) {
padding-right: $value;
}
@else if ($rtl-support == 1) {
padding-left: $value;
}
@else if ($rtl-support == 2) {
[dir="ltr"] & {
padding-right: $value;
}
[dir="rtl"] & {
padding-left: $value;
}
}
}
@mixin right($value) {
@if ($rtl-support == 0) {
right: $value;
}
@else if ($rtl-support == 1) {
left: $value;
}
@else if ($rtl-support == 2) {
[dir="ltr"] & {
right: $value;
}
[dir="rtl"] & {
left: $value;
}
}
}
Also, option 2 will include ms-x, ps-x, float-start, and -e, -end classes.
Obviously there will be alot of mixins.
Moreover some of the mixins will change, i.e. border-left-radius => border-start-radius and will contain the same login as shown above.
I didn't want to make a pull request of this so here is an example where I have done the above for [alert, breadcrumb, btn-group, card]
@mdo @cvrebert
Another option that might work is to run Bootstrap's CSS through postcss-rtl, which would generate a new CSS file with both LTR and RTL support.
I haven't tried it myself, but it might be an option.
Another option that might work is to run Bootstrap's CSS through postcss-rtl, which would generate a new CSS file with both LTR and RTL support.
I haven't tried it myself, but it might be an option.
i have check this option but it seems to make your css a bit bulky
FWIW, we're using rtlcss in our own fork Boosted to output another dist file.
However it still requires a few overrides, which we basically push to the RTL file.
Our script looks like this: rtlcss dist/css/boosted.css dist/css/boosted-rtl.css && shx cat dist/css/o-rtl.css >> dist/css/boosted-rtl.css. This is probably not the best way, but at least it works and we can provide some help with it.
Also, if the targetted version is v5 and if dropping support for IE11 is considered, using logical properties and values everywhere possible could help a lot with RTL, without doing anything…
Simple update to mention that v5 dropped IE11 support in #30377 — so logical properties might be a game changer alongside custom properties.
Discussion of this approach and other approaches to tackle RTL is now in #30918
Most helpful comment
FWIW, we're using rtlcss in our own fork Boosted to output another
distfile.However it still requires a few overrides, which we basically push to the RTL file.
Our script looks like this:
rtlcss dist/css/boosted.css dist/css/boosted-rtl.css && shx cat dist/css/o-rtl.css >> dist/css/boosted-rtl.css. This is probably not the best way, but at least it works and we can provide some help with it.Also, if the targetted version is v5 and if dropping support for IE11 is considered, using logical properties and values everywhere possible could help a lot with RTL, without doing anything…