# UI Library

import { Callout } from "fumadocs-ui/components/callout";
import { Accordion, Accordions } from "fumadocs-ui/components/accordion";
import {
  Box,
  Palette,
  PanelsTopLeft,
  Accessibility,
  Code2,
  Route,
} from "lucide-react";
import { DocsLinks } from "@/components/docs/docs-links";
import { DocsComponentCatalog } from "@/components/docs/docs-component-catalog";
import { DocsSectionLinks } from "@/components/docs/docs-section-links";

<DocsSectionLinks
  items={[
  { title: "Setup", href: "#build-interfaces-that-scale-with-your-product" },
  { title: "Components", href: "#start-with-the-essentials" },
  { title: "Live examples", href: "#interactive-component-examples" },
]}
/>

## Build interfaces that scale with your product

Start with a React app and Tailwind CSS v4. Install the public packages, load the styles, and verify one component before building a larger screen.

<DocsLinks
  variant="list"
  tone="neutral"
  items={[
  {
    title: "Install the library",
    href: "/docs/ui/installation",
    description:
      "Add the packages, configure Tailwind, and render your first component.",
    icon: Box,
  },
  {
    title: "Make it your own",
    href: "/docs/ui/theming",
    description:
      "Apply your brand through shared tokens and light and dark themes.",
    icon: Palette,
  },
]}
/>

## Start with the essentials

Each component reference includes a working preview, copyable code, API details, and accessibility guidance.

<DocsComponentCatalog />

## Interactive component examples

Open [PyColors UI Explorer](https://ui.pycolors.io) to try component states and keyboard interactions in light and dark themes. Each component page links directly to its example.

To set up examples in your own app, follow the [consumer Storybook guide](/docs/ui/storybook). You can also try a [complete interface preview](/ui#ui-preview) or create a palette in [Theme Builder](/tools/theme-builder).

## Composition rules

Keep the parts small and connect them in your application:

* **Use semantic tokens.** Utilities such as `bg-card`, `text-muted-foreground`, and `border-border` keep components consistent across themes.
* **Compose a screen from primitives.** Combine fields, buttons, cards, and feedback around one task.
* **Keep product logic in your app.** Routing, data fetching, authentication, and billing remain application responsibilities.

<Callout title="Start with one working screen">
  Verify styling, keyboard focus, and the app build before replacing a larger
  product area. The [installation
  checklist](/docs/ui/installation#verify-the-first-screen) covers these checks.
</Callout>

## When to use Patterns

Use a component for one part of an interface. Use a pattern when several components need to work together, such as validation, pagination, or mutation feedback.

<DocsLinks
  variant="grid"
  tone="neutral"
  items={[
  {
    title: "Compose common flows",
    href: "/docs/ui/usage-patterns",
    description:
      "Try settings forms, dialogs, paginated tables, and save feedback.",
    icon: PanelsTopLeft,
  },
  {
    title: "Build from a block",
    href: "/docs/blocks",
    description:
      "Copy a composed section when you need a larger starting point.",
    icon: Code2,
  },
]}
/>

## Next steps

<DocsLinks
  variant="list"
  tone="neutral"
  items={[
  {
    title: "Accessibility",
    href: "/docs/ui/accessibility",
    description:
      "Review labels, keyboard behavior, focus, and feedback in your application.",
    icon: Accessibility,
  },
  {
    title: "Migration guidance",
    href: "/docs/ui/migration-guidance",
    description:
      "Adopt components incrementally in an existing React or Next.js app.",
    icon: Route,
  },
]}
/>

<Accordions className="mt-8">
  <Accordion title="Contributing to the component examples" id="maintaining-examples">
    Contributors can run Storybook from the repository root:

    ```bash
    pnpm --filter @pycolors/ui storybook
    ```

    Canonical examples live in `packages/ui/stories/components/<family>.stories.tsx`.
    The public `src/index.ts` barrel remains the source of truth for supported families.
    Foundations demonstrate existing tokens; compositions are small synthetic examples.
    The local navigation orders Foundations, Components, then Compositions.

    When a public component or meaningful state changes:

    1. Update its typed family module with an explicit `components-<family>` ID,
       stable story exports, a `Default`, a useful description and its Fumadocs link.
       Import through `../../src/index.js`, never a component's internal file.
    2. Expose only supported args/controls. Controlled examples own their state;
       keep labels, native/Radix semantics, tokens and both themes intact.
    3. Update the matching component tests and Fumadocs page when behavior changes.
       Run `pnpm --filter @pycolors/ui verify`, `pnpm check:ui-package`, and
       `pnpm --filter pycolors-marketing types:check` for documentation changes.
    4. Install Chromium with `pnpm --filter @pycolors/ui test:storybook:install`,
       then run `pnpm --filter @pycolors/ui test:storybook` for interactions,
       accessibility scans, light/dark and desktop/mobile checks. Check generated
       story IDs separately. Automated checks do not replace assistive-technology
       and visual review; setup, selection and diagnostics are in the story guide.
    5. Preserve old IDs through shared-render compatibility entries when migrating
       links. The migration ledger and deprecation rules live in
       `packages/ui/stories/README.md`; the legacy module contains no new examples.

    Story-only changes do not need a package release. Public API/behavior changes
    retain their normal Changeset, test and documentation requirements. Public stories
    must contain only public primitives and fixtures: no Pro source, private imports,
    credentials or customer data. See `packages/ui/stories/README.md` in the repository for contributor setup and story ID conventions.
  </Accordion>
</Accordions>