Reusable web components across any JavaScript framework.
A lightweight, customizable, and accessible component library powered by Lit.
Five documents in docs/:
- Component standards — engineering fundamentals: reactive state, form-association internals, theming, a11y, events, performance, testing, Storybook.
- Definition of done — the checklist that gates "this component is ready to ship."
- Internal architecture — design-system internals for maintainers (styling flow, etc.).
- Multi-Framework Integration plan — how mimi-ui ships to React, Angular, and Vue consumers.
- Plain usage — how to use mimi-ui today via native custom elements (no wrappers required).
The rest of this README is project-level orientation: structure, scripts, setup, architectural overview, scope.
@first-apps/mimi-ui exposes typed framework entrypoints. Pick the subpath that matches
your stack — every entrypoint is a regular import, no bundler plugin needed.
Four entrypoints ship: the vanilla web-components (
@first-apps/mimi-ui), plus React, Vue, and Angular wrappers. For the raw custom elements without a wrapper, see Plain usage.
<script type="module">
import '@first-apps/mimi-ui'; // registers <m-button>
</script>
<m-button variant="primary" size="md">Save changes</m-button>import { MButton } from '@first-apps/mimi-ui/react';
export function SaveButton() {
const onClick = () => {
// …
};
return (
<MButton variant="primary" onClick={onClick}>
Save
</MButton>
);
}onClick is the native click. Use onMButtonClick for the component's own
event, which carries a typed payload:
import { MButton, type MButtonClickDetail } from '@first-apps/mimi-ui/react';
<MButton
variant="primary"
onMButtonClick={(e: CustomEvent<MButtonClickDetail>) => {
// e.detail.source → the <m-button> element
}}
/>;<script setup lang="ts">
import { MButton } from '@first-apps/mimi-ui/vue';
function onSave() {
// …
}
</script>
<template>
<MButton variant="primary" @click="onSave">Save</MButton>
</template>The icon slot is forwarded too:
<MButton variant="primary">
<template #icon><span aria-hidden="true">★</span></template>
Add to favorites
</MButton>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@first-apps/mimi-ui';
@Component({
selector: 'app-save',
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `<m-button variant="primary" (click)="onSave()">Save</m-button>`,
})
export class SaveComponent {
onSave() {
// …
}
}mimi-ui/
├── .env.development # Dev defaults baked into the dev bundle (committed)
├── .env.production # Prod defaults baked into the prod bundle (committed)
├── .env.example # Template — copy to .env.local to override
├── .storybook/
│ └── main.ts # Storybook config (web-components-vite, a11y + docs addons)
├── AGENTS.md # Project memory for AI agents
├── biome.json # Lint/format config (Biome 2)
├── docs/
│ ├── COMPONENT_STANDARDS.md # Engineering fundamentals — the *why*
│ ├── DEFINITION_OF_DONE.md # Component-completion checklist — the gate
│ ├── INTERNAL_ARCHITECTURE.md # Design-system internals for maintainers
│ ├── INTEGRATION.md # Cross-framework distribution roadmap
│ └── PLAIN_USAGE.md # Today's working code (native custom elements)
├── LICENSE # MIT
├── README.md # GitHub-rendered repo orientation (this file)
├── README.npm.md # npm-rendered readme (set via package.json `readme`)
├── package.json
├── src/
│ ├── components/
│ │ └── m-button/ # Production template: SASS, theming,
│ │ │ # form-association, slots, a11y
│ │ ├── m-button.ts
│ │ ├── m-button.scss
│ │ ├── m-button.test.ts
│ │ └── m-button.stories.ts
│ ├── config/
│ │ ├── env.ts # Single env accessor (only place components read env)
│ │ └── index.ts # Re-exports
│ ├── styles/
│ │ ├── _tokens.scss # Design tokens (color, space, radius, motion)
│ │ └── _mixins.scss # Reusable SASS mixins
│ ├── index.ts # Public package entry — re-exports all components
│ └── vite-env.d.ts # ImportMetaEnv augmentation
├── tsconfig.json
├── vite.config.ts
└── vitest.setup.ts
Component folder is portable. Each m-<name>/ folder is self-contained: logic, styles, tests, and stories live together. Tokens and mixins are global; components @use them by path. See
Section 1 File structure and
Section 5 Theming for the conventions.
Every component is a single class extending LitElement registered with @customElement('m-…'). Three primitives define the contract:
| Layer | Mechanism | Purpose |
|---|---|---|
| Inputs | @property decorated fields |
Reactive public API; reflected to HTML attributes where the standard requires (see Section 4 Variants) |
| Outputs | CustomEvent with composed: true, bubbles: true |
Cross Shadow DOM boundaries; consumable from any framework (see Section 7 Events) |
| Composition | Named + default slots | Light-DOM children projected into the Shadow DOM |
- React 18+: works directly. For idiomatic JSX with typed props and synthetic events, wrap each component using
@lit/react'screateComponent. - Angular 18+: declare
CUSTOM_ELEMENTS_SCHEMAin the consuming module, or register via@angular/elements. Form-association hooks intoNgModelautomatically. - Vue 3.4+: works without config. v-model on form-associated elements is built-in.
The composed: true flag on every dispatched event is what makes this work — it lets the event cross the Shadow DOM boundary so framework event systems can hear it.
| Command | Purpose |
|---|---|
npm run dev |
Storybook dev server with HMR on port 6006. Runs build:storybook first, then storybook dev -p 6006. |
npm run build |
Type-check (tsc) + production bundle to dist/ as ES + CJS. |
npm run build:dev |
Type-check + dev bundle to dist-dev/. Unminified, full sourcemaps. |
npm run build:prod |
Alias for build. Use when you want the script name to read "prod" instead of "build". |
npm run preview |
Builds Storybook static and serves it on http://localhost:6007 for review. |
npm run test |
Run the full Vitest suite once. |
npm run test:watch |
Re-run tests on file change. Use during development. |
npm run build:storybook |
Static Storybook build. Output: storybook-static/. Pushed to GitHub Pages via .github/workflows/deploy-storybook.yml on every push to master. |
npm run lint |
Check for lint errors (Biome). |
npm run lint:fix |
Fix lint errors (Biome). |
npm run format |
Check for code formatting errors (Biome). |
npm run format:fix |
Fix code formatting errors (Biome). |
npm run clean |
Remove dist/, dist-dev/, storybook-static/. |
Prerequisites
- Node.js ≥ 20
From scratch
git clone <repo-url> mimi-ui
cd mimi-ui
npm installRun the dev server
npm run devOpen the printed URL. Edit any component under src/components/ — Vite hot-reloads.
Run tests
npm run test # one-shot
npm run test:watch # watch modeRun Storybook
npm run devOpen http://localhost:6006. The a11y tab in each story's panel runs axe-core against the rendered component and surfaces violations.
The published Storybook lives at https://first-apps.github.io/mimi-ui/.
It rebuilds on every push to master via
.github/workflows/deploy-storybook.yml; see docs/INTERNAL_ARCHITECTURE.md
§"Storybook deploy" for the flow.
Build for production
npm run build # emits dist/mimi-ui.es.js + dist/mimi-ui.cjs.jsThe bundle is tree-shakeable — consumers only ship the components they import.
This package is built in two environments. Both are author-side — the files described here are bundled into the published library at build time and never reach consumers at runtime.
| Environment | Purpose | Output | Minified | Sourcemaps |
|---|---|---|---|---|
dev |
Smoke-test the package output locally | dist-dev/ |
no | full |
prod |
Publish to npm (default for npm run build) |
dist/ |
yes | hidden |
.env.development— defaults baked into the dev bundle (committed)..env.production— defaults baked into the prod bundle (committed)..env.example— template. Copy to.env.localto override for your machine..env.local/.env.*.local— personal overrides; ignored by git.src/config/env.ts— the only place components read env values. Imports the typedimport.meta.envaugmentation fromsrc/vite-env.d.ts.
npm run dev # Storybook dev server with HMR on port 6006
npm run build # prod build → dist/
npm run build:dev # dev build → dist-dev/ (unminified, full sourcemaps)
npm run preview # Storybook static + serve on http://localhost:6007
npm run clean # remove dist/, dist-dev/, storybook-static/prepublishOnly runs lint && test && build (the prod build), so a
mistaken npm publish while in dev mode is gated correctly.
Override any value for a single command without editing files:
VITE_BUILD_ENV=production VITE_SHOW_DEV_WARNINGS=false npm run build:devVite also reads mode from the --mode flag, which the scripts above set
explicitly — the value in .env.<mode> is the default, not the
authoritative source. To change defaults, edit the .env.<mode> file
or add a personal .env.local.
Consumers of @first-apps/mimi-ui do not ship these env files.
Whatever value these files hold at our npm run build time is frozen
into the bundle they import. If you ever need per-app configuration,
expose a component prop instead of reaching for a VITE_* variable.
The fastest path: open DEFINITION_OF_DONE.md and run the checklist. Every box needs to be checked before merging. For the "why" behind each item, see COMPONENT_STANDARDS.md.
Use m-button as the working template — it implements every convention in the checklist and the standards doc.
- No CSS-in-JS. SASS + CSS custom properties handle theming with zero runtime cost.
- No state management. Components are stateless inputs → events. Consumers own state.
- No build-time framework wrappers yet. The path is documented in Multi-Framework Integration plan: multi-entry Vite library build +
@lit/reactfor React + Angular type augmentation + VuedefineCustomElement. Track progress there. - No monorepo. Single package until a second consumer (React app, Angular app, Vue app) lives in the same repo. Split then with npm workspaces.
