kibana/packages/kbn-storybook
2025-01-03 05:38:57 -06:00
..
preset chore(NA): moving @kbn/storybook into bazel (#102731) 2021-06-21 20:17:54 +01:00
src Sustainable Kibana Architecture: Move plugins owned by @elastic/appex-sharedux (#204959) 2025-01-03 05:38:57 -06:00
templates Delete imports/references to EUI's distributed .css files (#194237) 2024-09-30 13:37:47 -05:00
index.ts Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
kibana.jsonc Sustainable Kibana Architecture: Categorise straightforward packages (#199630) 2024-11-22 10:33:25 +01:00
package.json Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
preset.js Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
README.md Fixes for storybook aliases (#204842) 2024-12-26 08:38:22 -08:00
tsconfig.json [Storybook][i18n] initialize i18n with english locale (#185033) 2024-06-07 12:44:37 -07:00

Kibana Storybook

This package provides ability to add Storybook to any Kibana package or plugin.

Setup Instructions

  • Add a .storybook/main.js configuration file to your plugin. For example, create a file at src/plugins/<plugin>/.storybook/main.js, with the following contents:

    module.exports = require('@kbn/storybook').defaultConfig;
    
  • Add your plugin alias to src/dev/storybook/aliases.ts config.

  • Create sample Storybook stories. For example, in your plugin create a file at src/plugins/<plugin>/public/components/hello_world/hello_world.stories.tsx with the following Component Story Format contents:

    import type { Meta, StoryObj } from '@storybook/react';
    
    import { MyComponent } from './MyComponent';
    
    const meta: Meta<typeof MyComponent> = {
      component: MyComponent,
    };
    
    export default meta;
    type Story = StoryObj<typeof MyComponent>;
    
    export const Basic: Story = {};
    
    export const WithProp: Story = {
      render: () => <MyComponent prop="value" />,
    };
    
  • Launch Storybook with yarn storybook <plugin>, or build a static site with yarn storybook --site <plugin>.

Customizing configuration

The defaultConfig object provided by the @kbn/storybook package should be all you need to get running, but you can override this in your .storybook/main.js. Using Storybook's configuration options.

You can also add a manager.ts file to customize various aspects of your Storybook. For example, to change the title and link of the Storybook sidebar, you could add:

addons.setConfig({
  theme: create({
    brandTitle: 'My Plugin',
    brandUrl: 'https://github.com/elastic/kibana/tree/main/src/plugins/my_plugin',
  }),
});

Refer to the Storybook documentation for more information.