A modern React component library built with Storybook, featuring reusable UI components with interactive documentation. Built with React 18, Vite, and Storybook 8.
Once deployed to Vercel, your Storybook will be publicly accessible for sharing with team members and stakeholders.
This repository comes pre-configured with:
- React 18 - Latest React with hooks
- Vite - Lightning-fast build tool and dev server
- Storybook 8 - Component development and documentation
- Example Components - Button and Card components to get you started
- Vercel Deployment - Ready to deploy configuration
- Node.js 18+ and npm
- Clone the repository:
git clone <your-repo-url>
cd samples- Install dependencies:
npm install- Start Storybook:
npm run storybookStorybook will open at http://localhost:6006 π
npm run storybook- Start Storybook development servernpm run build-storybook- Build Storybook for productionnpm run dev- Start Vite development server (for the React app)npm run build- Build the React app for production
samples/
βββ src/
β βββ components/ # React components
β β βββ Button/
β β β βββ Button.jsx
β β β βββ Button.css
β β β βββ Button.stories.jsx
β β βββ Card/
β β βββ Card.jsx
β β βββ Card.css
β β βββ Card.stories.jsx
β βββ App.jsx # Main app component
β βββ App.css
β βββ main.jsx # App entry point
β βββ index.css # Global styles
βββ .storybook/
β βββ main.js # Storybook configuration
β βββ preview.js # Global decorators/parameters
βββ package.json
βββ vite.config.js
βββ vercel.json # Vercel deployment config
βββ index.html
Follow this pattern to add your own components:
mkdir -p src/components/YourComponent
touch src/components/YourComponent/YourComponent.jsx
touch src/components/YourComponent/YourComponent.css
touch src/components/YourComponent/YourComponent.stories.jsx// src/components/YourComponent/YourComponent.jsx
import React from 'react';
import './YourComponent.css';
export const YourComponent = ({ prop1, prop2 }) => {
return (
<div className="your-component">
{/* Your component JSX */}
</div>
);
};/* src/components/YourComponent/YourComponent.css */
.your-component {
/* Your styles */
}// src/components/YourComponent/YourComponent.stories.jsx
import { YourComponent } from './YourComponent';
export default {
title: 'Components/YourComponent',
component: YourComponent,
parameters: {
layout: 'centered',
},
tags: ['autodocs'],
};
export const Default = {
args: {
prop1: 'value1',
prop2: 'value2',
},
};
export const Variant = {
args: {
prop1: 'different value',
prop2: 'another value',
},
};Your component will automatically appear in Storybook. Restart the dev server if needed.
- Push your code to GitHub:
git add .
git commit -m "Initial Storybook setup"
git push origin main- Go to vercel.com and sign in
- Click "Add New..." β "Project"
- Import your GitHub repository
- Vercel will auto-detect the configuration from
vercel.json - Click "Deploy"
Every push to your main branch will automatically trigger a new deployment!
npm install -g vercel
vercel login
vercelFollow the prompts to deploy your Storybook.
- Vercel will run
npm run build-storybookto generate static files - The build output in
storybook-static/will be deployed - You'll receive a public URL like
https://your-project.vercel.app - SSL certificate is automatically provided
A versatile button component with multiple variants:
- Primary - Main call-to-action button
- Secondary - Secondary actions
- Outline - Subtle actions
- Disabled - Non-interactive state
Props:
label(string) - Button textonClick(function) - Click handlervariant('primary' | 'secondary' | 'outline') - Button styledisabled(boolean) - Disabled state
A flexible card container for grouping content:
Props:
title(string) - Optional card titlechildren(ReactNode) - Card contentfooter(ReactNode) - Optional footer content
Components use plain CSS for easy customization. Modify the .css files in each component folder to adjust styles.
Edit .storybook/preview.js to customize Storybook's appearance:
export default {
parameters: {
backgrounds: {
default: 'light',
values: [
{ name: 'light', value: '#ffffff' },
{ name: 'dark', value: '#333333' },
{ name: 'custom', value: '#your-color' },
],
},
},
};Feel free to add your own components and share them with the team!
MIT