Skip to content

Commit

Permalink
feat(layout): add nbLtr and nbRtl directives (#2927)
Browse files Browse the repository at this point in the history
  • Loading branch information
katebatura committed Nov 24, 2021
1 parent ad64fe2 commit 35a7ad1
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 154 deletions.
16 changes: 14 additions & 2 deletions docs/articles/usability/rtl.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Document direction could be set through the `NbThemeModule.forRoot` call. Suppor
]
})
```

Default value is `ltr`.

<div class="note note-info">
Expand All @@ -28,23 +29,34 @@ Default value is `ltr`.
</div>

To help you add RTL support to your custom components, Nebular provides you with two scss mixins: `nb-lrt` and `nb-rtl`. You can use them to alter values of css properties, which don't support logical values, like paddings, margins, etc. You can pass single property and value as arguments, pass multiple statements as the content of mixin or both. For example:

```scss
:host {
@include nb-ltr(padding-left, 1em);
@include nb-rtl(padding-right, 1em);
}
```

```scss
:host {
@include nb-ltr() {
padding-left: 1em;
};
}
@include nb-rtl() {
padding-right: 1em;
};
}
}
```

Please note, the mixins are only available within component `:host` selector or `nb-install-component()` mixin if used.

If you need to change direction dynamically, get current value or listen to changes of direction, Nebular provides `NbLayoutDirectionService`.

# Layout direction directives

Nebular provides `nbLtr` and `nbRlt` directives to show content based on the current direction.
For example, you could apply the `nbRtl` directive to the element you need to show only when layout direction is right-to-left add:

```html
<div *nbRtl>This text is visible only when layout direction is RTL</div>
```
Loading

0 comments on commit 35a7ad1

Please sign in to comment.