Introduction
React Styleguidist generates a living style guide from your React components. It extracts prop types and JSDoc comments automatically, renders live-editable code examples from Markdown files, and serves everything in an interactive development environment that makes component documentation effortless.
What React Styleguidist Does
- Auto-generates prop documentation tables from PropTypes, TypeScript, or Flow definitions
- Renders live, editable code examples that update in real time
- Organizes components into sections with Markdown-based descriptions
- Provides an isolated rendering sandbox for each component example
- Supports custom webpack configuration for project-specific build setups
Architecture Overview
Styleguidist scans your source tree for component files, extracts metadata using react-docgen, and parses companion Markdown files for code examples. At dev time, a webpack-based dev server compiles and serves the style guide as a single-page React application. Each code example runs in an isolated context using a sandboxed editor powered by CodeMirror, enabling live editing without affecting other examples on the page.
Self-Hosting & Configuration
- Configure via
styleguide.config.jsat the project root - Specify component glob patterns to control which files are documented
- Add
Readme.mdorComponentName.mdfiles next to components for examples - Use
webpackConfigto reuse your existing project webpack setup - Build a static HTML site with
styleguidist buildfor deployment to any host
Key Features
- Live editor: modify example code and see results instantly in the browser
- Prop tables: auto-extracted from PropTypes, TypeScript interfaces, or Flow types
- Section organization: group components logically with nested Markdown sections
- Theme customization: override styles and layout via a theme configuration object
- Hot module replacement: component changes reflect immediately during development
Comparison with Similar Tools
- Storybook — More ecosystem plugins and addons; Styleguidist is simpler with Markdown-first documentation
- Docz — MDX-based documentation; Styleguidist uses plain Markdown with embedded JSX examples
- Ladle — Vite-native Storybook alternative; Styleguidist is webpack-based
- Cosmos — Focuses on component fixtures; Styleguidist emphasizes prose documentation alongside examples
FAQ
Q: Does it work with TypeScript? A: Yes. It uses react-docgen-typescript to extract prop types and descriptions from TypeScript interfaces.
Q: Can I use it alongside Storybook? A: Yes. They serve different purposes and can coexist. Styleguidist focuses on written documentation while Storybook focuses on interactive component states.
Q: Does it support CSS Modules or styled-components? A: Yes. Since it uses your project's webpack config, any styling approach that works in your build also works in Styleguidist.
Q: Can I customize the look of the generated site?
A: Yes. The theme object in styleguide.config.js lets you override colors, fonts, spacing, and layout.