You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 13, 2025. It is now read-only.
Simply `@import "@material/rtl/mixins";` and start using the mixins. Each mixin is described below.
29
+
### Sass Mixins
32
30
33
-
### mdc-rtl
31
+
`mdc-rtl` is the most flexible mixin, because it can work with multiple CSS properties. All other RTL mixins logic could be engineered by only using `mdc-rtl`, but we provide these mixins for convenience.
34
32
35
-
```scss
36
-
@mixinmdc-rtl($root-selector: null)
37
-
```
38
-
39
-
Creates a rule that will be applied when an MDC-Web component is within the context of an RTL layout.
40
-
41
-
Usage Example:
42
-
43
-
```scss
44
-
.mdc-foo {
45
-
position: absolute;
46
-
left: 0;
33
+
Both `mdc-rtl-reflexive-property` and `mdc-rtl-reflexive-box` work with one base box-model property, e.g. margin, border, padding. But `mdc-rtl-reflexive-property` is more flexible because it accepts different left and right values. `mdc-rtl-reflexive-box` assumes the left and right values are the same, and therefore that the box-model is symmetrical.
47
34
48
-
@includemdc-rtl {
49
-
left: auto;
50
-
right: 0;
51
-
}
35
+
`mdc-rtl-reflexive-position` is the least flexible mixin. It only works with one horizontal position property, "left" or "right". It also assumes the left and right values are the same.
|`mdc-rtl($root-selector)`| Creates a rule that is applied when the root element is within an RTL context |
40
+
|`mdc-rtl-reflexive-box($base-property, $default-direction, $value, $root-selector)`| Applies the value to the `#{$base-property}-#{$default-direction}` property in a LTR context, and flips the direction in an RTL context. **This mixin zeros out the original value in an RTL context.**|
41
+
|`mdc-rtl-reflexive-property($base-property, $left-value, $right-value, $root-selector)`| Emits rules that assign `#{$base-property}`-left to `#{left-value}` and `#{base-property}`-right to `#{right-value}` in a LTR context, and vice versa in a RTL context. **Basically it flips values between a LTR and RTL context.**|
42
+
|`mdc-rtl-reflexive-position($position-property, $value, $root-selector)`| Applies the value to the specified position in a LTR context, and flips the direction in an RTL context. `$position-property` is a horizontal position, either "left" or "right". |
**N.B.**: checking for `[dir="rtl"]` on an ancestor element works in most cases, it will sometimes
100
-
lead to false negatives for more complex layouts, e.g.
44
+
**A note about [dir="rtl"]**: `mdc-rtl($root-selector)` checks for `[dir="rtl"]` on the ancestor element. This works in most cases, it will sometimes lead to false negatives for more complex layouts, e.g.
101
45
102
46
```html
103
47
<htmldir="rtl">
@@ -108,129 +52,4 @@ lead to false negatives for more complex layouts, e.g.
108
52
</html>
109
53
```
110
54
111
-
Unfortunately, we've found that this is the best we can do for now. In the future, selectors such
112
-
as [:dir](http://mdn.io/:dir) will help us mitigate this.
Takes an argument specifying a horizontal position property (either "left" or "right") as well
210
-
as a value, and applies that value to the specified position in a LTR context, and flips it in a
211
-
RTL context.
212
-
213
-
For example:
214
-
215
-
```scss
216
-
.mdc-foo {
217
-
@includemdc-rtl-reflexive-position(left, 0);
218
-
position: absolute;
219
-
}
220
-
```
221
-
is equivalent to:
222
-
223
-
```scss
224
-
.mdc-foo {
225
-
position: absolute;
226
-
left: 0;
227
-
right: initial;
228
-
229
-
@includemdc-rtl {
230
-
right: 0;
231
-
left: initial;
232
-
}
233
-
}
234
-
```
235
-
236
-
An optional third `$root-selector` argument may also be given, which is passed to `mdc-rtl`.
55
+
Unfortunately, we've found that this is the best we can do for now. In the future, selectors such as [:dir](http://mdn.io/:dir) will help us mitigate this.
0 commit comments