
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
postcss-rtl-logical-properties
Advanced tools
This plugin is a PostCSS plugin that replaces supported horizontal direction properties (LTR/RTL) with logical CSS properties (start/end) to add RTL support.
This plugin is a PostCSS plugin that replaces supported horizontal direction properties (LTR/RTL) with logical CSS properties (start/end) to add RTL support.
The following properties are supported by this plugin:
Padding
PaddingLeft
PaddingRight
Margin
MarginLeft
MarginRight
BorderRight
BorderLeft
BorderLeftWidth
BorderLeftColor
BorderRightWidth
BorderRightColor
BorderLeftStyle
BorderRightStyle
BorderBottomLeftRadius
BorderBottomRightRadius
BorderTopLeftRadius
BorderTopRightRadius
Left
Right
Float
Clear
TextAlight
This plugin does not replace other plugins such as rtlcss - it should be included in your PostCSS plugins before others to replace direction properties with logical properties in the first place. By replacing direction properties with logical properties, this plugin helps to reduce the final weight of the CSS file and cover almost 80% of the standard properties.
To use this plugin, you will need to have PostCSS installed. Then, you can install postcss-rtl-logical-properties
via npm:
npm install postcss-rtl-logical-properties
Then, you can use it in your PostCSS configuration file:
const postcssRtlLogicalProperties = require('postcss-rtl-logical-properties');
module.exports = {
plugins: [
postcssRtlLogicalProperties()
]
}
or use with rtlcss
const postcssRtlLogicalProperties = require('postcss-rtl-logical-properties');
var rtlcss = require('rtlcss');
const postcss = require('postcss');
const result = postcss([
postcssRtlLogicalProperties(),
rtlcss(),
]).process(`
.test {
padding-left: 10px;
border-right: 20px;
margin: 10px 1px 10px 29px;
transform: translateX(50%)
}
`);
console.log(result.css);
/*
.test {
padding-inline-start: 10px;
border-inline-end: 20px;
margin-block: 10px;
margin-inline: 29px 1px;
transform: translateX(-50%)
}
*/
use with postcss-rtl
const postcssRtlLogicalProperties = require('postcss-rtl-logical-properties');
const postcssRTL = require('postcss-rtl');
const result = postcss([
postcssRtlLogicalProperties(),
postcssRTL({
blacklist: postcssRtlLogicalProperties.ignoreDeclarationList
})
]).process(`
.test {
padding-left: 10px;
border-right: 20px;
margin: 10px 1px 10px 29px;
transform: translateX(50%)
}
`);
console.log(result.css);
/*
.test {
padding-inline-start: 10px;
border-inline-end: 20px;
margin-block: 10px;
margin-inline: 29px 1px
}
[dir=ltr] .test {
transform: translateX(50%)
}
[dir=rtl] .test {
transform: translateX(-50%)
}
*/
ngx-build-plus
package,postcss
and postcss-loader in your angular project npm i postcss postcss-loader
webpack.transformer.js
to add postcss-loader
see documentationpostcss.config.js
to add this plugin// postcss.config.js
const autoprefixer = require('autoprefixer');
const postcssRtlLogicalProperties = require('postcss-rtl-logical-properties');
const postcssRTL = require('postcss-rtl');
module.exports = () => {
return {
plugins: [
postcssRtlLogicalProperties(),
autoprefixer(),
postcssRTL({
blacklist: postcssRtlLogicalProperties.ignoreDeclarationList,
addPrefixToSelector: (selector, prefix) => {
return `${prefix} ${selector}`;
}
})
]
}
}
hDirection
: This option allows you to change the standard direction from LTR to RTL (default: HorizontalDirection.LeftToRight
)
vDirection
: This option allows you to change the direction from TopToBottom to BottomToTop (default: VerticalDirection.TopToBottom
)
This plugin has good browser support and is worth using. According to Can I Use, global support is at 89.12%.
Note that this plugin does not support complex properties like transform or background-position, border-radius and others, for this you will still use rtlcss.
As you know, plugins such as postcss-rtlcss process all the properties that are responsible for the direction and generate their own selectors for different versions of LTR and RTL with the addition of the [DIR] attribute before the selector, why is that bad? - This generates duplicates and ultimately affects the size of the file.
postcss-rtl-logical-properties
- is a useful plugin for adding RTL support to your CSS, reducing the final file size and covering a majority of standard properties.
FAQs
This plugin is a PostCSS plugin that replaces supported horizontal direction properties (LTR/RTL) with logical CSS properties (start/end) to add RTL support.
The npm package postcss-rtl-logical-properties receives a total of 99 weekly downloads. As such, postcss-rtl-logical-properties popularity was classified as not popular.
We found that postcss-rtl-logical-properties demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.