Kosmesis
Components

Direction

Sets the ambient text direction (ltr/rtl) via the native dir attribute. Purely presentational.

Installation

npx kosmesis add direction
pnpm dlx kosmesis add direction
yarn dlx kosmesis add direction
bunx kosmesis add direction

Copy and paste the following code into your project.

direction.tsx
import { StatelessComponent } from "@praxisjs/core";import { Component } from "@praxisjs/decorators";import type { Children } from "@praxisjs/shared";export type TextDirection = "ltr" | "rtl";export interface DirectionProviderProps {  dir: TextDirection;  children?: Children;}/** * shadcn/ui's `DirectionProvider` relies on React Context so every descendant primitive can read * the ambient text direction without prop-drilling it. PraxisJS/Morphos have no context system — * the honest equivalent here is a plain element setting the native `dir` attribute, which the * browser (and every Morphos component's own CSS-selector-driven styling) already respects for * free via `:dir(rtl)`/`[dir="rtl"]` without any JS reading it back out. * * If a specific component needs its *behavior* (not just layout) to change per-direction (e.g. * which arrow key moves "forward" in `Tabs`), pass `dir` to that component directly — Morphos's * `orientation`-driven components already expose the primitives needed to compose that yourself. */@Component()export class DirectionProvider extends StatelessComponent<DirectionProviderProps> {  render() {    const { dir, children } = this.props;    return <div dir={dir}>{children}</div>;  }}

Install the following dependencies:

npm install @praxisjs/css
pnpm add @praxisjs/css
yarn add @praxisjs/css
bun add @praxisjs/css

Copy and paste the following code into your project.

direction.tsx
import { StatelessComponent } from "@praxisjs/core";import { Component } from "@praxisjs/decorators";import type { Children } from "@praxisjs/shared";export type TextDirection = "ltr" | "rtl";export interface DirectionProviderProps {  dir: TextDirection;  children?: Children;}/** * shadcn/ui's `DirectionProvider` relies on React Context so every descendant primitive can read * the ambient text direction without prop-drilling it. PraxisJS/Morphos have no context system — * the honest equivalent here is a plain element setting the native `dir` attribute, which the * browser (and every Morphos component's own CSS-selector-driven styling) already respects for * free via `:dir(rtl)`/`[dir="rtl"]` without any JS reading it back out. No styling of its own, * so this file is identical in both style systems. * * If a specific component needs its *behavior* (not just layout) to change per-direction (e.g. * which arrow key moves "forward" in `Tabs`), pass `dir` to that component directly — Morphos's * `orientation`-driven components already expose the primitives needed to compose that yourself. */@Component()export class DirectionProvider extends StatelessComponent<DirectionProviderProps> {  render() {    const { dir, children } = this.props;    return <div dir={dir}>{children}</div>;  }}

Examples

Usage

import { DirectionProvider } from "@/components/ui/direction";

<DirectionProvider dir="rtl">
  <YourApp />
</DirectionProvider>

shadcn/ui's DirectionProvider relies on React Context so every descendant primitive reads the ambient direction. PraxisJS/Morphos have no context system, so this is a plain element setting the native dir attribute — the browser (and Morphos's own CSS-selector-driven styling) already respects it via :dir(rtl)/[dir="rtl"] for free. If a component's behavior (not just layout) needs to flip per-direction, pass orientation/side props to that component directly.

Props

DirectionProvider

PropTypeDefault
dir"ltr" | "rtl"— required

On this page