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;}// PraxisJS/Morphos have no context system, so this just sets the native `dir` attribute — the// browser and every Morphos component's CSS already respect it via `:dir(rtl)`/`[dir="rtl"]`.@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;}// PraxisJS/Morphos have no context system, so this just sets the native `dir` attribute — the// browser and every Morphos component's CSS already respect it via `:dir(rtl)`/`[dir="rtl"]`.@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>

PraxisJS/Morphos have no context system, so DirectionProvider 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