Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

storybook-addon-rtl

literalpie366.8kMIT2.0.0TypeScript support: included

Right-to-left addon for Storybook.

storybook, storybook-addon, rtl, directionality, right-to-left, ltr, internationalization, i18n, storybook-addons

readme

Storybook Addon RTL Version

Storybook Addon RTL allows you to switch to right-to-left flow in your stories in Storybook.

This addon has been tested with Storybook for React, Vue and Angular. It should also work in other frameworks.

Storybook Addon RTL Demo

This is a permanent fork of unindented/storybook-addon-rtl, which is now archived. Thanks for unindented for the original code!

Getting Started

npm i --save-dev storybook-addon-rtl

Add the addon to the addons array in .storybook/main.js

module.exports = {
  /// other storybook configuration
  addons: [
    // other addons here
    "storybook-addon-rtl",
  ],
};

Then write your stories normally:

import React from 'react'
import MyComponent from './MyComponent'

export default {
  title: 'My Component',
  component: MyComponent
};

export const default = {};

export const rtlParameter = {
  // Optionally include direction as story parameter
  // Note: usually, globals should not be set at the story level because this disables the toolbar toggle button.
  globals: {
    addonRtl: 'rtl'
  },
}

Advanced

Query Params

You can set the direction using query params in the URL. This is useful for things like e2e tests.

Just add &globals=addonRtl:rtl or &globals=addonRtl:ltr to the end of the URL:

storybook.example.com/?path=/story/button--standard&globals=addonRtl:rtl

Globals API

This addon uses the Storybook Globals API to set the direction. This allows anyone to write custom code that can set or react to changes in the direction. This is especially useful when working with some libraries that need to know about the current direction. See ./src/stories/CustomDecorator.stories.tsx for an example.

Meta

Contributors

License

Copyright (c) 2025 Benjamin Kindle (@literalpie). This is free software, and may be redistributed under the terms specified in the LICENSE file.

changelog

v2.0.0 (Sat May 31 2025)

💥 Breaking Change

Authors: 1


v1.1.0 (Tue Apr 29 2025)

:tada: This release contains work from a new contributor! :tada:

Thank you, Anthanh (@anthanh), for all your work!

🚀 Enhancement

🐛 Bug Fix

Authors: 2


v1.0.1 (Sat Aug 03 2024)

🐛 Bug Fix

🏠 Internal

Authors: 1


v1.0.0 (Sat Feb 24 2024)

💥 Breaking Change

  • initializeRTL has been removed. The addon now automatically registers itself.

Authors: 1