Storybook Tutorial

How to use the visual UI catalog for ShipRules AI — with real examples from the app.

Live Storybook: Open ShipRules AI Storybook — no login required.

What Is Storybook?

Storybook is a visual catalog of every screen and component in your app. Each item in the catalog is called a story. Stories render with mock data — no database, no API, no Shopify login needed.

Without Storybook

To see the Dashboard, you need to: install the app on a Shopify dev store, log in to the admin, click the app, wait for data to load...

With Storybook

Open a URL. Click "Dashboard" in the sidebar. See it instantly with mock data. Switch to mobile view. Check accessibility. Done.

The Interface

When you open Storybook, you see three areas:

Storybook Viewport: Desktop Zoom: 100% Accessibility Measure
Components
KPI Card
Prompt Box
Rule Badges
Rate Result Card
Empty State
NLP Confirmation
Usage Meter
Banners
Pages
Dashboard
Settings
Simulate
Version History
NLP Prompt
Product Groups
The selected story renders here — exactly as the merchant sees it.

Sidebar — lists all stories, grouped by Pages and Components. Click to preview.
Canvas — renders the selected story with Polaris Web Components.
Toolbar — viewport switcher, zoom, accessibility checker.

Here's what it actually looks like:

Storybook home screen showing sidebar with Components and Pages groups
The Storybook home screen. Components group is expanded; Pages group is collapsed.

Page Stories — Full Screens

Page stories show complete app screens. These are what the merchant sees inside the Shopify admin.

Dashboard

The main screen: KPI cards (Zones, Methods, Rules, Groups, Blended Rates, Plan), the NLP prompt box, recent rules table, and plan usage metrics.

Dashboard page story showing KPI cards, prompt box, rules table, and usage
Dashboard with mock data — 3 zones, 5 methods, 12 rules, plan usage meters.

Settings

Shop configuration: test mode toggle, weight unit, currency, import/export, API keys, and shop info.

Settings page story showing form controls and plan usage
Settings page — Polaris form controls (select, checkbox, text field, button).

Rate Simulation

The test rates page: destination fields, cart items, and rate results with rule traces.

Simulate page with destination form, cart items, and rate results
Rate simulation — 2-column destination form, cart items, and two rate result cards.

Component Stories — Building Blocks

Component stories show individual UI elements in isolation. This is where you catch visual inconsistencies before they reach a full page.

NLP Confirmation Card

What the merchant sees after typing a natural language prompt. Shows the AI's interpretation, proposed operations, and Confirm/Edit/Cancel actions.

NLP confirmation component showing AI interpretation and action buttons
NLP confirmation — 95% confidence, one proposed rule, with Confirm/Edit/Cancel/Queue buttons.

Banners

All four Polaris banner tones: success, warning, critical, and info. These appear as toast notifications and inline alerts throughout the app.

Four Polaris banners showing success, warning, critical, and info tones
Banner component in all four tones — used for feedback after every action.

Empty States

What pages look like before the merchant has created any data. Each empty state has a specific message and a suggested first action.

Empty state for Product Groups showing helpful message and prompt suggestion
Product Groups empty state — explains what groups are and suggests a prompt to create one.

Usage Meter

Plan usage progress bars at three levels: healthy (green), warning (amber), and critical (red).

Usage meter showing three progress bars at different levels
Usage meters — Methods at 50% (green), Groups at 67% (amber), Prompts at 96% (red).

How Stories Work

A story is a JavaScript function that returns HTML. That's it.

// A simple component story
export const KPICard = {
  render: () => `
    <s-section>
      <s-stack direction="block" gap="100">
        <s-text tone="subdued">Shipping Methods</s-text>
        <s-text type="strong">5</s-text>
      </s-stack>
    </s-section>
  `,
};

The <s-section> and <s-text> tags are Polaris Web Components — Shopify's UI library. Storybook loads Polaris from the CDN automatically, so they render as styled Shopify UI.

Key insight: Stories use the exact same <s-*> tags as the real app. What you see in Storybook is what the merchant sees in Shopify.

File Structure

shiprules-ai/
├── .storybook/
│ ├── main.ts ← Config: where stories live, which addons
│ └── preview.ts ← Wraps every story in Polaris <s-app-provider>
├── apps/web/stories/
│ ├── pages.stories.ts ← 8 full page stories
│ └── components.stories.ts ← 15 component stories

Workflow

1
Write the story first

Before building a new page, write how it should look as a story. This forces you to think about the UI before writing business logic.

2
Build the component to match

Run pnpm storybook locally. Edit the story, see it hot-reload. Iterate until it looks right.

3
Check mobile + accessibility

Use the viewport dropdown to switch to 375px. Click the Accessibility tab to run WCAG checks.

4
Deploy and share

Build and deploy to Cloudflare Pages. Share the URL — anyone can review without a Shopify account.

Quick Reference

CommandWhat it does
pnpm storybookDev server at localhost:6006 (hot-reload)
pnpm storybook:buildBuild static site to storybook-static/
npx wrangler pages deploy storybook-static --project-name shiprules-storybookDeploy to Cloudflare Pages
TermMeaning
StoryOne render of a component with specific mock data
CanvasThe preview area where stories render
DecoratorCode that wraps every story (loads Polaris CDN)
AddonPlugin that adds features (accessibility checker)
MetaGroups stories under a sidebar heading (Pages, Components)
Open the live Storybook now: https://shiprules-storybook.pages.dev
Click Pages in the sidebar to expand it, then click any page to preview.