# `@aisquare/ui/console` and `console.css`

A slim entry for console apps: Explainability v2 (Tailwind 3) and aisquare-fe (Tailwind 4). It exports the branded
primitives a console uses, and ships the CSS for them pre-built, so the app neither pulls the whole library (root
entry: about +210 KB JS in v2's first-load chunk) nor scans `node_modules/@aisquare/ui` (about +74 KB CSS in v2).
`./stock` is not a substitute: it has no Badge, Tag or Skeleton, and its `form.js` needs `react-hook-form` to build.

## Use

```ts
import { Badge, Tag, Skeleton, Table, TableRow, Tabs, TabsList, TabsTrigger, cn } from "@aisquare/ui/console";
import "@aisquare/ui/console.css"; // once, at the app root
```

Do **not** add `node_modules/@aisquare/ui/dist` to Tailwind `content`: that is what `console.css` replaces.

**Variables.** `console.css` only contains classes. Colours stay `hsl(var(--primary))` style, so the app must define the
semantic names (`--background`, `--primary`, `--border`, ... as bare HSL triplets). Shape reads `--ui-*` variables with a
fallback equal to the value the component computed before the variable existed (`rounded-[var(--ui-badge-radius,9999px)]`),
so with no theme loaded nothing changes. The `--ui-*` seams arrive with the theme layer (PR #301, `themes/*.css`):
`console.css` is generated from whatever source the entry reaches, so the file shipped after #301 merges carries them
(checked on #301's branch: 43.4 KB raw, 8.7 KB gzip, with the seams).

### Explainability v2 (Tailwind 3)

```css
@import "@aisquare/ui/themes/v2.css";   /* after #301 */
@import "@aisquare/ui/console.css";
```

Set `data-ui-theme="v2"` on `<html>`. v2's `tailwind.config` needs no library `content` entry and no library preset for
these components; keep its own.

### aisquare-fe (Tailwind 4)

```css
@import "@aisquare/ui/themes/fe.shape.css";  /* shape only, after #301 */
@import "@aisquare/ui/console.css";
```

aisquare-fe writes `--background`, `--primary`, ... as **hex**, while the library reads them as bare HSL triplets, so
colour classes (`bg-primary` is `hsl(var(--primary))`) need the colours scoped to a subtree (`fe.css`, which carries
triplets) or an app-side triplet alias. This is the same collision `docs/THEMES.md` (PR #301) describes; `console.css`
does not change it.

## What the stylesheet is

- Generated by Tailwind 3 over exactly the source files the entry reaches (`scripts/build-console-css.mjs`, `pnpm build`).
- **No preflight, no element reset.** The only universal rule is the `--tw-*` variable defaults (`*,::before,::after`);
  they are needed by ring, shadow and transform utilities and set no visual property. In a Tailwind 4 app they coexist
  with its own `--tw-*`.
- The library's token variables (foundation ramps, motion durations, elevation) are written as `:where(:root)` and
  `:where(.dark)`: zero specificity, so a consumer value for the same name always wins and loading the file cannot retint
  the app.
- Variables it reads but does not define: the semantic colours above, `--radius`, `--font-mono`, `--shadow-glow`,
  `--premium`. Define them (the theme files do) or the matching class falls back to the browser default.

## Size

| | raw | gzip |
|---|---|---|
| `console.css` (main) | 41,976 B | 8,396 B |
| `console.css` (with #301 seams) | 43,393 B | 8,738 B |

With everything step 5 adds (ConsoleCard, ConsoleEmptyState, ConsoleCallout, Alert, Progress and Avatar; the Button and
field seams; StatusChip and MeterBar) the file is 84,381 B raw / 14.5 KB gzip at this branch (arbitrary-property classes that read `--ui-*` variables are
verbose). The budget is **88,000 B raw**, one assertion in `src/console.test.ts`.

JS, measured in a throwaway Vite 5 + React 18 app that imports Badge, Skeleton, Table, Tabs and `console.css`
(react-dom alone is 142.4 KB raw / 45.7 KB gzip): **+45.4 KB raw / +14.8 KB gzip**. Of that, `cn` alone
(tailwind-merge + clsx) is +20.5 KB raw / +6.7 KB gzip, which an app that already ships tailwind-merge does not pay
again. Compare v2's headroom (JS 1044 of 1060 KB used, CSS 149 of 150 KB): the CSS does not fit on top of v2's current
stylesheet, so v2 adopts it by deleting the matching hand-written Badge/Skeleton/Table/Tabs CSS in the same change.

## Exported

- Helpers: `cn`, `PortalContainerProvider`, `usePortalContainer`.
- Library primitives: Badge, Tag, StatusChip, MeterBar, Skeleton (+ `SkeletonParagraph`), Button, Input, Textarea,
  Checkbox, Switch, Label, Tooltip (+ `SimpleTooltip`), DropdownMenu (+ parts).
- Console stand-ins (motion-free, theme-variable-driven, for Card, EmptyState and a Callout): ConsoleCard (+ Header,
  Title, Description, Action, Body, Footer), ConsoleEmptyState, ConsoleCallout.
- Type roles (docs/THEMES.md): Text, Heading.
- Stock shadcn (no brand wrapper yet, same tokens): Alert (+ Title, Description), Progress, Avatar, Table (+ parts),
  Tabs (+ parts), Select (+ parts), Popover, Dialog (+ parts).

## Excluded, and why

| Component | Reason |
|---|---|
| Card (+ parts) | imports `motion` (hover lift) and Image/PixelCard; no motion-free variant exists |
| EmptyState | imports `motion` (entrance) |
| Everything else in the root entry | not console-relevant, or reaches an excluded package |

Packages that must not be reachable (guarded by `src/console.test.ts`, which walks the source graph and the built
`dist/console.js`): `react-hook-form`, `zod`, `@hookform/resolvers`, `lenis`, `canvas-confetti`, `recharts`, `gsap`,
`motion`, `react-markdown`, `react-syntax-highlighter`, `cmdk`, `sonner`. The only packages the entry may import are
react, radix-ui and `@radix-ui/*`, class-variance-authority, clsx and tailwind-merge.

Card and EmptyState stay out and byte-unchanged; `ConsoleCard` and `ConsoleEmptyState` are their motion-free stand-ins
for console apps. Sheet is also not in the entry: it imports the icon set.

## Adding to the entry

Add the export to `src/console.ts`, run `pnpm test:ci` (the graph test fails if a heavy package becomes reachable) and
`pnpm build` (regenerates `dist/console.css`). Take the component out rather than editing the guard lists.
