harebear-ui 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/AGENTS.md +19 -2
  2. package/README.md +108 -36
  3. package/bin/harebear-ui.mjs +66 -3
  4. package/dist/components/admin/status.d.ts +3 -1
  5. package/dist/components/admin/status.js +5 -2
  6. package/dist/components/ai/approval.d.ts +3 -1
  7. package/dist/components/ai/approval.js +6 -3
  8. package/dist/components/ai/chat.d.ts +5 -2
  9. package/dist/components/ai/chat.js +1 -1
  10. package/dist/components/ai/code-block.d.ts +5 -1
  11. package/dist/components/ai/code-block.js +5 -3
  12. package/dist/components/ai/conversation-list.d.ts +16 -2
  13. package/dist/components/ai/conversation-list.js +88 -37
  14. package/dist/components/ai/model-picker.d.ts +6 -1
  15. package/dist/components/ai/model-picker.js +43 -23
  16. package/dist/components/layout/media-item.d.ts +13 -0
  17. package/dist/components/layout/media-item.js +54 -0
  18. package/dist/components/layout/metric.d.ts +15 -0
  19. package/dist/components/layout/metric.js +51 -0
  20. package/dist/components/layout/show-more.d.ts +17 -0
  21. package/dist/components/layout/show-more.js +30 -0
  22. package/dist/components/layout/stack.d.ts +39 -0
  23. package/dist/components/layout/stack.js +114 -0
  24. package/dist/components/layout/text.d.ts +37 -0
  25. package/dist/components/layout/text.js +52 -0
  26. package/dist/components/theme/theme-toggle.d.ts +4 -1
  27. package/dist/components/theme/theme-toggle.js +11 -6
  28. package/dist/components/ui/badge.d.ts +4 -1
  29. package/dist/components/ui/badge.js +10 -1
  30. package/dist/components/ui/button.d.ts +3 -1
  31. package/dist/components/ui/button.js +13 -3
  32. package/dist/components/ui/empty.d.ts +4 -1
  33. package/dist/components/ui/empty.js +3 -2
  34. package/dist/components/ui/item.d.ts +4 -1
  35. package/dist/components/ui/item.js +7 -2
  36. package/dist/index.d.ts +8 -3
  37. package/dist/index.js +7 -2
  38. package/docs/COMPONENTS.md +96 -71
  39. package/docs/guides/agents.md +75 -0
  40. package/docs/guides/getting-started.md +217 -0
  41. package/docs/guides/theming.md +98 -0
  42. package/llms.txt +6 -1
  43. package/package.json +2 -1
  44. package/skills/harebear-ui/SKILL.md +1 -1
