Skip to content

feat: add dir prop for RTL support - #574

Merged
pradel merged 1 commit into
masterfrom
feat/dir-prop-rtl-support
Sep 24, 2026
Merged

pradel merged 1 commit into
masterfrom
feat/dir-prop-rtl-support

Conversation

@pradel

@pradel pradel commented Sep 24, 2026

Copy link
Copy Markdown
Owner

Closes #523.

Problem

The modal had no way to set a text direction. The component does not spread extra props, so consumers could not put dir on the modal DOM, and the built-in styles used physical properties (text-align: left, right: 14px) that ignore direction. Setting dir on <html>/<body> or using a custom container were the only workarounds.

Changes

  • New optional dir?: 'ltr' | 'rtl' | 'auto' prop, applied to the modal root element so the whole modal inherits the direction.

  • Built-in styles are now direction aware:

    • .react-responsive-modal-modal: text-align: left → text-align: start
    • .react-responsive-modal-closeButton: right: 14px → inset-inline-end: 14px

    Both are identical in LTR and flip correctly in RTL.

  • Documented the prop in the website props table.

  • Added tests covering the dir attribute being set and absent by default.

Notes

The CSS flip is not covered by jsdom tests. Happy to add an RTL example page and a Cypress assertion against real computed styles if you want that covered in a browser.

Allow consumers to set the text direction of the modal content with a
new dir prop, and make the built-in styles direction aware so the
close button and text alignment flip correctly in RTL.

Closes #523
@codecov

codecov Bot commented Sep 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.40%. Comparing base (7765f69) to head (6d3028a).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #574   +/-   ##
=======================================
  Coverage   80.40%   80.40%           
=======================================
  Files           7        7           
  Lines         199      199           
  Branches       73       73           
=======================================
  Hits          160      160           
  Misses         29       29           
  Partials       10       10           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pradel
pradel merged commit 070a1f6 into master Sep 24, 2026
3 checks passed
@pradel
pradel deleted the feat/dir-prop-rtl-support branch September 24, 2026 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for Custom HTML Direction Attributes in React Responsive Modal

1 participant