Introduction
Manage content direction for languages right-to-left.
Install
npm install @sass-collective/direction --save
Usage
Mixin
direction($direction: right, $root-selector: null);
Options
Names | Default | Values |
---|
$direction | right | left or right |
$root-selector | null | Class, ID or HTML element. |
Module System
@use "@sass-collective/direction";
p {
margin-left: 20px;
margin-right: 0;
@include direction.direction {
margin-left: 0;
margin-right: 20px;
}
@include direction.direction(left) {
margin-left: 0;
margin-right: 20px;
}
@include direction.direction($root-selector: div) {
margin-left: 0;
margin-right: 20px;
}
}
Legacy @import
@import "@sass-collective/direction";
p {
margin-left: 20px;
margin-right: 0;
@include sass-direction {
margin-left: 0;
margin-right: 20px;
}
@include sass-direction(left) {
margin-left: 0;
margin-right: 20px;
}
@include sass-direction($root-selector: div) {
margin-left: 0;
margin-right: 20px;
}
}
CSS
p {
margin-left: 20px;
margin-right: 0;
}
[dir="rtl"] p {
margin-left: 0;
margin-right: 20px;
}
[dir="ltr"] p {
margin-left: 0;
margin-right: 20px;
}
[dir="rtl"] div p {
margin-left: 0;
margin-right: 20px;
}