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 🙏

© 2026 – Pkg Stats / Ryan Hefner

storybook-addon-toolbar-buttons

v0.0.1

Published

Add one-click buttons to the Storybook manager toolbar with a declarative, React-free API

Downloads

135

Readme

storybook-addon-toolbar-buttons

Add one-click toolbar buttons — toggles, icon buttons, or plain buttons — to the Storybook (v10+) manager toolbar, declaratively.

Consumers never need to install React themselves — Storybook's manager UI already provides it at runtime. This package's build keeps react (and Storybook's own packages) external, so it reuses that copy instead of bundling its own.

Installation

npm install --save-dev storybook-addon-toolbar-buttons

Usage

In .storybook/manager.ts:

import { registerToolbarButtonGroup } from "storybook-addon-toolbar-buttons";

registerToolbarButtonGroup({
  id: "my-org/viewport-quick-switch",
  title: "Viewport quick switch",
  buttons: [
    {
      label: "D",
      tooltip: "Desktop (1280×720)",
      pressed: (ctx) => ctx.globals["viewport"]?.value === "desktop",
      onClick: (ctx) => ctx.updateGlobals({ viewport: { value: "desktop", isRotated: false } }),
    },
    // ...
  ],
});

Each button's callbacks receive ctx = { globals, storyGlobals, updateGlobals }. To disable a button when a story has locked its globals, use something like disabled: (ctx) => ctx.storyGlobals['viewport'] !== undefined.

label, tooltip, disabled, icon, className, style, and pressed all accept either a plain value or a function of ctx that computes one — e.g. label: (ctx) => (ctx.globals['viewport']?.value === 'desktop' ? 'D ✓' : 'D').

Each button also accepts a variant to pick which Storybook component it renders as:

  • 'toggle' (default) — highlights while pressed is true. Requires pressed.
  • 'icon' — a plain button with no pressed state, intended for icon-only content.
  • 'button' — a plain button with no pressed state, intended for text content.

Other optional fields:

  • icon — name of a @storybook/icons export (e.g. 'EyeIcon') to show instead of label. Falls back to label if the name doesn't match an icon export.
  • className / style — extra styling for the button element. style keys are DOM style properties in camelCase (e.g. backgroundColor), not CSS property names.

See index.d.ts for the full API.

Development

bun install
bun run check   # tsc --noEmit — also checks that the implementation matches the index.d.ts signature
bun run build   # bundles src/index.tsx to dist/index.js via `bun build`

The public API's source of truth is the hand-written index.d.ts. The implementation (src/index.tsx) is annotated with typeof import('../index'), which catches a renamed/removed field the implementation reads or an incompatible return type — but not every kind of drift (e.g. a new parameter or an unused new required field compiles fine either side).

dist/ is what's published to npm (see exports and files in package.json); src/ is not. prepublishOnly runs check and build automatically before npm publish.

License

MIT