Get 2024 Templates Mega Bundle!14 Bootstrap, Vue & React Templates + 3 Vector Sets
Get for 99$

React RTL version setup - updated



  1. Install webpack-rtl-plugin and remove-files-webpack-plugin using command: npm install --save-dev webpack-rtl-plugin remove-files-webpack-plugin

  2. Copy the webpack configuration from this gist and paste it into rtl.config.js in the demo root folder.

  3. Execute the command yarn webpack --config=rtl.config.js --mode development. This command will execute the webpack configuration to build styles and output them to the assets/rtl folder.

  4. In file src/index.tsx, replace the LRT style import with RTL style import from assets/rtl:

    import "./_metronic/assets/sass/style.scss"

    to


    import "./_metronic/assets/rtl/style.rtl.css"


  5. In the file public/index.html, on HTML tag add direction="rtl", dir="rtl" and style attribute with value direction: rtl.

  6. Find and replace the following attributes in the project:

    • data-kt-menu-placement='bottom-start' => data-kt-menu-placement='bottom-end'

    • data-kt-menu-placement='right-start' => data-kt-menu-placement='left-start'



  7. In the file src/_metronic/layout/components/header/MenuInnerWithSub.tsx, add the type 'left-start' to the 'menuPlacement' property: menuPlacement?: 'right-start' | 'bottom-start' | 'left-start'.

  8. In the file src/_metronic/layout/components/header/MenuInner.tsx, update all occurrences of 'right-start' to 'left-start'.


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (3)


Thanks for the info.. If I am using rtl and ltr languages in one project. How can I keep both css files. then based on the selected language the ltr or rtl is loaded with the changes you explained above.

I would appreciate your help on this.

Thanks,
Abdullah



Hi Abdullah,

Unfortunately, dynamic direction switching is currently not supported by Metronic SPA versions.

The only way to change the direction dynamically in our React version is by updating the link href of the main style file. To achieve this, follow the steps below:


  1. Generate RTL and LTR CSS style files using our HTML version.
    To generate styles, refer to our gulp build and rtl version setup docs.

  2. Copy the generated style.bundle.css and style.bundle.rtl.css files to public folder in your React app.

  3. In the public/index.html file, add link tag with default direction styles as shown in this gist file.

  4. Remove the style import line below from src/index.tsx:

    import "./_metronic/assets/sass/style.scss"


  5. To switch the direction, you just need to change the link href from style.bundle.css to style.bundle.rtl.css.
    You can reuse switch functions from this gist.



Regards,
Lauris Stepanovs,
Keenthemes Support Team

Appreciate your help.

Thanks,
Abdullah


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(