Use CSS Logical Properties and Values for Styling #13619
Labels
adopter: strategic-product
Work-stream that directly effects the Product-led Growth initiative.
proposal: accepted
This request has gone through triaging and we are accepting PR's against it.
role: dev 🤖
type: bidi ↔️
type: enhancement 💡
Milestone
The problem
Component styling currently uses typical properties for positioning and sizing, things like margin-top, padding-left, border-right, etc.
These properties are static and are not impacted by the writing mode. When a page is rendered in
rtl
, padding-left does not automatically become padding-right. It is static on the left.Due to this, we currently recommend that applications using Carbon with a requirement to support
rtl
mode use a postprocessor like RTLCSS. RTLCSS converts these static properties into their logical inverse property forrtl
mode(padding-left
becomespadding-right
). The output stylesheet can then be loaded when the document is inrtl
mode and override the default styles provided by Carbon.We do not have RTLCSS as part of the pipeline within the monorepo. This means that if we were to alter the writing mode in the storybook canvas, the components would not have appropriate styling to be rendered correctly.
The solution
We should instead use Logical Properties and Values to specify styling that will be impacted by the writing mode.
From the MDN docs:
In effect, this means that we can specify things like padding, margin, text-alignment, etc. to be dependent on the writing mode rather than static right/left/top/bottom values.
Examples
Here's an example from this excellent article on the topic. It does a much better job of explaining all the facets of this than I can do here, please read.
Tasks
With this mapping I think we could get most (all?) of the way there in a single sprint https://github.com/csstools/stylelint-use-logical#property-and-value-mapping
The text was updated successfully, but these errors were encountered: