@tour-kit/coreHooks
useDirection
Hook returning the resolved text direction (ltr or rtl) and an isRTL boolean for RTL-aware components
domidex01Published
Returns the resolved text direction ('ltr' or 'rtl') and a convenience isRTL flag. The value comes from TourKitProvider's dir prop — when set to 'auto', the provider resolves it from document.dir on mount.
Use this hook in tour cards, hint hotspots, and custom UI that needs to mirror layout for RTL languages.
Usage
import { useDirection } from '@tour-kit/core';
function TourArrow() {
const { isRTL } = useDirection();
return <span aria-hidden>{isRTL ? '←' : '→'}</span>;
}import { useDirection } from '@tour-kit/core';
function MirroredCard() {
const { direction } = useDirection();
return <div dir={direction} className="card">{/* ... */}</div>;
}Return Value
| Field | Type | Description |
|---|---|---|
direction | 'ltr' | 'rtl' | Resolved text direction |
isRTL | boolean | Convenience flag (direction === 'rtl') |
useDirection requires a <TourKitProvider> in the tree — it will throw otherwise.
Related
useTourKitContext— read the full context thatuseDirectionis a thin wrapper over.<TourKitProvider>— the provider whosedirprop this hook resolves.- i18n guide — patterns for RTL languages and translated tour copy.
Ship onboarding, not config.
npm i @tour-kit/core is MIT and free. The Pro packages work unlicensed too — a one-time $99 license removes the production watermark when you ship.
MIT-licensed — no signup, no credit card. Pay once, only when you ship.