storybook-addon-flow-direction
v0.3.1
Published
Stress-test writing-mode and direction in Storybook and detect physical CSS with logical-property hints.
Maintainers
Readme
Storybook Addon Flow Direction
Validate components across writing modes and text directions directly in Storybook. Detect physical CSS usage and get logical-property suggestions before shipping.
Install
pnpm add -D storybook-addon-flow-directionnpm install -D storybook-addon-flow-directionyarn add -D storybook-addon-flow-directionRegister the addon
Add it to .storybook/main.ts:
import type { StorybookConfig } from '@storybook/react-vite';
const config: StorybookConfig = {
framework: '@storybook/react-vite',
addons: ['storybook-addon-flow-direction'],
};
export default config;Toolbar
The Flow Direction toolbar includes:
- writing mode (
horizontal-tb,vertical-rl,vertical-lr) - direction (
ltr,rtl) - matrix mode toggle
- reset action
Use the toolbar to switch context, then run a scan from the panel.

Scanner
The scanner checks rendered DOM and authored styles for physical CSS that can break in RTL or vertical layouts.
It reports matches from:
- stylesheet declarations that are readable via CSSOM
- inline
styleattributes
Examples:
padding-left->padding-inline-startmargin-right->margin-inline-endleft->inset-inline-starttext-align: left->text-align: startscroll-snap-type: x mandatory->scroll-snap-type: inline mandatory
Cross-origin stylesheets that block cssRules access are skipped.
Panel workflow

- Open a story.
- Click Re-scan in the Flow Direction panel.
- Review grouped findings.
- Click Focus offender to jump to the element in preview.
Selector hints used by Focus offender are derived in this order: data-testid, data-flow-direction-label, id, then the first class token.
Class tokens keep semantic hyphenated names intact (for example physical-toast), while CSS-module style underscore hash suffixes are normalized for readability.
Configuration
Supported parameters:
flowDirection.matrix(boolean, story-level) - render the story in a six-cell matrixflowDirection.supportedWritingModes(FlowWritingMode[], project-level) - writing modes shown in toolbar and matrixflowDirection.supportedDirections(FlowDirection[], project-level) - directions shown in toolbar and matrixflowDirection.scanScope({ include?: (string | RegExp)[]; exclude?: (string | RegExp)[] }) - restrict scanner to matching stylesheet sources
Set project-wide defaults in .storybook/preview.ts:
import type { Preview } from '@storybook/react-vite';
const preview: Preview = {
parameters: {
flowDirection: {
supportedWritingModes: ['horizontal-tb', 'vertical-rl', 'vertical-lr'],
supportedDirections: ['ltr', 'rtl'],
// Optional:
// scanScope: { include: [/my-app/], exclude: ['vendor.css'] },
scanScope: {
// Match local story stylesheets in root-level `stories/` setups.
// Include build-time asset URLs so hashed CSS chunks are scanned too.
include: ['/src/stories/', '\\src\\stories\\', '.stories.', '.module.css', '/stories/', '\\stories\\', '/assets/', '\\assets\\'],
},
},
},
};
export default preview;If your story CSS still does not appear in scan results, add project-specific identifiers from generated stylesheet sources (for example chunk names) and keep the include list focused so you do not scan unrelated Storybook UI/vendor styles.
Compatibility
- Storybook
10.x - Node.js
>=20.19
License
MIT
