# @mieweb/ui — MIE design system (v0.12.1)
> React component library and design system by MIE. This index is for AI
> agents: start at the agent entry document, follow the rules document for
> all UI work, and fetch skills/guides as the task demands. The library is
> installed from npm as `@mieweb/ui`; human docs are at https://ui.mieweb.org/.
>
> If your browsing tool refuses to open links discovered in this document,
> do not stall or ask for file uploads: ask the user to paste the specific
> URLs into the chat — pasted URLs fetch successfully.
## Start here
- [Agent entry — setup recipes, routing, full index](https://ui.mieweb.org/agent.md): how
to set up the package in any environment and which document answers what
- [Rules for AI agents](https://ui.mieweb.org/instructions.md): non-negotiable project
rules (NITRO-first tables, tokens not hardcoded colors, lucide-react
icons, a11y, i18n/RTL)
- [API cheat sheet](https://ui.mieweb.org/api-cheatsheet.md): verified prop signatures
for the components agents most often guess wrong (Select, Checkbox,
Modal, NITRO grid wire format) — read before writing component code
## Skills (reference knowledge)
- [mieweb-ui-a11y-checklist](https://ui.mieweb.org/skills/mieweb-ui-a11y-checklist.md): Accessibility audit procedure for apps built with @mieweb/ui — ARIA naming, keyboard navigation, focus management, color contrast, and live-region announcements, plus the library's a11y toolkit (useFocusTrap, useLiveAnnouncement, VisuallyHidden, useDragReorder) and known contrast traps.
- [mieweb-ui-brands](https://ui.mieweb.org/skills/mieweb-ui-brands.md): Brand theming for @mieweb/ui — available brands, switching brands at build or runtime, the dark-mode model, and the step-by-step procedure for creating a new brand.
- [mieweb-ui-catalog](https://ui.mieweb.org/skills/mieweb-ui-catalog.md): Component inventory and selection guidance for the @mieweb/ui design system.
- [mieweb-ui-catalog — selection-guidance](https://ui.mieweb.org/skills/mieweb-ui-catalog-selection-guidance.md): Companion document to the mieweb-ui-catalog skill.
- [mieweb-ui-charts](https://ui.mieweb.org/skills/mieweb-ui-charts.md): Chart, map, globe and presentation components of @mieweb/ui — Sparkline, DataVisNitroGraph pointer, Deck slide decks, Globe, PointMap, OrgChart, TileCartogramSection and the report-template sections.
- [mieweb-ui-clinical](https://ui.mieweb.org/skills/mieweb-ui-clinical.md): Clinical components of @mieweb/ui — PatientHeader, ProblemList/PresentingProblems/ConditionEditor, MedicationList/MedicationReconciliation, AllergyList/AllergyManager, Assessment, OrderEditor, HealthSurveillance, ResultsEntryForm, EncounterVisit, CodeLookup wiring.
- [mieweb-ui-datavis-api](https://ui.mieweb.org/skills/mieweb-ui-datavis-api.md): Deep API reference for @mieweb/ui grids — DataVis NITRO (DataVisNitroSource/Grid/Graph, column API, feature flags, grouping/aggregates, operations palette, perspectives) and the eSheet form pair (Builder/Renderer, registerMieEsheetFields, EncounterVisit).
- [mieweb-ui-i18n-checklist](https://ui.mieweb.org/skills/mieweb-ui-i18n-checklist.md): Internationalization and RTL audit procedure for apps built with @mieweb/ui — string externalization, locale-bundle completeness, Intl formatting with the active locale, and RTL-safe layout (logical properties, direction-aware JS), plus the library's direction toolkit (useDirection, isRtl, isRtlLocale) and known RTL layout gotchas.
- [mieweb-ui-icons](https://ui.mieweb.org/skills/mieweb-ui-icons.md): Icon usage for the @mieweb/ui design system — the lucide-react policy, the *Icon aliases re-exported from @mieweb/ui, sizing conventions, and icon accessibility.
- [mieweb-ui-kerebron](https://ui.mieweb.org/skills/mieweb-ui-kerebron.md): Integrating @mieweb/ui rich-text editors — the Kerebron entry (RichEditor, CodeEditor, TextAreaRich), the Kerebron-backed main-barrel Textarea, EmailEditor, and MarkdownRenderer — including the exact-0.8.12 peer set, ProseMirror version overrides, WASM grammar serving, the consumer-side @kerebron patches, Yjs collaboration and its degrade path.
- [mieweb-ui-superchat](https://ui.mieweb.org/skills/mieweb-ui-superchat.md): Chat, AI and media-conversation components of @mieweb/ui — SuperChat/SuperChatInbox/SuperChatConversations, AIChat/OzwellChat/AIMessage/MCPToolCall, ChatComposer, Messaging primitives, and the media stack (AudioPlayer, MediaPlayer, MediaFeed, TranscriptView, MediaEditor, AudioRecorder, RecordButton, DictationButton, DocumentScanner).
- [mieweb-ui-tailwind4](https://ui.mieweb.org/skills/mieweb-ui-tailwind4.md): Installing and wiring @mieweb/ui in a consumer app — Tailwind 4 `@source` setup vs the Tailwind 3 preset, PostCSS config, dark-mode variant and CSS-variable fallbacks, peer dependencies per entry point, and connecting headless modules to a data layer.
- [mieweb-ui-templates](https://ui.mieweb.org/skills/mieweb-ui-templates.md): Marketing and report page sections of @mieweb/ui/templates — HeroSection, CtaSection, PricingSection, FaqSection, TestimonialSection, LeadFormSection, FeatureGridSection, StatsSection, LogoCloudSection and friends, plus the LandingPage renderer, landingPresets archetypes and validateLandingPage.
- [mieweb-ui-tokens](https://ui.mieweb.org/skills/mieweb-ui-tokens.md): Design tokens for the @mieweb/ui design system — color scales, semantic colors, radius, typography, shadows, animations, and how CSS variables and dark mode work.
- [mieweb-ui-views](https://ui.mieweb.org/skills/mieweb-ui-views.md): Views & layout components of @mieweb/ui — the ViewSet system (ListView, BoardView, CalendarView, GanttView, ViewSwitcher), dashboards (DashboardWidget, CustomizableDashboard), panels (DockablePanel, FloatingWindow) and the app shell (Sidebar, AppHeader, PageHeader).
## Guides (domain workflows)
- [MIE UI A11y Agent](https://ui.mieweb.org/guides/a11y.md): Accessibility auditor for apps built with @mieweb/ui — ARIA naming, keyboard navigation, focus management, color contrast, and live-region announcements.
- [MIE UI DataVis Agent](https://ui.mieweb.org/guides/datavis.md): Visualization specialist for the @mieweb/ui design system — charts, maps, globes, decks and org charts (Sparkline, DataVisNitroGraph boundary, Deck, Globe, PointMap, OrgChart, TileCartogramSection, report-template sections).
- [MIE UI Grids Agent](https://ui.mieweb.org/guides/grids.md): Grids specialist for the @mieweb/ui design system — DataVis NITRO (DataVisNitroSource/Grid/Graph, column API, feature flags, grouping/aggregates, operations palette, perspectives) and the eSheet form pair (Builder/Renderer, clinical fields, EncounterVisit).
- [MIE UI i18n Agent](https://ui.mieweb.org/guides/i18n.md): Internationalization and RTL auditor for apps built with @mieweb/ui — string externalization, locale-bundle completeness, Intl formatting with the active locale, and right-to-left layout.
- [MIE UI Install Agent](https://ui.mieweb.org/guides/install.md): Installation & setup diagnostician for the @mieweb/ui design system — peer dependencies, Tailwind 4 `@source` vs the Tailwind 3 preset/safelist, PostCSS config, CSS entry wiring, dark-mode plumbing, and pnpm resolution quirks.
- [MIE UI Migration Agent](https://ui.mieweb.org/guides/migration.md): Migration and compliance auditor for bringing codebases onto @mieweb/ui — raw-HTML-to-component pattern enforcement (badge spans, card divs, raw buttons, tables to DataVis NITRO), hand-rolled SVG to lucide-react, CSS foundation checks, and legacy-framework migration planning (Meteor/Blaze to React).
- [MIE UI Rich Text Agent](https://ui.mieweb.org/guides/richtext.md): Rich-text editing specialist for the @mieweb/ui design system — the Kerebron entry (RichEditor, CodeEditor, TextAreaRich), the Kerebron-backed main-barrel Textarea, EmailEditor, MarkdownRenderer, Yjs collaboration, WASM grammar serving, the exact-0.8.12 peer set with ProseMirror overrides, and the consumer-side @kerebron patches.
- [MIE UI Styling Agent](https://ui.mieweb.org/guides/styling.md): Styling & theming specialist for the @mieweb/ui design system — design tokens, Tailwind classes, CSS variables, brands and brand switching, dark mode, and motion/animation.
- [MIE UI SuperChat Agent](https://ui.mieweb.org/guides/superchat.md): Chat & media-conversation integration specialist for the @mieweb/ui design system — SuperChat/SuperChatInbox/SuperChatConversations, AIChat/OzwellChat and the AI message components, ChatComposer, Messaging primitives, and the media stack (players, recorders, transcripts, DocumentScanner).
- [MIE UI Views Agent](https://ui.mieweb.org/guides/views.md): Views & layout architect for the @mieweb/ui design system — the ViewSet system (ListView, BoardView, CalendarView, GanttView, ViewSwitcher), dashboards (DashboardWidget, CustomizableDashboard), panels (DockablePanel, FloatingWindow) and the app shell (Sidebar, AppHeader, PageHeader).
---
---
applyTo: '**/*.{ts,tsx,js,jsx}'
---
<!-- Generated by `npx @mieweb/ui init-agent`. Do not edit by hand — rerun the command after upgrading @mieweb/ui to refresh. -->
# @mieweb/ui — Rules for AI Agents
This project uses the `@mieweb/ui` component library. Follow these rules for ALL UI work. Browse the full catalog at https://ui.mieweb.org (Storybook).
## Rule 1: Tables start with DataVis NITRO
> **Tables and data grids start with DataVis NITRO.** Use `Table` only for a few static rows the user will not sort, filter, page or export. Never hand-roll grid features on a plain table; `AGGrid` is deprecated.
When asked to create a table, data grid, or any tabular data view:
- **Propose `DataVisNitroGrid` from `@mieweb/ui/datavis` first, every time.**
- Use the `Table` component from `@mieweb/ui` (`Table` + `TableHeader`/`TableBody`/`TableRow`/`TableCell`) only when the data meets the criterion above — a few static rows, no sorting, filtering, paging or export — or when the human explicitly asks for a plain table after you have proposed NITRO.
- **`AGGrid` is deprecated.** Never import from `@mieweb/ui/ag-grid` in new code.
- **Never hand-roll a data grid** from raw `<table>`, `<div>` grids, or a third-party grid library.
- Full comparison: the [Grids family page](https://ui.mieweb.org/?path=/docs/components-grids-overview--docs).
```tsx
import { DataVisNitroSource, DataVisNitroGrid } from '@mieweb/ui/datavis';
// Self-contained entry: @mieweb/datavis is bundled in and datavis-ace ships as
// a dependency of @mieweb/ui — no extra installs needed to use these.
```
## Rule 2: Buttons belong in a ButtonGroup
- **Two or more adjacent buttons → always wrap them in `ButtonGroup`.** Never lay out sibling buttons with ad-hoc flex/gap divs.
- **A single button with a long or unpredictable label** (sentence-like labels, translated text, user-provided data — e.g. "Permanently delete this record") **→ also wrap it in a `ButtonGroup`.** The default `orientation="auto"` measures labels and controls text ellipsis/stacking so long labels never truncate silently.
- A single button with a short, fixed label ("Save", "OK") may stand alone.
- **Icon-only buttons** → `<Button size="icon" aria-label="...">`. The `aria-label` is required.
```tsx
import { Button, ButtonGroup } from '@mieweb/ui';
// Multiple buttons
<ButtonGroup split>
<Button variant="ghost">Back</Button>
<Button variant="secondary">Cancel</Button>
<Button variant="danger">Permanently delete this record</Button>
</ButtonGroup>
// Single button, long/dynamic label
<ButtonGroup>
<Button>{t('orders.submitForPriorAuthorization')}</Button>
</ButtonGroup>
```
## Rule 3: Use an existing @mieweb/ui component before writing your own
Before writing any UI element, check whether `@mieweb/ui` already provides it. The Storybook sidebar is organised as _Tier / Family / Component_ (the live count is in `catalog-manifest.json` next to the published Storybook, or `pnpm catalog:check` in the repo); every family has an **Overview** page with a comparison table — read it before choosing. Families include:
| Tier / Family | Components |
| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| Inputs / Actions | `Button`, `ButtonGroup` (see Rule 2), `Toggle`, `CopyButton`, `QuickAction`, `RowActionToolbar` |
| Inputs / Text, Choice, Date & time | `Input`, `Textarea`, `PhoneInput`, `Select`, `Dropdown`, `Autocomplete`, `Checkbox`, `Radio`, `Switch`, `Slider`, `DateInput`, `DateRangePicker` |
| Components / Grids | `DataVisNitroGrid` (default for all tables), `Table` (see Rule 1), `Pagination`, `Sparkline` — `AGGrid` is **deprecated** |
| Components / Data display, Layout | `Badge`, `Avatar`, `CountBadge`, `Timeline`, `Card`, `Accordion`, `AppHeader`, `PageHeader`, `Text` (Foundations) |
| Components / Feedback, Loading | `Alert`, `Toast`, `AlertDialog`, `NotificationCenter`, `ErrorPage`, `Spinner`, `Skeleton`, `Progress`, `LoadingPage` |
| Components / Overlays, Navigation | `Modal`, `Sheet`, `Tooltip`, `DockablePanel`, `Sidebar`, `Tabs`, `Breadcrumb`, `StepIndicator`, `CommandPalette` |
| Modules | Dashboards, Media (`AudioPlayer`, `AudioRecorder`, `DocumentScanner`), Editors (`RichEditor`, `Markdown`), Chat, Voice, Files |
| Healthcare | `ProblemList`, `MedicationList`, `AllergyList`, `CodeLookup`, `OrderEditor`, `Assessment`, `PatientHeader` |
| BlueHive (product-specific) | Orders, Employers, Billing, Providers, Services — reuse only if your app shares the BlueHive data model |
Raw HTML that duplicates a component is a violation, even if it looks right:
```tsx
// ❌ Violations
<button onClick={save}>Save</button>
<span className="rounded-full bg-blue-100 px-2 py-1 text-xs">Active</span>
<div className="rounded-lg border p-4 shadow">...</div>
<table>...</table>
// ✅ Compliant
<Button onClick={save}>Save</Button>
<Badge>Active</Badge>
<Card><CardContent>...</CardContent></Card>
<DataVisNitroGrid ... />
```
## Rule 4: Use composition slots, not custom markup
Components ship structural sub-components — use them instead of bespoke divs inside a component:
- `Modal` → `ModalHeader` / `ModalBody` / `ModalFooter`
- `Card` → `CardHeader` / `CardContent`
- `Table` → `TableHeader` / `TableBody` / `TableRow` / `TableCell`
```tsx
// ❌ <Modal open={open}><div className="p-4 border-b font-bold">Title</div>...</Modal>
// ✅
<Modal open={open} onClose={close}>
<ModalHeader>Title</ModalHeader>
<ModalBody>...</ModalBody>
<ModalFooter>...</ModalFooter>
</Modal>
```
## Rule 5: Use variants and sizes, not className hacks
If a component has a prop for it, use the prop. Never restyle a component with utility classes to imitate an existing variant.
```tsx
// ❌ <Button className="bg-red-600 text-white hover:bg-red-700">Delete</Button>
// ✅ <Button variant="danger">Delete</Button>
// ❌ <Button className="text-xs px-2 py-1">Save</Button>
// ✅ <Button size="sm">Save</Button>
```
Button variants: `primary`, `secondary`, `ghost`, `outline`, `danger`, `link`. Sizes: `sm`, `md`, `lg`, `icon`.
## Rule 6: Never hardcode colors
Use design tokens so multi-brand theming (mieweb, bluehive, webchart, enterprise-health, …) keeps working:
- ❌ `bg-blue-500`, `text-[#1a73e8]`, `style={{ color: 'red' }}`
- ✅ semantic tokens: `bg-primary-600`, `text-muted-foreground`, `border-border`, `bg-background`
- ✅ charts: `var(--mieweb-chart-1)` … `var(--mieweb-chart-5)`
## Rule 7: Theme through the brand system, never global CSS
- Wrap the app in `ThemeProvider`; use `@mieweb/ui/brands` (`generateBrandCSS`, `brands`) for brand switching.
- **No global resets or element-selector overrides** (`button { … }`, `* { … }`). Styles stay component-scoped and minimal.
## Rule 8: Feedback states use library components
- Loading: `Spinner` (inline), `Skeleton` (content placeholder), `LoadingPage` (full page). Never a hand-rolled CSS spinner.
- Outcomes: `Alert` (inline), `Toast` (transient — announces via aria-live for free). Never a bespoke alert div.
- Errors/empty pages: `ErrorPage`. Progress: `Progress`.
## Rule 9: Accessibility is not optional
- Every interactive element needs an accessible name (`aria-label`, `aria-labelledby`, or visible text).
- Use semantic HTML (`nav`, `main`, `button`) — never a clickable `div`.
- Dynamic updates (modals, alerts, notifications) must be announced — prefer `Toast`/`Alert`, which handle aria-live.
- Preserve logical tab order and visible focus indicators; never remove focus outlines.
## Rule 10: Internationalization and RTL
- **Externalize all user-facing text** — no hardcoded English strings in JSX. Use the project's i18n function (`t('…')`).
- **Use RTL-safe logical classes**: `ms-*`/`me-*`, `ps-*`/`pe-*`, `start-*`/`end-*`, `text-start`/`text-end` — never `ml-*`/`mr-*`, `pl-*`/`pr-*`, `left-*`/`right-*`, `text-left`/`text-right`.
- Localize dates, numbers, and currency via `Intl` APIs, not string formatting.
## Rule 11: Forms
- Always use library fields (`Input`, `Textarea`, `Select`, `Checkbox`, `Radio`, `Switch`, `Slider`) with a properly associated `<label>`.
- Dates → `DateInput` / `DateRangePicker`, never raw `type="date"`. Phones → `PhoneInput`. URLs → `WebsiteInput`.
## Rule 12: Imports and Tailwind setup
```tsx
// Most components: named imports from the main barrel
import { Button, Input, Card, Modal, Badge } from '@mieweb/ui';
// Heavy add-ons live behind subpath entries (install their peer deps):
import { DataVisNitroGrid } from '@mieweb/ui/datavis'; // tables/grids
import { generateBrandCSS, brands } from '@mieweb/ui/brands'; // branding
```
Never import from `@mieweb/ui/ag-grid` (deprecated).
Tailwind: on Tailwind 4, add an `@source` for `@mieweb/ui` so library classes are generated; on Tailwind 3, use the `@mieweb/ui/tailwind-preset` preset and `miewebUISafelist`. Do not invent purge/content configs.
## Rule 13: Deprecations are law
If JSDoc, the console, or the docs mark something deprecated (`AGGrid` today), do not use it in new code and do not suppress the warning. Use the documented replacement.
## Rule 14: A component that renders a collection takes it through props
Anything that displays a list, board, calendar, timeline or inbox of records the caller owns is a **headless module**. It receives `items` / `loading` / `error` as props, hands changes back through `on*` callbacks typed `void | Promise<void>`, and navigates through `onOpen(id)` / `getHref(id)`.
Never fetch, subscribe, read a store, or import a router or app framework inside such a component — `meteor/*`, `next/*`, `react-router*`, `@tanstack/react-query` and `@fortawesome/*` are blocked by ESLint. Make it generic over the item type with accessor props (`getId`, `getStatus`, `getStart`, …), put domain rendering in `render*` slots, return a token _name_ for colour (never a class string), and make every user-facing string overridable through `labels`.
Declare it with `parameters.catalog.collection: true`; `pnpm catalog:check` then requires an **Empty**, **Loading** and **Error** story. Full contract:
[component-policy → Tier 2.5](https://github.com/mieweb/ui/blob/main/lessons/component-policy.md#tier-25-headless-modules).
Wiring one to an app's data layer — accessors, awaited mutations, `onOpen` plus `getHref`, where filter state lives:
[wiring-headless-modules.md](https://github.com/mieweb/ui/blob/main/lessons/wiring-headless-modules.md).
## Rule 15: When existing components do not meet the need
Before creating or materially extending a reusable component, read the
[upstream contribution guide](https://github.com/mieweb/ui/blob/main/CONTRIBUTING.md)
and follow its
[Developing Components From a Consuming Application](https://github.com/mieweb/ui/blob/main/CONTRIBUTING.md#developing-components-from-a-consuming-application)
process, including the alternatives audit, contribution-ready implementation,
submodule workflow, and PR requirements. If the guide is unavailable, report that
limitation and obtain it before proceeding with the contribution workflow.
Present the gap and supporting evidence before implementation. Obtain approval
before introducing a submodule or changing the consuming project's dependency
strategy. Keep project-specific behavior local, and do not create a generic
abstraction solely to make it contributable.
Follow the repository's permissions and approval requirements for commits,
pushes, and PR creation. Do not treat these instructions as authorization to
publish changes.
## Rule 16: Embedding the Ozwell assistant that acts on the page
Two different things share the "Ozwell" name — pick deliberately:
- **`OzwellChat` / `AIChat` (this library)** — the *chat UI shell*. You own the
transport and render messages you already have. Use it when the assistant is
part of your own product and you wire the answers yourself (see the
[Chat family](https://ui.mieweb.org/?path=/docs/modules-chat-overview--docs)
and the [Ozwell backend guide](https://github.com/mieweb/ui/blob/main/src/components/AI/OZWELL-BACKEND.md)).
- **The embedded Ozwell assistant (`@ozwell/react`, from ozwellai-api)** — a
drop-in, page-aware assistant that can **read and act on your page** through
tool calls. Use this when the user says things like "add Ozwell" or "let
Ozwell click / read / fill something on the page."
To add the page-aware assistant to a `@mieweb/ui` app:
- Install `@ozwell/react` alongside `@mieweb/ui`.
- Render `OzwellChat` from `@ozwell/react` and declare one tool in `tools` for
each page action the user wants Ozwell to perform (click, read, fill, …).
- Authenticate with a **site-approved agent key** (`agnt_key-…`) via
`VITE_OZWELL_AGENT_KEY`. Vite inlines every `VITE_*` value into the browser
bundle — this is **not** secret storage, so never expose a parent (`ozw_…`),
admin, or model-provider key this way; use a server-side integration when a
credential must stay private.
- Handle each call in `onToolCall(name, args, respond)`: perform the DOM action
and **always** `respond(...)`. Return `isError: true` for an unknown tool name
or a missing target, so the assistant never claims an action that did not happen.
- Follow the canonical guide — a full **Vite + MIE UI "Click Hello World"**
example — at <https://mieweb.github.io/ozwellai-api/frontend/react/>.
Example — let Ozwell fill a field on the page (adapt the tool to your app's own actions):
```tsx
import { useState } from 'react';
import { Input } from '@mieweb/ui';
import { OzwellChat, type OzwellTool } from '@ozwell/react';
const tools: OzwellTool[] = [{
type: 'function',
function: {
name: 'set_note',
description: 'Write text into the Note field when the user asks.',
parameters: {
type: 'object',
properties: { text: { type: 'string', description: 'Text to put in the Note field' } },
required: ['text'],
},
},
}];
export default function App() {
const [note, setNote] = useState('');
return (
<>
<Input label="Note" value={note} onChange={(e) => setNote(e.target.value)} />
<output aria-live="polite">Note: {note}</output>
<OzwellChat
apiKey={import.meta.env.VITE_OZWELL_AGENT_KEY}
tools={tools}
onToolCall={(name, args, respond) => {
if (name !== 'set_note' || typeof args.text !== 'string') {
respond({ isError: true, content: [{ type: 'text', text: 'Tool unavailable' }] });
return;
}
setNote(args.text);
respond({ content: [{ type: 'text', text: `Note set to "${args.text}"` }] });
}}
/>
</>
);
}
```
Privacy: conversation content stays between the user and Ozwell and is never
relayed to the host page. The host receives only the tool calls it declares,
lifecycle/error events, and any data the user explicitly shares (opt-in).
## Rule 17: Icons come from lucide-react
- **Every icon comes from `lucide-react`** — either a `*Icon` convenience re-export from `@mieweb/ui` (`HomeIcon`, `SearchIcon`, `TrashIcon`, …) or a direct `lucide-react` import for the full set.
- **Never hand-roll an `<svg>` icon and never add another icon library** (Font Awesome, Heroicons, Material Icons, …) — `@fortawesome/*` is ESLint-blocked in the library for this reason, and mixed icon sets break visual consistency.
- Sizing: `h-4 w-4` (16px) is the default inline size; `h-5 w-5` for emphasis, `h-3.5 w-3.5` in dense UI. Lucide's `size={16}` prop is equivalent.
- Icon-only controls need an `aria-label` (Rules 2 and 9); purely decorative icons get `aria-hidden="true"`.
- For dynamic icon props, type them as `LucideIcon` (re-exported from `@mieweb/ui`).
```tsx
// ✅ Convenience re-exports, or the full set directly
import { SearchIcon, TrashIcon } from '@mieweb/ui';
import { Stethoscope } from 'lucide-react';
// ❌ Hand-rolled or foreign icons
// <svg viewBox="0 0 24 24"><path d="..." /></svg>
// import { faTrash } from '@fortawesome/free-solid-svg-icons';
```
---
# @mieweb/ui — API cheat sheet for AI agents
> Verified prop signatures for the components web agents most often guess
> wrong. **These APIs deviate from Radix/shadcn conventions** — an agent that
> codes from convention instead of from this sheet produces runtime crashes
> (verified failure mode: `options is not iterable`, `onClose` ignored,
> `onCheckedChange` never firing). Everything here is checked against the
> library source. For components not on this sheet, fetch the catalog skill
> (https://ui.mieweb.org/skills/mieweb-ui-catalog.md) — never invent props.
## Imports
```tsx
import {
Button, ButtonGroup, Badge, Card, Input, Select, Checkbox,
Modal, ModalHeader, ModalTitle, ModalBody, ModalFooter,
ThemeProvider,
} from '@mieweb/ui';
import { DataVisNitroSource, DataVisNitroGrid } from '@mieweb/ui/datavis';
```
## Select — options array, NOT children/native select
No `<option>` children, no native `onChange`. It renders a `role="combobox"`
button with a portaled listbox.
```tsx
<Select
label="Provider"
options={[
{ value: 'dr-a', label: 'Dr. Adams' },
{ value: 'dr-b', label: 'Dr. Brown', disabled: true },
// groups: { label: 'Group', options: [{ value, label }] }
]}
value={provider} // string
onValueChange={(v) => setProvider(v)} // (value: string) => void
placeholder="Choose…"
/>
```
- `multiple` switches `value`/`onValueChange` to `string[]`.
- Also: `defaultValue`, `searchable`, `disabled`, `error`, `helperText`,
`size`, `labelVariant`.
- There is **no** `onChange`, no `children`, no `<SelectItem>`.
## Checkbox — native input events, NOT onCheckedChange
Extends native `<input type="checkbox">` props (minus `size`/`type`):
```tsx
<Checkbox
label="Patient verified" // built-in label prop
description="ID and insurance checked"
checked={verified}
onChange={(e) => setVerified(e.target.checked)} // NATIVE event
/>
```
- Also: `indeterminate`, `error`, `labelPosition`.
- There is **no** `onCheckedChange` (that is Radix, not this library).
## Input — native input plus label/error/helperText
Extends native `<input>` props (minus `size`):
```tsx
<Input
label="Search appointments"
value={query}
onChange={(e) => setQuery(e.target.value)} // native event
error={errors.query}
helperText="Name or chart ID"
/>
```
## Modal — open/onOpenChange, NOT isOpen/onClose
```tsx
<Modal open={open} onOpenChange={setOpen} aria-labelledby="checkin-title">
<ModalHeader>
<ModalTitle id="checkin-title">Check in patient</ModalTitle>
</ModalHeader>
<ModalBody>…</ModalBody>
<ModalFooter>
<Button variant="secondary" onClick={() => setOpen(false)}>Cancel</Button>
<Button onClick={confirm}>Check in</Button>
</ModalFooter>
</Modal>
```
- `onOpenChange: (open: boolean) => void` — there is **no** `onClose`.
- Content unmounts when `open` goes false — immediately on the default CSS
path, after the exit animation under a `MotionProvider` — so don't rely on
unmount cleanup timing.
- Also: `closeOnOverlayClick`, `closeOnEscape`, `size`.
## Button / Badge — use real variants, not CSS
Never fake states with font colors or hand-rolled classes:
```tsx
<Button variant="primary" size="md" disabled={!canSubmit}>Save</Button>
<Button variant="danger" isLoading={saving} loadingText="Saving…">Delete</Button>
<Badge variant="success">Checked in</Badge>
```
- Button `variant`: `primary | secondary | ghost | outline | danger | link`;
`size`: `sm | md | lg | icon | icon-sm`; plus `isLoading`, `loadingText`,
`leftIcon`/`rightIcon`, `fullWidth`, native `disabled`.
- Badge `variant`: `default | secondary | success | warning | danger |
outline`; `size`: `sm | md | lg`.
## DataVis NITRO grid — source wrapper + wire format
Grids/tables start here (never hand-rolled `<table>` features). The Grid must
be nested inside a Source:
```tsx
<DataVisNitroSource type="http" url="/api/appointments.json">
<DataVisNitroGrid
title="Today's appointments"
columns={[
{ field: 'patient', header: 'Patient', sortable: true, filterable: true },
{ field: 'time', header: 'Time', sortable: true },
'status', // bare string = field name
]}
features={{ rowSelection: 'checkbox', stickyHeaders: true }}
onRowClick={(row) => openChart(row.data)} // row payload is row.data
height="60vh"
/>
</DataVisNitroSource>
```
**The HTTP endpoint must serve one of exactly two formats** — a bare JSON
array crashes with `JSON Parser / Missing (data) property`:
```jsonc
// 1. JSON envelope — BOTH properties required:
{
"typeInfo": [
{ "field": "patient", "type": "string", "displayText": "Patient" },
{ "field": "time", "type": "string" }
],
"data": [{ "patient": "Jane Smith", "time": "09:00" }]
}
// 2. CSV text — header row then rows (every column typed string).
```
No server endpoint? Use the local source instead of blob URLs (blob URLs get
revoked between the engine's fetches): set
`window.myData = { typeInfo, data }` **before** mounting, then
`<DataVisNitroSource type="local" varName="myData">`.
Full grid API (features, grouping, aggregates, mass operations, Graph):
https://ui.mieweb.org/skills/mieweb-ui-datavis-api.md
## Everything else
- App shell: wrap the tree in `<ThemeProvider>`; import
`@mieweb/ui/styles.css` then `@mieweb/ui/brands/mieweb.css`.
- Icons: `lucide-react` only — no emoji, no inline SVGs.
- Component inventory + selection policy:
https://ui.mieweb.org/skills/mieweb-ui-catalog.md
- Setup recipes per environment: https://ui.mieweb.org/agent.md
- Non-negotiable rules: https://ui.mieweb.org/instructions.md