Skip to content

chore: add RTL support for @asgardeo/react & @asgardeo/nextjs UI components #144

@brionmario

Description

@brionmario

Current Limitation

Add Right-to-Left (RTL) language support to the @asgardeo/react & @asgardeo/nextjs components to ensure proper internationalization for Arabic, Hebrew, and other RTL languages.

Current State:

  • Components use LTR (Left-to-Right) layout assumptions
  • No RTL-specific styling or layout adjustments
  • Text direction not handled for RTL languages
  • Icons and UI elements positioned for LTR only

Missing RTL Features:

  • CSS logical properties not used (margin-left vs margin-inline-start)
  • No dir="rtl" attribute handling
  • Icons and arrows don't flip for RTL contexts
  • Dropdown positioning assumes LTR layout
  • Modal and popup positioning needs RTL consideration

Suggested Improvement

Implementation Plan

1. CSS Logical Properties

Replace physical properties with logical equivalents:

/* Before */
margin-left: 16px;
text-align: left;

/* After */
margin-inline-start: 16px;
text-align: start;

2. RTL Detection Hook

// Custom hook for RTL detection
const useRTL = () => {
  const isRTL = document.dir === 'rtl' || 
               document.documentElement.dir === 'rtl';
  return { isRTL };
};

3. Icon and Arrow Flipping

  • Add transform: scaleX(-1) for directional icons in RTL
  • Update arrow directions in dropdowns and navigation
  • Flip chevron icons appropriately

4. Component Updates

OrganizationSwitcher:

  • Dropdown positioning for RTL
  • Icon alignment adjustments
  • Menu item layout

Modal Components:

  • Positioning and alignment
  • Close button placement
  • Content flow direction

5. Testing

// RTL testing with Vitest
test('renders correctly in RTL mode', () => {
  document.dir = 'rtl';
  render(<OrganizationSwitcher />);
  // Test RTL-specific behavior
});

Files to Update

  • CSS/styled-components in all React components
  • OrganizationSwitcher and related modal components
  • Icon components for directional flipping
  • Add RTL detection utilities
  • Update Storybook stories with RTL variants
  • Add RTL-specific tests

Please select the package issue is related to

@asgardeo/react, @asgardeo/nextjs

Version

current

Reporter Checklist

  • I have searched the existing issues and this is not a duplicate.
  • I have provided all the necessary information.
  • I have verified the improvement is not available in the latest version of the package.

Metadata

Metadata

Assignees

Labels

@asgardeo/nextjsIssues related to the `Next.js` wrapper of Asgardeo JavaScript SDK@asgardeo/reactIssues related to the `React.js` wrapper of Asgardeo JavaScript SDKComplexity/MediumIssues with the implementation complexity flagged as `Medium`Credits/30HacktoberfestOpen for Hacktoberfest contributors.Type/ImprovementaccessibilityIssues related to accessibility compliancegood first issueGood for newcomers

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions