Top Related Projects
Storybook is the industry standard workshop for building, documenting, and testing UI components in isolation
Isolated React component development environment with a living style guide
✍ It has never been so easy to document your things!
Sandbox for developing and testing UI components in isolation
Quick Overview
Ladle is a lightweight and fast development environment for React components. It provides a simple, zero-config setup for testing and showcasing components in isolation, similar to Storybook but with a focus on speed and simplicity.
Pros
- Fast and lightweight, with minimal configuration required
- Supports TypeScript, MDX, and CSS modules out of the box
- Easy integration with existing React projects
- Built-in hot reloading for quick development
Cons
- Less feature-rich compared to more established tools like Storybook
- Limited ecosystem of addons and plugins
- May not be suitable for complex component documentation needs
- Relatively new project, so community support might be less extensive
Code Examples
- Creating a simple story:
import { Button } from './Button';
export const Default = () => <Button>Click me</Button>;
export const Primary = () => <Button primary>Primary Button</Button>;
- Using controls to modify props:
import { Button } from './Button';
export const WithControls = ({ label, disabled }) => (
<Button disabled={disabled}>{label}</Button>
);
WithControls.args = {
label: 'Click me',
disabled: false,
};
- Adding metadata to a story:
import { Button } from './Button';
export default {
title: 'Components/Button',
component: Button,
};
export const Default = () => <Button>Click me</Button>;
Default.parameters = {
docs: {
description: 'This is the default button style',
},
};
Getting Started
- Install Ladle in your React project:
npm install --save-dev @ladle/react
- Add a script to your
package.json
:
{
"scripts": {
"ladle": "ladle serve"
}
}
- Create a story file (e.g.,
Button.stories.tsx
):
import { Button } from './Button';
export const Default = () => <Button>Click me</Button>;
- Run Ladle:
npm run ladle
This will start the Ladle development server, and you can view your components in the browser.
Competitor Comparisons
Storybook is the industry standard workshop for building, documenting, and testing UI components in isolation
Pros of Storybook
- Extensive ecosystem with a wide range of addons and integrations
- Supports multiple frameworks (React, Vue, Angular, etc.)
- Robust documentation and large community support
Cons of Storybook
- Heavier setup and configuration process
- Slower build times, especially for larger projects
- Steeper learning curve for beginners
Code Comparison
Storybook configuration:
// .storybook/main.js
module.exports = {
stories: ['../src/**/*.stories.@(js|jsx|ts|tsx)'],
addons: ['@storybook/addon-links', '@storybook/addon-essentials'],
};
Ladle configuration:
// .ladle/config.mjs
export default {
stories: 'src/**/*.stories.{js,jsx,ts,tsx}',
};
Storybook offers more extensive configuration options out of the box, while Ladle aims for simplicity with minimal setup required. Storybook's ecosystem provides a wider range of customization possibilities, but this can also lead to increased complexity. Ladle focuses on a streamlined experience, particularly for React projects, with faster build times and a more straightforward configuration process. Both tools serve the purpose of component development and documentation, but cater to different project needs and team preferences.
Isolated React component development environment with a living style guide
Pros of React Styleguidist
- More mature and feature-rich, with a larger community and ecosystem
- Supports automatic prop type documentation and component description generation
- Offers a wider range of customization options for the style guide
Cons of React Styleguidist
- Steeper learning curve due to more complex configuration
- Slower build times, especially for larger projects
- Can be overkill for simpler component libraries or smaller projects
Code Comparison
React Styleguidist configuration:
module.exports = {
components: 'src/components/**/*.js',
webpackConfig: require('./webpack.config.js')
}
Ladle configuration:
export default {
stories: ['src/**/*.stories.{js,jsx,ts,tsx}'],
addons: ['@ladle/addon-a11y']
}
React Styleguidist focuses on creating a comprehensive style guide with detailed documentation, while Ladle emphasizes simplicity and speed for component development and testing. Styleguidist requires more configuration but offers greater customization, whereas Ladle provides a more streamlined experience out of the box. The choice between the two depends on project requirements, team preferences, and the desired level of documentation and customization.
✍ It has never been so easy to document your things!
Pros of Docz
- More comprehensive documentation solution, supporting MDX and generating full documentation sites
- Offers a wider range of customization options and themes
- Integrates well with existing documentation workflows and supports static site generation
Cons of Docz
- Steeper learning curve due to more complex setup and configuration
- Heavier bundle size and potentially slower performance for large documentation projects
- Less focused on component development and testing compared to Ladle
Code Comparison
Docz configuration:
// doczrc.js
export default {
title: 'My Documentation',
description: 'A sample Docz project',
base: '/docs',
menu: ['Home', 'Components', 'API']
}
Ladle configuration:
// .ladle/config.mjs
export default {
stories: 'src/**/*.stories.{js,jsx,ts,tsx}',
addons: {
a11y: true,
action: true,
control: true
}
}
Both Docz and Ladle serve different purposes in the React ecosystem. Docz is more suited for comprehensive documentation projects, while Ladle focuses on component development and testing. The choice between them depends on the specific needs of your project and development workflow.
Sandbox for developing and testing UI components in isolation
Pros of React Cosmos
- More comprehensive fixture system, allowing for complex component states and variations
- Built-in proxies for state management, routing, and API mocking
- Supports server-side rendering and static exports
Cons of React Cosmos
- Steeper learning curve due to more advanced features
- Potentially slower setup and configuration process
- May be overkill for smaller projects or simpler component libraries
Code Comparison
React Cosmos fixture example:
import Button from './Button';
export default {
component: Button,
props: { label: 'Click me', onClick: () => console.log('Clicked!') }
};
Ladle story example:
import { Button } from './Button';
export const Default = () => <Button>Click me</Button>;
Both React Cosmos and Ladle are powerful tools for developing and testing React components in isolation. React Cosmos offers more advanced features and flexibility, making it suitable for complex projects and large component libraries. Ladle, on the other hand, provides a simpler and more lightweight approach, which can be beneficial for smaller projects or teams looking for a quick setup.
React Cosmos excels in creating detailed fixtures and managing complex component states, while Ladle focuses on ease of use and quick story creation. The choice between the two depends on the project's specific needs, team expertise, and desired level of customization.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Ladle is an environment to develop, test, and share your React components faster.
Quick start
mkdir my-ladle
cd my-ladle
pnpm init
pnpm add @ladle/react react react-dom
mkdir src
echo "export const World = () => <p>Hey</p>;" > src/hello.stories.tsx
pnpm ladle serve
with yarn
mkdir my-ladle
cd my-ladle
yarn init --yes
yarn add @ladle/react react react-dom
mkdir src
echo "export const World = () => <p>Hey</p>;" > src/hello.stories.tsx
yarn ladle serve
with npm
mkdir my-ladle
cd my-ladle
npm init --yes
npm install @ladle/react react react-dom
mkdir src
echo "export const World = () => <p>Hey</p>;" > src/hello.stories.tsx
npx ladle serve
Top Related Projects
Storybook is the industry standard workshop for building, documenting, and testing UI components in isolation
Isolated React component development environment with a living style guide
✍ It has never been so easy to document your things!
Sandbox for developing and testing UI components in isolation
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot