Skip to content

southleft/story-ui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

75 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Story UI 🎨

AI-powered Storybook story generator for any React component library

npm version License: MIT

Story UI revolutionizes component documentation by automatically generating Storybook stories through AI-powered conversations. Simply chat with the AI about your components and watch as comprehensive stories are created in real-time.

✨ Features

🎯 Core Features

  • AI-Powered Story Generation: Chat with AI to create comprehensive Storybook stories
  • Intelligent Iteration Support: Modify existing stories without losing your work
  • Multi-Component Library Support: Works with any React component library
  • Real-time Story Updates: See your stories appear in Storybook instantly
  • Intelligent Component Discovery: Automatically finds and analyzes your components
  • TypeScript Support: Full TypeScript integration with type-aware story generation

πŸ“š Documentation System (New!)

  • Auto-Generated Structure: npx story-ui init creates a story-ui-docs/ directory template
  • Directory-Based Documentation: Organize design system docs in a structured directory
  • Multiple Format Support: Markdown, JSON, HTML, and text files
  • Legacy Support: Still supports single story-ui-considerations.md file
  • Auto-Discovery: Automatically finds and loads documentation to enhance AI story generation

🎨 Advanced Features

  • Memory-Persistent Stories: Stories are remembered across sessions
  • Git Integration: Automatic gitignore management for generated files
  • Production Mode: Clean deployment without generated stories
  • Auto Port Detection: Automatically finds available ports
  • Hot Reload Integration: Stories update automatically as you chat
  • MCP Server Integration: Use Story UI directly from Claude Desktop or other MCP clients

πŸš€ Quick Start

# Install Story UI
npm install -D @tpitre/story-ui

# Initialize Story UI in your project
npx story-ui init

# Start generating stories (Story UI will pick 4001 or the next free port)
npm run story-ui

# Need a custom port? Just pass the flag:
npm run story-ui -- --port 4005

Story UI will automatically:

  • βœ… Discover your components
  • βœ… Set up the chat interface
  • βœ… Create a story-ui-docs/ directory structure for your design system documentation
  • βœ… Generate stories as you type
  • βœ… Load your design system documentation to enhance AI generation

πŸ“š How It Works

Story UI uses advanced AI to understand your component library and generate appropriate stories:

  1. Component Discovery: Story UI scans your codebase for available components
  2. Documentation Loading: Reads your design system documentation (if available)
  3. AI Generation: Claude generates stories using discovered components
  4. Iteration Support: Previous code is preserved when modifying stories
  5. Hot Reload: Stories appear instantly in your Storybook

🎯 Configuration

Basic Configuration (story-ui.config.js)

export default {
  // Component library import path
  importPath: 'your-component-library',

  // Path to your local components (for custom libraries)
  componentsPath: './src/components',

  // Generated stories location
  generatedStoriesPath: './src/stories/generated/',

  // Story configuration
  storyPrefix: 'Generated/',
  defaultAuthor: 'Story UI AI',

  // Layout rules for multi-column layouts
  layoutRules: {
    multiColumnWrapper: 'div',
    columnComponent: 'div',
    containerComponent: 'div'
  }
};

🌟 Officially Supported Design Systems

Story UI provides guided installation and automatic configuration for the following design systems:

Design System Package Auto Install Pre-configured
Ant Design antd βœ… Yes βœ… Yes
Mantine @mantine/core βœ… Yes βœ… Yes
Chakra UI @chakra-ui/react βœ… Yes βœ… Yes
Custom Any React library ❌ Manual βœ… Configurable

When you run npx story-ui init, you can choose to automatically install and configure these design systems with optimized layout rules and component mappings.

πŸ“± Examples

Simple Component Story

You: "Create a button story with different variants"

AI: "I'll create a comprehensive Button story with all available variants..."

Result:

export const AllVariants = {
  render: () => (
    <div style={{ display: 'flex', flexDirection: 'column', gap: '16px' }}>
      <Button variant="primary">Primary</Button>
      <Button variant="secondary">Secondary</Button>
      <Button variant="tertiary">Tertiary</Button>
      <Button variant="plain">Plain</Button>
    </div>
  )
};

Complex Layout Story

You: "Create a product card with image, title, price, and add to cart button"

AI: "I'll create a product card using your design system components..."

Iterating on Existing Stories

You: "Make the buttons full width"

AI: "I'll modify the existing story to make the buttons full width..."

The AI will preserve your existing code and only modify what you requested!

πŸ€– MCP Server Integration

Story UI can be used as a Model Context Protocol (MCP) server, allowing you to generate stories directly from Claude Desktop or other MCP-compatible clients.

Quick Setup for Claude Desktop

  1. Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
  "mcpServers": {
    "story-ui": {
      "command": "npx",
      "args": ["@tpitre/story-ui", "mcp"],
      "env": {
        "CLAUDE_API_KEY": "your-claude-api-key-here"
      }
    }
  }
}
  1. Start the Story UI HTTP server in your project:
story-ui start
  1. Restart Claude Desktop

Now you can generate stories directly in Claude Desktop! Just ask:

  • "Use Story UI to create a hero section with a title and CTA button"
  • "List all available components in Story UI"
  • "Show me the stories I've generated"

For detailed MCP setup instructions, see docs/MCP_INTEGRATION.md.

πŸ“– Documentation Support

Directory-Based Documentation (Recommended)

Create a story-ui-docs/ directory in your project root:

story-ui-docs/
β”œβ”€β”€ README.md                    # Overview and getting started
β”œβ”€β”€ guidelines/
β”‚   β”œβ”€β”€ accessibility.md         # Accessibility guidelines
β”‚   β”œβ”€β”€ responsive-design.md     # Responsive design rules
β”‚   └── brand-guidelines.md      # Brand usage
β”œβ”€β”€ tokens/
β”‚   β”œβ”€β”€ colors.json             # Color tokens
β”‚   β”œβ”€β”€ spacing.md              # Spacing system
β”‚   └── typography.json         # Typography tokens
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ button.md               # Button documentation
β”‚   └── forms.md                # Form component docs
└── patterns/
    β”œβ”€β”€ layouts.md              # Layout patterns
    └── data-tables.md          # Table patterns

Story UI will automatically discover and use this documentation to generate better stories.

Legacy Single-File Documentation

You can still use a single story-ui-considerations.md file in your project root for simpler setups.

πŸ”§ Advanced Features

Story Version History

Every generated story is tracked with version history:

  • Each iteration is saved with a timestamp
  • Previous versions are linked for easy tracking
  • History is stored in .story-ui-history/ (git-ignored)

Component Validation

All generated stories are validated to ensure:

  • βœ… Only existing components are imported
  • βœ… Props match component interfaces
  • βœ… Import paths are correct
  • βœ… TypeScript types are valid

Production Mode

In production environments, Story UI operates in memory-only mode:

  • No files are written to disk
  • Stories are served from memory
  • Clean deployment without generated files

πŸš€ CLI Commands

# Initialize Story UI in a new project
npx story-ui init

# Start the Story UI server
npx story-ui start

# Start on a specific port
npx story-ui start --port 4005

# Use a specific config file
npx story-ui start --config custom-config.js

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Setup

# Clone and install
git clone https://github.com/southleft/story-ui.git
cd story-ui
npm install

# Build and link for development
npm run build
npm link

# Test in a project
cd your-project
npm link @tpitre/story-ui

πŸ“„ License

MIT Β© Story UI Contributors

πŸ”— Links


Story UI - Making component documentation delightful, one conversation at a time. ✨