Skip to content

Option A — Phase 9: Theme & Design System

This document is the plan for Phase 9 of AppiFire AI Chat (Option A): adopting a professional, widely used design system so the admin UI (and optionally the storefront chat widget) looks consistent and polished instead of basic custom styling.

Prerequisites: Admin app routes exist (e.g. Phase 4 settings, Phase 5 billing, Phase 8 chat logs). No functional changes to business logic; this phase is about visual consistency and component library.


  • Replace ad‑hoc styling (inline styles, custom s-* elements, hardcoded hex colors) with a single design system used across the project.
  • Use components and tokens (spacing, color, typography) so pages look professional and consistent.
  • Prefer a market-standard, open-source approach that fits a Shopify embedded app (React).

Section titled “1. Recommended approach: Shopify Polaris (React)”

Primary choice: Shopify Polaris React (@shopify/polaris).

  • Widely used for Shopify admin and embedded apps; matches the host admin chrome.
  • Professional components: Page, Card, IndexTable (expandable rows), DataTable, Badge, Banner, TextField, Button, Box, Stack, etc.
  • Design tokens: Color, spacing, typography built in; no need to invent a palette.
  • Fits the stack: React, and the app already uses @shopify/app-bridge-react and @shopify/polaris-types (types only today).
  • Single source of truth: One library for layout, tables, forms, and feedback across all admin routes.

What changes:

  • Add @shopify/polaris and its CSS to the app (root layout or app shell).
  • Replace custom layout (e.g. s-page, s-section, raw <table>) with Polaris components: Page, Card, IndexTable, DataTable, Text, Box, Banner, etc.
  • Use Polaris for all admin routes (Home, Settings, Billing, AI Chats, Additional) so the whole project shares one theme.

Note: Polaris React is being succeeded by Polaris Web Components long-term; for current React-based admin UIs it remains the standard and is well documented.


  • Use case: Utility-first styling for one-off tweaks, or if you want a second “theme layer” (e.g. custom marketing/landing pages) without full Polaris.
  • Recommendation: Introduce only if needed. For an admin-only app, Polaris alone is enough. If you add Tailwind later, keep Polaris for structure and use Tailwind for spacing/color overrides where necessary.
  • This plan: Phase 9 focuses on Polaris first; Tailwind can be a later, optional step.

