pyside6-storybook¶
A small, Storybook-style component explorer for PySide6. Write stories, functions that build one widget in one state, and browse them in a gallery window: edit each story's arguments live, switch between light and dark themes, and see an error in place of a story that breaks instead of a crashed app.

Status
Early release. Before 1.0, a minor release may change the API, and the changelog says so; see Versions and compatibility. The roadmap describes what is planned next.
Install¶
pyside6-storybook needs Python 3.11 or newer and PySide6 6.8 or newer. Its only dependency is PySide6-Essentials, which a
project that already depends on the full PySide6 package satisfies.
pip install pyside6-storybook
or, as a development dependency of a project managed with uv:
uv add --dev pyside6-storybook
Until 0.1.0 is out, only a release candidate is on PyPI, and pip and uv skip pre-releases unless asked: use
pip install --pre pyside6-storybook or uv add --dev --prerelease allow pyside6-storybook. The development version installs from
GitHub with pip install git+https://github.com/Youth-Research-Center/pyside6-storybook.
uv installs it into the project's .venv without activating that environment, so with uv, put uv run in front of the
pyside6-storybook commands in this documentation (or activate .venv first).
Then open the built-in example stories:
pyside6-storybook --examples
With uv:
uv run pyside6-storybook --examples
Your first story¶
Create stories/greeting_story.py in your project:
from PySide6.QtWidgets import QPushButton, QWidget
from pyside6_storybook import BoolControl, StoryContext, TextControl, story
@story(
"Buttons/Greeting",
controls=[TextControl("text", "Hello!"), BoolControl("enabled", default=True)],
)
def greeting_button(ctx: StoryContext) -> QWidget:
"""A push button whose text and enabled state can be edited in the gallery."""
button = QPushButton(ctx.args["text"])
button.setEnabled(ctx.args["enabled"])
return button
and open it, with uv run in front when you installed with uv:
pyside6-storybook stories
@storyregisters the function under an id. The parts before the last/group stories (hereButtons); the last part is the story's name.- The gallery calls the function with a
StoryContext:ctx.argsholds the current value of each control, by name, andctx.themethe name of the active theme. The story is built again from scratch whenever a control or the theme changes.ctx.tokensholds the theme provider's design tokens (see Themes). - The function returns the widget to show. If it raises, or returns something that is not a widget, the gallery shows the error and its traceback in place of the widget, and the other stories keep working.
- Discovery picks up every file named
*_story.pyor*_stories.pybelow a folder. Story files can import your application, and each other, like any module of your project.
Where to go next¶
- Writing stories:
@story, ids and groups, theStoryContext, variants, layout and decorators. - Controls: every control type and its options.
- Finding stories: targets, file names,
pyproject.tomland entry points. - Command line: every option and the exit codes.
- The gallery: the window, keyboard, canvas, Docs tab, logging actions and hot reload.
- Themes: the built-in themes, theme providers, design tokens and styling the gallery.
- Testing stories: the pytest plugin, accessibility and contrast checks, snapshots and the
render_storyfixture. - Troubleshooting: load errors, duplicate ids, headless runs, fonts in CI.
- API reference: every public name.
- Changelog: what changed in each release.
- Roadmap: the plan and the design decisions.
- Contributing: set up, run the checks, and open issues and pull requests.