@@ -0,0 +1,217 @@
1
+ # Getting started
2
+
3
+ harebear-ui needs React 19 and Tailwind CSS v4 in your app. Pick your framework below; each setup is about five minutes.
4
+
5
+ - [Vite](#vite)
6
+ - [Next.js (App Router)](#nextjs-app-router)
7
+ - [React Router v7 (framework mode)](#react-router-v7-framework-mode)
8
+ - [Check it works](#check-it-works)
9
+ - [Troubleshooting](#troubleshooting)
10
+
11
+ The fast path for any framework that already has Tailwind v4:
12
+
13
+ ```bash
14
+ npm i harebear-ui
15
+ npx harebear-ui init
16
+ ```
17
+
18
+ `init` finds the CSS file that contains `@import "tailwindcss"`, adds `@import "harebear-ui/styles.css";` after it, writes a harebear-ui section into `AGENTS.md` (or `CLAUDE.md` if that is what you have), and installs a Claude Code skill in `.claude/skills/harebear-ui/`. It is safe to run again: the CSS import is not duplicated and the agent section is replaced in place.
19
+
20
+ | Flag | Effect |
21
+ | -------------- | ------------------------------------------------------------- |
22
+ | `--css <file>` | Use this CSS file. Needed when several files import Tailwind. |
23
+ | `--no-agents` | Skip the `AGENTS.md` / `CLAUDE.md` section. |
24
+ | `--no-skill` | Skip the Claude Code skill. |
25
+
26
+ Then wrap your root (framework sections below show where).
27
+
28
+ ## Vite
29
+
30
+ ```bash
31
+ npm create vite@latest my-app -- --template react-ts
32
+ cd my-app
33
+ npm i tailwindcss @tailwindcss/vite harebear-ui
34
+ ```
35
+
36
+ ```ts
37
+ // vite.config.ts
38
+ import tailwindcss from "@tailwindcss/vite"
39
+ import react from "@vitejs/plugin-react"
40
+ import { defineConfig } from "vite"
41
+
42
+ export default defineConfig({
43
+ plugins: [react(), tailwindcss()],
44
+ })
45
+ ```
46
+
47
+ ```css
48
+ /* src/index.css: replace the contents */
49
+ @import "tailwindcss";
50
+ @import "harebear-ui/styles.css";
51
+ ```
52
+
53
+ ```tsx
54
+ // src/main.tsx
55
+ import { StrictMode } from "react"
56
+ import { createRoot } from "react-dom/client"
57
+ import { ThemeProvider, Toaster, TooltipProvider } from "harebear-ui"
58
+ import App from "./App"
59
+ import "./index.css"
60
+
61
+ createRoot(document.getElementById("root")!).render(
62
+ <StrictMode>
63
+ <ThemeProvider>
64
+ <TooltipProvider>
65
+ <App />
66
+ <Toaster />
67
+ </TooltipProvider>
68
+ </ThemeProvider>
69
+ </StrictMode>,
70
+ )
71
+ ```
72
+
73
+ Tailwind's Vite guide: https://tailwindcss.com/docs/installation/using-vite
74
+
75
+ ## Next.js (App Router)
76
+
77
+ ```bash
78
+ npx create-next-app@latest my-app --typescript --tailwind --app
79
+ cd my-app
80
+ npm i harebear-ui
81
+ ```
82
+
83
+ `create-next-app --tailwind` sets up Tailwind v4 with `@tailwindcss/postcss`. Add the stylesheet after the Tailwind import:
84
+
85
+ ```css
86
+ /* app/globals.css */
87
+ @import "tailwindcss";
88
+ @import "harebear-ui/styles.css";
89
+ ```
90
+
91
+ ```tsx
92
+ // app/layout.tsx
93
+ import type { ReactNode } from "react"
94
+ import { ThemeProvider, ThemeScript, Toaster, TooltipProvider } from "harebear-ui"
95
+ import "./globals.css"
96
+
97
+ export default function RootLayout({ children }: { children: ReactNode }) {
98
+ return (
99
+ <html lang="en" suppressHydrationWarning>
100
+ <head>
101
+ <ThemeScript />
102
+ </head>
103
+ <body>
104
+ <ThemeProvider>
105
+ <TooltipProvider>
106
+ {children}
107
+ <Toaster />
108
+ </TooltipProvider>
109
+ </ThemeProvider>
110
+ </body>
111
+ </html>
112
+ )
113
+ }
114
+ ```
115
+
116
+ - `ThemeScript` sets the `.dark` class before first paint, so dark-mode users don't see a light flash. `suppressHydrationWarning` on `<html>` is needed because that class is added before React hydrates.
117
+ - Every component module ships with `"use client"`, so you can import harebear-ui from server components (layouts, pages) and pass server data in as props.
118
+ - Remove the starter's own `:root` color variables and `body` styles from `globals.css`; they fight the harebear tokens.
119
+ - `AppShell` renders plain `<a>` links by default. Pass `linkComponent={Link}` (from `next/link`) for client-side navigation.
120
+
121
+ Tailwind's Next.js guide: https://tailwindcss.com/docs/installation/framework-guides/nextjs
122
+
123
+ ## React Router v7 (framework mode)
124
+
125
+ ```bash
126
+ npx create-react-router@latest my-app
127
+ cd my-app
128
+ npm i harebear-ui
129
+ ```
130
+
131
+ The template ships Tailwind v4 through `@tailwindcss/vite`. Add the stylesheet:
132
+
133
+ ```css
134
+ /* app/app.css */
135
+ @import "tailwindcss";
136
+ @import "harebear-ui/styles.css";
137
+ ```
138
+
139
+ ```tsx
140
+ // app/root.tsx (Layout only; keep the rest of the file)
141
+ import { ThemeProvider, ThemeScript, Toaster, TooltipProvider } from "harebear-ui"
142
+
143
+ export function Layout({ children }: { children: React.ReactNode }) {
144
+ return (
145
+ <html lang="en" suppressHydrationWarning>
146
+ <head>
147
+ <meta charSet="utf-8" />
148
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
149
+ <ThemeScript />
150
+ <Meta />
151
+ <Links />
152
+ </head>
153
+ <body>
154
+ <ThemeProvider>
155
+ <TooltipProvider>
156
+ {children}
157
+ <Toaster />
158
+ </TooltipProvider>
159
+ </ThemeProvider>
160
+ <ScrollRestoration />
161
+ <Scripts />
162
+ </body>
163
+ </html>
164
+ )
165
+ }
166
+ ```
167
+
168
+ If the template's `app.css` sets its own font (`@theme { --font-sans: ... }`) or page colors (`html, body { @apply bg-white dark:bg-gray-950 }`), remove them, along with any Google Fonts `links` export in `root.tsx`. Geist is bundled and the tokens handle both modes.
169
+
170
+ ## Check it works
171
+
172
+ Render a few components and look at them in both modes:
173
+
174
+ ```tsx
175
+ import { Button, Card, CardContent, CardHeader, CardTitle, StatusBadge, ThemeToggle } from "harebear-ui"
176
+ import { PlusIcon } from "lucide-react"
177
+
178
+ export default function App() {
179
+ return (
180
+ <main className="mx-auto flex max-w-3xl flex-col gap-5 p-8">
181
+ <div className="flex items-center justify-between">
182
+ <h1 className="font-semibold text-2xl">Hello harebear</h1>
183
+ <ThemeToggle />
184
+ </div>
185
+ <Card>
186
+ <CardHeader>
187
+ <CardTitle>Deploys</CardTitle>
188
+ </CardHeader>
189
+ <CardContent className="flex items-center gap-3">
190
+ <StatusBadge tone="success">Healthy</StatusBadge>
191
+ <Button>
192
+ <PlusIcon /> New deploy
193
+ </Button>
194
+ </CardContent>
195
+ </Card>
196
+ </main>
197
+ )
198
+ }
199
+ ```
200
+
201
+ `lucide-react` is a dependency of harebear-ui; add it to your own `package.json` if you import icons directly (`npm i lucide-react`).
202
+
203
+ You should see a white card on a light grey page with Geist text and a blue button. The toggle flips to the dark theme.
204
+
205
+ ## Troubleshooting
206
+
207
+ | Symptom | Cause and fix |
208
+ | ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
209
+ | Components render unstyled | The stylesheet import is missing or comes before `@import "tailwindcss"`. It must come after. |
210
+ | Some classes are missing (spacing, color) | Tailwind v3 is installed. harebear-ui needs v4 (`npm ls tailwindcss`). |
211
+ | Flash of light theme on load (SSR) | Render `<ThemeScript />` in `<head>`. If you pass `storageKey` or `defaultMode` to `ThemeProvider`, pass the same values to `ThemeScript`. |
212
+ | Accent or radius flashes on load (SSR) | `accent` and `radius` props apply after hydration. For SSR, set `--brand` and `--radius` in CSS instead (see [Theming](theming.md)). |
213
+ | Tooltips don't show | `TooltipProvider` is missing near the root. |
214
+ | `toast()` does nothing | `<Toaster />` is not mounted. Import `toast` from `sonner`. |
215
+ | `init` says several Tailwind entry files | Pass the one your app loads: `npx harebear-ui init --css src/index.css`. |
216
+
217
+ Next: [Theming](theming.md) · [Working with AI agents](agents.md) · [Component catalog](../COMPONENTS.md)
@@ -0,0 +1,98 @@
1
+ # Theming
2
+
3
+ Every harebear-ui component reads shadcn-named CSS variables. You change the look in three places, from least to most effort:
4
+
5
+ 1. `ThemeProvider` props: accent, radius, font, default mode.
6
+ 2. CSS variables after the stylesheet import: any token, per mode.
7
+ 3. `className` on a component: one-off layout. Not for colors.
8
+
9
+ ## ThemeProvider
10
+
11
+ ```tsx
12
+ ;<ThemeProvider defaultMode="system" accent="#0f8a7e" radius={10} font="Inter">
13
+ <App />
14
+ </ThemeProvider>
15
+ ```
16
+
17
+ | Prop | Default | What it does |
18
+ | ------------- | ------------------ | --------------------------------------------------------------------------------------------- |
19
+ | `defaultMode` | `"system"` | `"light"`, `"dark"` or `"system"`. Used until the user picks a mode. |
20
+ | `accent` | `#2f5bd3` | Any CSS color. Sets `--brand`; `primary`, `primary-soft`, rings and `chart-1` derive from it. |
21
+ | `radius` | `14` | Base corner radius in px. The `rounded-sm` to `rounded-4xl` scale derives from it. |
22
+ | `font` | Geist | Body font family name. Load the font yourself; Geist and Geist Mono are bundled. |
23
+ | `storageKey` | `"harebear-theme"` | localStorage key for the chosen mode. `null` turns persistence off. |
24
+
25
+ In dark mode `primary` is the accent mixed 26% toward white, so one accent reads well on both backgrounds.
26
+
27
+ ### Change it at runtime
28
+
29
+ ```tsx
30
+ import { useTheme } from "harebear-ui"
31
+
32
+ function AccentPicker() {
33
+ const { accent, setAccent, radius, setRadius, mode, setMode } = useTheme()
34
+ return (
35
+ <>
36
+ <input type="color" value={accent ?? "#2f5bd3"} onChange={(e) => setAccent(e.target.value)} />
37
+ <input type="range" min={0} max={24} value={radius ?? 14} onChange={(e) => setRadius(Number(e.target.value))} />
38
+ <button type="button" onClick={() => setMode(mode === "dark" ? "light" : "dark")}>
39
+ Toggle mode
40
+ </button>
41
+ </>
42
+ )
43
+ }
44
+ ```
45
+
46
+ `ThemeToggle` is the ready-made light/dark icon button. `UserMenu` includes a Light / Dark / System choice.
47
+
48
+ ## CSS variables
49
+
50
+ Override tokens after the import. `:root` is light mode, `.dark` is dark mode:
51
+
52
+ ```css
53
+ @import "tailwindcss";
54
+ @import "harebear-ui/styles.css";
55
+
56
+ :root {
57
+ --brand: #0f8a7e;
58
+ --radius: 0.625rem;
59
+ }
60
+
61
+ .dark {
62
+ --background: #0b0b0d;
63
+ --card: #141417;
64
+ }
65
+ ```
66
+
67
+ Use CSS rather than props when the first paint must be right (SSR apps): `ThemeProvider` applies `accent` and `radius` in an effect, after hydration.
68
+
69
+ The full token list, with what each is for, is in the [component catalog](../COMPONENTS.md#tokens) (`npx harebear-ui docs Tokens`). The ones you will use most:
70
+
71
+ | Token | Tailwind utilities |
72
+ | ----------------------------------- | ------------------------------------------------- |
73
+ | `background`, `foreground` | `bg-background`, `text-foreground` |
74
+ | `card` | `bg-card` (raised surfaces) |
75
+ | `muted`, `muted-foreground` | `bg-muted` (inputs, quiet panels), secondary text |
76
+ | `primary`, `primary-soft` | `bg-primary`, `bg-primary-soft text-primary` |
77
+ | `success`, `warning`, `destructive` | `text-success`, `bg-success/12`, and so on |
78
+ | `border` | `border-border` (the default border color) |
79
+ | elevation | `shadow-card` (the one shadow) |
80
+
81
+ ## Rules that keep a themed app consistent
82
+
83
+ - Colors come from tokens only. No hex values, no Tailwind palette colors (`bg-blue-500`), no inline `style={{ color }}`. A palette color will look wrong in one of the two modes.
84
+ - Status is a tone, not a color: `tone="success" | "warning" | "danger" | "info" | "neutral"` on `StatusBadge`, `StatusDot`, `Badge`, `Timeline`, `StatusBars`, `LinkTile`.
85
+ - Cards are `rounded-xl`, controls are `rounded-md`. Both follow `--radius`.
86
+ - If you reach for `className` to fix a harebear component's color, spacing or border, that is a gap in the library. Open an issue rather than overriding it per screen.
87
+
88
+ ## Fonts
89
+
90
+ Geist (sans) and Geist Mono are bundled and on by default. To use another family, load it however your framework does (`next/font`, `@fontsource`, a `<link>`), then pass its name:
91
+
92
+ ```tsx
93
+ <ThemeProvider font="Inter">
94
+ ```
95
+
96
+ Or set it in CSS: `:root { --hb-font-sans: "Inter", ui-sans-serif, system-ui, sans-serif; }`. Code uses `--hb-font-mono`.
97
+
98
+ Next: [Working with AI agents](agents.md) · [Component catalog](../COMPONENTS.md)
package/llms.txt CHANGED
@@ -20,6 +20,10 @@
20
20
  ## Docs
21
21
 
22
22
  - [Component catalog](docs/COMPONENTS.md): every export with props and examples. In an installed app: node_modules/harebear-ui/docs/COMPONENTS.md
23
+ - Look up single entries instead of reading it all: `npx harebear-ui docs DataTable StatCard` (export names, a prefix like `Prompt`, or a section like `Tokens`). Exits 1 when nothing matches.
24
+ - [Getting started](docs/guides/getting-started.md): setup for Vite, Next.js App Router and React Router v7, plus troubleshooting.
25
+ - [Theming](docs/guides/theming.md): ThemeProvider props, CSS token overrides, fonts, SSR.
26
+ - [Working with AI agents](docs/guides/agents.md): what init installs, per-tool setup, prompts, review checklist.
23
27
  - [Agent skill](skills/harebear-ui/SKILL.md): Claude Code skill, installed by `npx harebear-ui init`.
24
28
  - [Example screens](https://github.com/hmilbradt/harebear-ui/tree/main/playground/screens): admin dashboard, AI chat, data table + detail panel, status home page, auth pages, component catalog.
25
29
  - [Source](https://github.com/hmilbradt/harebear-ui)
@@ -28,8 +32,9 @@
28
32
 
29
33
  Theme: ThemeProvider, useTheme, ThemeToggle, ThemeScript
30
34
  Layout/admin: SidebarLayout, SidebarCollapseButton, AppShell, AppBrand, PageHeader, StatCard, SearchInput, StatusDot, StatusBadge, UsageMeter, ActivityFeed, Timeline, KeyValueGrid, UserChip, UserMenu, Callout, LinkTile, ConfirmDialog, CopyField
35
+ Layout and text: Stack, Row, Grid, Text, Heading, Metric, MetricGroup, MediaItem, ShowMore
31
36
  Data: DataTable, createDataTableColumnHelper, TrendChart, TrendLegend, BarList, Sparkline, StatusBars
32
- AI/chat composites: ChatShell, ChatPanel, ChatThread, ChatMessage, AssistantAvatar, MessageActions, PromptInput, PromptInputChip, PromptInputSelect, ModelPicker, ConversationList, NewConversationButton, groupByDate, ToolCall, ToolGroup, ToolStep, ToolStatusIcon, ApprovalCard, ApprovalResult, TypingIndicator, CodeSnippet, InlineCode, Prose
37
+ AI/chat composites: ChatShell, ChatPanel, ChatThread, ChatMessage, AssistantAvatar, MessageActions, PromptInput, PromptInputChip, PromptInputSelect, ModelPicker, ConversationList, NewConversationButton, groupByDate, formatWhen, ToolCall, ToolGroup, ToolStep, ToolStatusIcon, ApprovalCard, ApprovalResult, TypingIndicator, CodeSnippet, InlineCode, Prose
33
38
  AI/chat primitives (shadcn): Message, Bubble, MessageScroller, Attachment, Trace, Marker, Questionnaire, CodeBlock
34
39
  Auth: AuthLayout, LoginForm, SignupForm, GitHubIcon, GoogleIcon, AppleIcon
35
40
  Primitives (the full shadcn/ui registry): Accordion, Alert, AlertDialog, AspectRatio, Attachment, Avatar, Badge, Breadcrumb, Bubble, Button, ButtonGroup, Calendar, Card, Carousel, Chart, Checkbox, CodeBlock, Collapsible, Combobox, Command, ContextMenu, Dialog, DirectionProvider, Drawer, DropdownMenu, Empty, Field, HoverCard, Input, InputGroup, InputOTP, Item, Kbd, Label, Marker, Menubar, Message, MessageScroller, NativeSelect, NavigationMenu, Pagination, Popover, Progress, Questionnaire, RadioGroup, Resizable, ScrollArea, Select, Separator, Sheet, Sidebar, Skeleton, Slider, Spinner, Switch, Table, Tabs, Textarea, Toaster, Toggle, ToggleGroup, Tooltip, Trace
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "harebear-ui",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "Opinionated, pre-themed shadcn/ui component library for React 19 + Tailwind CSS v4. Admin, data, and AI chat building blocks, ready for agents.",
5
5
  "license": "MIT",
6
6
  "author": "Harrison Milbradt",
@@ -58,6 +58,7 @@
58
58
  "lint": "biome check .",
59
59
  "format": "biome check --write .",
60
60
  "test": "vitest run",
61
+ "shots": "node scripts/screenshots.mjs",
61
62
  "check": "pnpm lint && pnpm typecheck && pnpm test && pnpm build && publint && attw --pack . --profile esm-only --exclude-entrypoints ./styles.css ./llms.txt",
62
63
  "prepublishOnly": "pnpm check"
63
64
  },
@@ -10,7 +10,7 @@ This project uses `harebear-ui` for all UI. Its theme, tokens, and components ar
10
10
 
11
11
  ## Before writing UI
12
12
 
13
- 1. Read the catalog: `node_modules/harebear-ui/docs/COMPONENTS.md`. It lists every export with props and examples.
13
+ 1. Read the catalog: `node_modules/harebear-ui/docs/COMPONENTS.md`. It lists every export with props and examples. To pull only what you need, run `npx harebear-ui docs DataTable StatCard` (export names, a name prefix such as `Prompt`, or a section such as `Tokens`).
14
14
  2. Pick existing components first. Build new components only by composing harebear-ui parts.
15
15
  3. For a whole screen, start from the closest reference screen: admin dashboard, AI chat, data table with detail panel, status home page, or auth (https://github.com/hmilbradt/harebear-ui/tree/main/playground/screens).
16
16