AreaIn scope for Phase 9Notes
Admin app routesYesAll routes under /app/*: Home, Settings, Billing, AI Chats, Additional. Use Polaris Page, Card, tables, forms, banners.
Auth / loginYesUse Polaris layout and components where it makes sense (e.g. Card, TextField, Button).
Chat widget (storefront)OptionalWidget is customer-facing; can stay custom or use a small subset of tokens. Document in this plan that widget theming is separate.
Root layoutYesLoad Polaris CSS (and font if not already) in app/root.jsx or the layout that wraps admin UI.

  1. Install:
    npm install @shopify/polaris

  2. Load Polaris CSS in the root that wraps the app (e.g. app/root.jsx):

    • Import Polaris styles: import '@shopify/polaris/build/esm/styles.css';
    • Or link the built CSS from node_modules if the bundler supports it.
    • Ensure the Inter font is loaded (Polaris expects it); the project already has a link to Shopify’s Inter in root.jsx.
  3. Optional: AppProvider
    Polaris can be wrapped in AppProvider for i18n and other context. If the app already uses a provider from @shopify/shopify-app-react-router, confirm how (or whether) to nest Polaris’s AppProvider so there are no duplicate or conflicting wrappers. Prefer a single root provider if possible.

  1. App shell (app/routes/app.jsx):
    Replace or complement custom nav (s-app-nav, s-link) with Polaris navigation components if available (e.g. Navigation, NavItem) so the sidebar/tabs use Polaris look and feel. If the template’s nav is required for embedding, keep it but style it with Polaris tokens or minimal overrides.

  2. Shared layout:
    Ensure every admin page is rendered inside a consistent wrapper so Polaris CSS and tokens apply (e.g. a single layout route that wraps /app and loads Polaris).

  1. AI Chats (app/routes/app.chat-logs.jsx):

    • Use Page for title and optional primary action.
    • Use Card for each session block (accordion-style).
    • Use IndexTable for the list of sessions with expandable rows, or DataTable for the inner “User or AI | Message | Time | Charged” table.
    • Use Badge for “User” / “AI” if desired.
    • Use Text, Box for spacing and typography.
    • Remove inline theme objects and raw <table> in favor of Polaris table components where possible.
  2. Billing (app/routes/app.billing.jsx):

    • Use Page, Card, Layout (or BlockStack/InlineStack).
    • Use DataTable or structured lists for billing history and subscription list.
    • Use Banner for success/error/info (e.g. cancel success, redirecting).
    • Use Button, Text from Polaris.
  3. Settings (app/routes/app.settings.jsx):

    • Use Page, Card, FormLayout, TextField, Select, Checkbox, Button, Banner.
    • Replace custom form markup with Polaris form components where it improves clarity and consistency.
  4. Home (app/routes/app._index.jsx) and Additional (app/routes/app.additional.jsx):

    • Use Page, Card, Text, Button, BlockStack/InlineStack so these pages match the rest of the admin.
  5. Auth / login:

    • Use Polaris Card, TextField, Button, Text for a consistent look with the rest of the app.
  1. Remove or reduce custom styling:

    • Prefer Polaris components and tokens; delete or trim large inline style objects (e.g. the theme object in app.chat-logs.jsx) as you replace them with Polaris.
    • Keep minimal custom CSS only where Polaris doesn’t cover the case (e.g. storefront widget).
  2. Document design decisions:

    • In this doc or in a short “Design system” section in the main docs: “Admin UI uses Shopify Polaris React. Do not introduce another component library for admin without updating this plan.”

  • Install @shopify/polaris and add Polaris CSS (and AppProvider) in root and app layout.
  • Ensure Inter font is loaded; no conflicting global resets.
  • App shell/nav: Polaris AppProvider wraps admin content; nav remains s-app-nav for embedding.
  • app.chat-logs.jsx: Page, Card, DataTable, Badge, Collapsible, Text, BlockStack, InlineStack.
  • app.billing.jsx: Page, Card, DataTable, Banner, Button, Text, ProgressBar, Box, BlockStack, InlineStack.
  • app.settings.jsx: Page, Card, FormLayout, TextField, Select, Checkbox, Button, Banner.
  • app._index.jsx and app.additional.jsx: Page, Card, Text, Button, Link, BlockStack, InlineStack, Box.
  • Auth/login route uses Polaris Page, Card, TextField, Button, BlockStack (with Polaris AppProvider).
  • Custom inline theme objects removed from chat-logs; Polaris components used throughout.
  • Admin UI uses Shopify Polaris React; storefront chat widget theming is separate.

ItemAction
package.jsonAdd @shopify/polaris.
app/root.jsx (or admin layout)Import Polaris CSS; ensure font.
app/routes/app.jsxUse or align nav with Polaris.
app/routes/app.chat-logs.jsxRefactor to Polaris Page, Card, IndexTable/DataTable.
app/routes/app.billing.jsxRefactor to Polaris Page, Card, tables, Banner.
app/routes/app.settings.jsxRefactor to Polaris form components.
app/routes/app._index.jsx, app.additional.jsxUse Polaris Page, Card, Text, Button.
Auth route(s)Use Polaris Card, form controls.
docs/Option-A-Phase-9-theme-and-design-system.mdThis plan; implemented.

  • Chat widget (storefront): Themes and styling for the storefront widget can stay custom or use a small shared token file; document separately.
  • Tailwind: Not required for Phase 9; add later if you want utility-first overrides.
  • Polaris Web Components: Migration to web components can be a future phase once Shopify’s guidance and examples are the default for new apps.

Next: After Phase 9, the admin app will have a single, professional design system (Polaris); new admin pages should use Polaris components and tokens from the start.