Your next page is taking shape...

Opening Your Next Page…

Loading the guide and preparing its examples for you to explore. The page will appear here automatically when it’s ready, so you can keep this view open without refreshing.

Made for Preact. Built to be yours.

Composition & Layout

Direction

Text direction context for RTL/LTR — `DirectionProvider` (shadcn API) plus legacy `Direction` with `dir`, and `useDirection()` hook. Build a clear hierarchy with reusable structure, consistent spacing and semantic surfaces. Keep layout decisions close to the content they organize. Import it from @/components/kamod-ui/direction.

Source · API reference · Theming · Styles


Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Installation

Import DirectionProvider, Direction, and useDirection from @/components/kamod-ui/direction (no Radix package required).

Install PackagesTerminal
pnpm add @kamod-ch/ui

Copy an example with @kamod-ch/ui or the matching @kamod-ch/ui/… subpath. The code block switches between those two installs. Connect The Global Theme CSS and Tailwind Source Detection before your first render.

Usage

Wrap subtrees that need explicit direction. Combine with dir on <html> for full-page RTL. Use logical Tailwind utilities (ms-*, me-*, ps-*, pe-*) so layouts flip automatically.

Import SetupTypeScript
import { Direction } from "@kamod-ch/ui";

Choose a complete composition from the examples below; required child components and props vary by pattern.

Component Examples & Variants

Explore Direction in Different Contexts, from the starting pattern to the compositions below. Begin with DirectionProvider, then compare the examples that match your content, state and layout. These are working patterns to adapt, not a list of interchangeable variant values: check the API Reference before using a prop or combining behaviors. Look at the surrounding labels, supporting text and spacing as well as the component itself.

Read the Result and Its Implementation Together. Use each showcase’s Code view to inspect imports and composition, or its Prompt view to prepare a setup or adaptation brief. Try the narrow preview and local theme controls before connecting real data, and use Reset to return an example to its initial state. Keep layout changes in class utilities where appropriate; follow the Component Styles Guide for hierarchy and the Theming Guide for shared surfaces and colors. The Accessibility Notes explain what to preserve when making those changes.

DirectionProvider

Keep Direction Available to Nested Components. Set the direction prop on DirectionProvider to share the reading direction with descendants. The provider also renders a div with dir, connecting component context to the browser's ordinary layout direction.

Place it around the relevant application region and verify portaled overlays too; a correctly mirrored trigger is not enough if its popup still uses another direction.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Direction (Dir)

Use the Legacy Spelling Consistently Where It Already Exists. The legacy dir prop supplies the same directional value through DirectionProvider. Use this example when maintaining an existing composition, and keep one consistent convention across new code rather than passing competing direction values.

For new compositions, compare DirectionProvider and avoid nesting contradictory direction settings that make child behavior difficult to predict.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

useDirection

Read Direction When Behavior Must Adapt. Read the current direction from the provider inside a descendant when its behavior depends on reading order. This is useful for directional symbols or positioning decisions that cannot be expressed through logical CSS alone.

Prefer logical CSS for ordinary spacing, and avoid copying the direction into unrelated state that can become stale when the language changes.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Document + Provider

Align document flow with component context. Set dir on the document's html element for the overall language direction, then keep DirectionProvider in agreement. Components that read context and UI rendered through portals should receive the same directional intent.

Update both from the same locale decision and test overlays, navigation and mixed-direction content rather than validating only a single text block.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width
API reference

Props and Data

Configure Direction using the contracts below. Read the documented options alongside the Source Definitions to understand which values your application supplies and which details the component owns. Start with a prop or helper, then follow its type link to inspect the declaration without leaving the page.

Props, slots and variants for this component.

API reference
Your API, from source

Type cards are extracted from this checkout’s TypeScript source at build time. Props inherited through HTMLAttributes, Omit or variant helpers remain references in those declarations; their fields are not flattened here. Match the reference to your installed version, and check a package’s exports before writing an import type. A type exported by a source file is not necessarily re-exported by @kamod-ch/ui.

Component Props

Read each option with its owning component. The
marker identifies required fields verified in that declaration. A ? means a field can be omitted; it does not promise a fallback value. Existing documented defaults remain alongside the descriptions. For callbacks, check the argument and return types before connecting your own state or services.
@kamod-ch/ui/direction1.4 KB min · 0.5 KB gzipSignals: none

Direction

DirectionProps

Direction documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildDirectionProps

Configure children for Direction. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
data-slot
stringDirectionProps

Configure data-slot for Direction. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
dir
DirectionValueDirectionProps

Kamod legacy prop — same as `direction` on `DirectionProvider`.

Default
"ltr"

DirectionProvider

DirectionProviderProps

DirectionProvider documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildDirectionProviderProps

Configure children for DirectionProvider. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
class
string | SignalLike<string | undefined>DirectionProviderProps

Configure class for DirectionProvider. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
data-slot
stringDirectionProviderProps

Configure data-slot for DirectionProvider. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
direction
DirectionValueDirectionProviderProps

Text direction for the subtree — matches shadcn `DirectionProvider` (`direction` prop).

Default
"ltr"

Data Type Reference

Expand a card to inspect and copy the exact declaration. The code header identifies its repository file; follow imported or inherited types in the Implementation Source when you need the complete dependency chain. Required-field summaries cover fields declared directly in that type. Source-only helpers and inferred schema outputs describe the local implementation, not additional props you can pass to every component.

DirectionValue

Declaration
DirectionValue
Exported Source Declaration from Direction.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DirectionValue before adapting it.

DirectionProvider Props

3 declared fields
DirectionProviderProps
Exported Source Declaration from Direction.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DirectionProviderProps before adapting it.

Direction Props

1 declared field
DirectionProps
Exported Source Declaration from Direction.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DirectionProps before adapting it.

Accessibility

Direction supplies direction context for components that consume it. A context value alone does not translate text or set the document's language. HTML direction and locale-specific content still need deliberate application configuration.

Take the Next Useful Step

You have the pieces. Put them into one real interaction, keep its state in one place, and check the result with the content your application will actually show.

Connect the Foundation

Return to Choose and Compose Components to connect this reference to a working screen. Keep global CSS in one entrypoint and import only the components that screen needs.

Build the Surrounding Screen

Find a neighboring interaction in the Component Library, or start with a complete Block. Replace sample content and destinations before refining the layout; a local class change can stay with the composition.

Make the Result Hold Up

Use shared theme roles for changes that belong everywhere. Then review the whole journey: keyboard focus, long labels, narrow screens and a clear way to recover when something fails.

Keep a link to the source and note your intentional changes. Your next edit should begin with a clear decision, not another search.