Description
Summary
To improve support for right-to-left (RTL) languages like Hebrew and Arabic, we propose replacing physical direction values ("left"
and "right"
) with logical equivalents ("start"
and "end"
) across our components. This aligns with modern CSS practices, specifically the use of CSS Logical Properties and Values, and enhances consistency in our component APIs.
Problem Statement
Our components currently use physical direction values ("left"
and "right"
) to specify the alignment of text or indicators (e.g., checkboxes, radio buttons) relative to labels. These values become confusing in RTL languages, where layout directions are reversed.
We also have an Alignment
type shared across components, but its valid values differ. For example:
- In
<Button>
, thealignText
prop accepts"left"
,"right"
, or"center"
. - In
<Checkbox>
, thealignIndicator
prop uses the sameAlignment
type but only"left"
or"right"
are valid. Passing"center"
has no effect since center alignment isn't applicable for the indicator on checkbox.
This inconsistency can lead to confusion and unexpected behavior.
Proposal
We propose the following changes:
- Expand
Alignment
to include logical direction values
// Current
type Alignment = "center" | "left" | "right";
// Updated
type Alignment = "center" | "left" | "right" | "start" | "end";
- Map
"start"
and"end"
to existing implementations
"start"
maps toClasses.ALIGN_LEFT
."end"
maps toClasses.ALIGN_RIGHT
.
This mapping currently occurs via Classes.alignmentClass(...)
- Deprecate physical direction values
- Mark
"left"
and"right"
as deprecated in all components usingAlignment
. - Provide deprecation warnings in development mode.
- Update documentation to promote
"start"
and"end"
.
- Introduce a new
TextAlignment
type
type TextAlignment = "center" | "start" | "end";
Use TextAlignment
in <Button>
and <ButtonGroup>
components for text alignment, separating it from Alignment
used in other components where "center"
isn't valid.
- Future: Remove physical values and update class names
In a future major version:
- Remove
"left"
,"right"
, and"center"
values fromAlignment
, leaving only"start"
and"end"
.
// Before
type Alignment = "center" | "left" | "right" | "start" | "end";
// After
type Alignment = "start" | "end"
- Update class names:
Classes.ALIGN_LEFT
→Classes.ALIGN_START
Classes.ALIGN_RIGHT
→Classes.ALIGN_END
- Replace
Alignment
type withTextAlignment
in<Button>
and<ButtonGroup>
.
Plan of Action
Phase 1: Immediate Changes
- Add
"start"
and"end"
toAlignment
. - Introduce
TextAlignment
. - Deprecate
"left"
and"right"
in components usingAlignment
and add deprecation warnings in development mode. - Revise documentation and examples to use
"start"
and"end"
. - Include clear migration guidelines in release notes.
- Provide a codemod script to automate the replacement of
"left"
/"right"
with"start"
/"end"
in existing codebases.
Phase 2: Future Breaking Changes
- Remove
"left"
and"right"
, and"center"
values fromAlignment
. - Rename CSS classes and use logical CSS properties in implementation:
Classes.ALIGN_LEFT
→Classes.ALIGN_START
Classes.ALIGN_RIGHT
→Classes.ALIGN_END
- Replace
Alignment
type withTextAlignment
in<Button>
and<ButtonGroup>
components.
These changes will constitute a breaking change and be scheduled for a major version update.
Affected Components
<AnchorButton>
<Button>
<ButtonGroup>
<Checkbox>
<CheckboxCard>
<NavbarGroup>
<Radio>
<RadioCard>
<Switch>
<SwitchCard>
References
Metadata
Metadata
Assignees
Type
Projects
Status