How To Change Angular Material 2 direction To RTL

22.9k Views Asked by At

I Want Create RTL Template With Angular Material 2 But، I do not know How To Do This Work? Please Help Me;

5

There are 5 best solutions below

2
On BEST ANSWER

You should use rtl as attribute

dir='rtl'

Here is a plunker

Go to index.html , you'll find :

<body >
   <chips-overview-example dir="rtl">Loading Material Docs example...</chips-overview-example>
</body>
1
On

you should add attribute dir=rtl to <html> tag, Because angular material.js code using this document.dir to distinguish layout direction

0
On

Angular material uses the selector[dir=rtl] for some elements in its css, for example:

[dir=rtl] .mat-form-field {
   text-align: right;
}

Therefore consider adding dir=rtl attribute to your html tag:

<html dir="rtl">
0
On

if you wish to change All element's directions in website, Use the following style (called Universal selector) in your styles.css file.

* {
    direction: rtl;
  }
0
On

I have published a library that works well with material bi-direction solution by using scss mixins check it out:

https://github.com/10bis/ngx-bdir