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

RTL and LTR


how to swap between RTL and LTR SCSS file
when I use LTR I should use part of SCSS and when I use RTL I should use different part of SCSS

in style.angular.scss using LTR
// Angular vendors
@import "~socicon/css/socicon.css";
@import "~@fortawesome/fontawesome-free/css/all.min.css";
@import "~line-awesome/dist/line-awesome/css/line-awesome.css";
@import "~prism-themes/themes/prism-shades-of-purple.css";
@import "~bootstrap-icons/font/bootstrap-icons.css";
@import "~animate.css/animate.css";
@import "./core/vendors/plugins/prismjs";
@import "./core/vendors/plugins/formvalidation";

in style.angular.scss using RTL without last two row from LTR the default
// Angular vendors
@import "~socicon/css/socicon.css";
@import "~@fortawesome/fontawesome-free/css/all.min.css";
@import "~line-awesome/dist/line-awesome/css/line-awesome.css";
@import "~prism-themes/themes/prism-shades-of-purple.css";
@import "~bootstrap-icons/font/bootstrap-icons.css";
@import "~animate.css/animate.css";
//@import "./core/vendors/plugins/prismjs";
//@import "./core/vendors/plugins/formvalidation";


and the same things in styles.scss file in RTL should i use last two rows and in the opposite way should i use different imports !
/* You can add global styles to this file, and also import other style files */
/*@import "./assets/sass/style.scss";*/
// Replace above style with this css file to enable RTL styles
// @import './assets/sass/plugins.scss';
@import "./assets/css/style.rtl.css";
@import "./assets/sass/style.angular.scss";

So how to reflect between this SCSS changes when i do change on the direction ??


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 (1)


Hi,

Currently, Angular does not provide built-in support for dynamically changing the CSS file based on the direction (LTR or RTL). In the provided styles.scss file, the LTR and RTL CSS files are included as hardcoded imports.

To handle dynamic direction changes, you would need to implement a custom solution. One possible approach is to create separate CSS files for LTR and RTL styles, and then conditionally load the appropriate file based on the direction.

Here's an example of how you can achieve this:


1. Create two separate SCSS files: style.ltr.scss and style.rtl.scss. Place the specific styles for each direction in their respective files.

2. In your component or application, define a class variable to keep track of the current direction. For example:

direction: string = "ltr"; // Default direction is LTR


3. In your component's template or in the root `app.component.html`, conditionally load the appropriate styles based on the direction variable:

<!-- Replace the default style import with conditional imports -->
<ng-container [ngSwitch]="direction">
<ng-container *ngSwitchCase=""ltr"">
<!-- Load LTR styles -->
<link rel="stylesheet" href="./assets/css/style.ltr.css">
<link rel="stylesheet" href="./assets/sass/style.angular.scss">
</ng-container>
<ng-container *ngSwitchCase=""rtl"">
<!-- Load RTL styles -->
<link rel="stylesheet" href="./assets/css/style.rtl.css">
<link rel="stylesheet" href="./assets/sass/style.angular.scss">
</ng-container>
</ng-container>


4. To change the direction dynamically, you can create a function that updates the direction variable based on user input or application logic. For example:

toggleDirection() {
this.direction = this.direction === "ltr" ? "rtl" : "ltr";
}


With this setup, when the direction variable is changed to `'ltr'`, the LTR styles will be loaded, and when it is changed to `'rtl'`, the RTL styles will be loaded. The corresponding SCSS files will be applied accordingly.

Remember to import the necessary SCSS files in your styles.scss file, including style.angular.scss, which contains the common styles for both directions.

Note: Make sure to adjust the file paths and imports according to your project structure.

If you have further questions or need clarification, feel free to ask.

Thanks


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  :(