npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ngx-bidi

v1.0.18

Published

Angular LTR/RTL direction handler with SCSS utilities

Readme

ngx-bidi

npm version npm downloads GitHub stars Coverage

📦 Install from npm

ngx-bidi is an Angular(^20.0.0) library for managing text direction (LTR / RTL) automatically based on selected language or manual control.

It supports:

  • Automatic direction switching via directive
  • Full programmatic control using NgxBidiService
  • SCSS mixins for RTL/LTR styles
  • Angular module and standalone usage

Installation

npm install ngx-bidi

Usage

1. Import as Angular module

Use this if you want the directive available in a module:

import { NgxBidiModule } from 'ngx-bidi';

@NgModule({
  imports: [NgxBidiModule]
})
export class AppModule {}

2. Use as standalone directive

If your component is standalone:

import { NgxBidiDirective } from 'ngx-bidi';

@Component({
  standalone: true,
  selector: 'app-example',
  template: `<div dirAuto>...</div>`,
  imports: [NgxBidiDirective],
})
export class ExampleComponent {}

3. Use only the service

If you only need direction logic without binding to HTML:

import { NgxBidiService } from 'ngx-bidi';

constructor(private dir: NgxBidiService) {}

ngOnInit() {
  this.dir.setLang('ar');   // rtl
  this.dir.setDir('ltr');   // override
}

Subscribe to changes:

this.dir.getDir$().subscribe(dir => console.log(dir));

Opposite direction:

this.dir.getOppositeDir$().subscribe(dir => console.log(dir));

Directive usage

Auto-detect direction:

<div dirAuto>Text</div>

Force direction:

<div dirAuto="rtl">RTL block</div>
<div dirAuto="ltr">LTR block</div>

Styles (SCSS utilities)

Import SCSS helpers:

@use 'ngx-bidi/scss' as dir;

Available Mixins

All mixins support ViewEncapsulation via optional $use-host-context parameter (defaults to true for component styles).

Direction Wrappers

  • dir-ltr($use-host-context: true) - Apply styles only for LTR direction
  • dir-rtl($use-host-context: true) - Apply styles only for RTL direction
  • dir($value, $use-host-context: true) - Apply styles for specific direction (ltr/rtl)

Padding & Margin

  • padding-start($value, $use-host-context: true) - Padding on start side (right in LTR, left in RTL)
  • padding-end($value, $use-host-context: true) - Padding on end side (left in LTR, right in RTL)
  • margin-start($value, $use-host-context: true) - Margin on start side (right in LTR, left in RTL)
  • margin-end($value, $use-host-context: true) - Margin on end side (left in LTR, right in RTL)

Float & Clear

  • float($pos, $use-host-context: true) - Float element to start or end (start or end)

Position

  • left($value, $use-host-context: true) - Left position (right in RTL)
  • right($value, $use-host-context: true) - Right position (left in RTL)

Text Alignment

  • text-align-start($use-host-context: true) - Align text to start (left in LTR, right in RTL)
  • text-align-end($use-host-context: true) - Align text to end (right in LTR, left in RTL)

Transforms

  • transformTranslate($x, $y: 0, $use-host-context: true) - Translate with X-axis inversion for RTL
  • transformScale($x, $y: 1, $use-host-context: true) - Scale with X-axis mirroring for RTL
  • mirror($use-host-context: true) - Full horizontal mirroring for RTL

Generic Property Helpers

  • start($property, $value, $use-host-context: true) - Apply any property to start side
  • end($property, $value, $use-host-context: true) - Apply any property to end side

Using in components (with ViewEncapsulation)

If you're using mixins inside Angular components with ViewEncapsulation, the $use-host-context parameter defaults to true:

:host {
  .button {
    @include dir.padding-start(20px); // Uses :host-context by default
  }
}

For global styles, you can pass false:

.button {
  @include dir.padding-start(20px, false); // Uses [dir] selector
}

RTL Languages

RTL is automatically enabled for:

['ar', 'he', 'fa', 'dv', 'ku', 'ur', 'ps']

License

MIT