Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Change Angular Material 2 direction To RTL

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

like image 504
Soheil Alizadeh Avatar asked Dec 24 '16 10:12

Soheil Alizadeh


People also ask

How to change RTL in Angular?

Right To Left (RTL) can be enabled for Syncfusion Angular UI components by calling enableRtl with true . This will render all the Syncfusion Angular UI components in right to left direction. We can enable the feature by setting the property enableRtl value as true.

How do you layout angular materials?

Layout Directiverow − Items are arranged horizontally with max-height = 100% and max-width is the width of the items in the container. column − Items are arranged vertically with max-width = 100% and max-height is the height of the items in the container.


5 Answers

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>
like image 179
Milad Avatar answered Sep 17 '22 19:09

Milad


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

like image 21
Mhd Wael Jazmati Avatar answered Sep 18 '22 19:09

Mhd Wael Jazmati


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;
  }
like image 35
Rzassar Avatar answered Sep 19 '22 19:09

Rzassar


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

like image 28
itay oded Avatar answered Sep 19 '22 19:09

itay oded


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">
like image 23
Rafi Henig Avatar answered Sep 18 '22 19:09

Rafi Henig