npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@fluentui/react-storybook-addon

v0.5.1

Published

fluentui react storybook addon

Readme

@fluentui/react-storybook-addon

Storybook addon for Fluent UI React

✨ Features

Toolbar/Tools

  • Adds a Fluent theme switcher:
    • Fluent Theme Switcher

Theme Management in Storybook Globals

Exports types and utilities to set and consume the correct Fluent theme in Storybook globals. Here's an example picker that sets the Fluent theme in Storybook globals.

import * as React from 'react';
import { themes, setGlobalTheme, FluentStoryContext, THEME_ID } from '@fluentui/react-storybook-addon';

// Storybook context which can be accessed, for example, in decorators
// https://storybook.js.org/docs/react/writing-stories/decorators#context-for-mocking
export const ThemePicker: React.FC<{ context: FluentStoryContext }> = ({ context }) => {
  const handleChange = e => {
    setGlobalTheme(e.target.value);
  };

  const selectedTheme = themes.find(theme => theme.id === context.globals[THEME_ID]);

  return (
    <select onChange={handleChange}>
      {themes.map(theme => (
        <option selected={selectedTheme.id === theme.id} value={theme.id}>
          {theme.label}
        </option>
      ))}
    </select>
  );
};

Augmented Docs Blocks

This presets uses custom docs container and page for unified FluentUI experience including:

  • table of contents
  • theme switcher
  • dir switcher
  • custom ArgsTable
    • Slot api rendering
    • native props support

Getting Started

Installation

To install the addon, run:

yarn add -D @fluentui/react-storybook-addon

Configuration

Add the following content to .storybook/main.js:

module.exports = {
  addons: ['@fluentui/react-storybook-addon'],
};

Development

  1. Run the inner loop from the monorepo root with yarn workspace @fluentui/react-storybook-addon storybook.

    • 💡 This will run the prestorybook script that compiles the addon implementation with all of its direct dependencies within the monorepo, so it can be consumed by the local Storybook.
  2. After making any changes to the implementation, manually run yarn workspace @fluentui/react-storybook-addon build to reflect those changes in your local Storybook.

Parameter Configuration

Three custom optional parameters can be set to alter the behavior of the addon:

  1. dir - Determines whether to render the story in ltr or rtl mode. Default is undefined.
  2. fluentTheme - Determines whether to render the story theme in web-light, web-dark, teams-high-contrast, teams-dark, or teams-light. Setting this parameter will disable the ability to dynamically change the theme within the story canvas or doc.
  3. mode - When set to vr-test, this removes the injected padding and background theme that's automatically applied from the rendered story. Default is default.
import { FluentParameters, parameters } from '@fluentui/react-storybook-addon';
import { Button } from '@fluentui/react-components';

export const Button = () => <Button>Hello World</Button>;

export const ButtonDarkMode = {
  render: Button,
  parameters: { fluentTheme: 'web-dark' } as FluentParameters, // Story renders in Dark mode.
};

export const ButtonHighContrast = {
  render: Button,
  parameters: { fluentTheme: 'teams-high-contrast', mode: 'vr-test' } as FluentParameters, // Story renders in High Contrast mode without injected padding and background style.
};

export const ButtonRTL = {
  render: Button,
  // Parameters identity function will have all TS type annotations built in for intellisense.
  parameters: parameters({ fluentTheme: 'web-light', dir: 'rtl', mode: 'vr-test' }), // Story renders in RTL, Web light mode and without injected padding and background style.
};