What is @storybook/core?
The @storybook/core package is a part of Storybook, which is an open-source tool for developing UI components in isolation for React, Vue, Angular, and many other frameworks. It allows developers to create component libraries, interactive examples, and UI documentation. The core package is responsible for the fundamental functionalities of Storybook, including the server, UI, and the management of stories.
What are @storybook/core's main functionalities?
Custom Storybook Configuration
This code snippet demonstrates how to customize Storybook's configuration, including specifying where to find stories, which addons to use, the framework (e.g., React), and the builder (e.g., Webpack 5).
module.exports = {
stories: ['../src/**/*.stories.js'],
addons: ['@storybook/addon-links', '@storybook/addon-essentials'],
framework: '@storybook/react',
core: {
builder: 'webpack5'
}
};
Adding Decorators
Decorators are a way to wrap stories with extra markup or styling. This code sample shows how to add a decorator globally in `.storybook/preview.js` that adds margin around each story.
export const decorators = [(Story) => <div style={{ margin: '3em' }}><Story/></div>];
Custom Webpack Configuration
This demonstrates how to extend Storybook's default Webpack configuration to support additional file types or loaders, in this case, adding support for SCSS files.
const path = require('path');
module.exports = {
webpackFinal: async (config) => {
config.module.rules.push({
test: /\.scss$/,
use: ['style-loader', 'css-loader', 'sass-loader'],
include: path.resolve(__dirname, '../'),
});
return config;
},
};
Other packages similar to @storybook/core
docz
Docz is a documentation tool that uses MDX to help you write documentation and build component libraries. It's similar to Storybook in that it focuses on components but differs in its approach by leveraging Markdown and providing a more documentation-oriented experience.
Storybook Core
This package contains common data structures and bootstrapping capabilities
used among the different frameworks
(React, RN, Vue, Ember, Angular, etc).