CSS for RTL Languages

When your Language setting in Salesforce is set to a right-to-left (RTL) language, the framework automatically flips property names, such as left and border-left to right and border-right respectively. The framework also rearranges certain values like padding, margin, and border-radius so that the right and left units are swapped.

Flipped CSS Properties 

These properties are automatically flipped for RTL languages.

PropertyFlipped Property
leftright
rightleft
border-leftborder-right
border-left-colorborder-right-color
border-left-styleborder-right-style
border-left-widthborder-right-width
border-rightborder-left
border-right-colorborder-left-color
border-right-styleborder-left-style
border-right-widthborder-left-width
border-top-left-radiusborder-top-right-radius
border-top-right-radiusborder-top-left-radius
border-bottom-left-radiusborder-bottom-right-radius
border-bottom-right-radiusborder-bottom-left-radius
padding-leftpadding-right
padding-rightpadding-left
margin-leftmargin-right
margin-rightmargin-left
nav-leftnav-right
nav-rightnav-left

Flipped CSS Keywords 

These keywords are automatically flipped for RTL languages.

KeywordFlipped Keyword
ltrrtl
rtlltr
leftright
rightleft
e-resizew-resize
w-resizee-resize
ne-resizenw-resize
nw-resizene-resize
nesw-resizenwse-resize
nwse-resizenesw-resize
se-resizesw-resize
sw-resizese-resize

Flipped CSS Percentage Values 

If the value is a percentage for these properties, the flipped value is set to 100 minus the value.

  • background
  • background-position
  • background-position-x

Flipped Property Arguments 

For these properties that can take four values, the second and fourth values are swapped. For example, property: A B C D becomes property: A D C B.

  • padding
  • margin
  • border-color
  • border-style
  • border-width

Flipped border-radius Arguments 

The arguments for the border-radius property are flipped with these patterns.

ArgumentsFlipped Arguments
border-radius: A Bborder-radius: B A
border-radius: A B Cborder-radius: B A C
border-radius: A B C Dborder-radius: B A D C

Override Flipping With @noflip 

To override the automatic flipping, add a /*@noflip*/ annotation in a comment directly before the property. For example:

1.THIS.mycontainer {
2    /*@noflip*/ direction : rtl;
3}

Use Conditional CSS 

Use the @if(isRTL) conditional statement to manually provide the appropriately oriented CSS for each direction.

1.THIS {
2    transform: skew(28deg) translate3d(0, 0 , 0);
3}
4
5@if(isRTL) {
6    .THIS {
7        transform: skew(-28deg) translate3d(0, 0 , 0);
8    }
9}

See Also