# SekiUI Components

Modern, accessible Web Components library built with Stencil.js, inspired by shadcn/ui design principles.

## Project Status

Actively developed, with **60+ components** ([full catalog below](#component-catalog)), a
comprehensive test suite, and an automated CI/CD + npm publishing pipeline. The
library currently publishes under `0.0.x`; now that catalog and documentation
coverage is in place, the next milestone is a **`0.1.0`** release to signal
API stability. Until then, treat minor API changes between `0.0.x` releases as
possible.

## Features

- 🎨 **Modern Design**: Clean, minimal components following shadcn/ui aesthetic
- ♿ **Accessibility First**: WCAG 2.1 Level AA compliant
- 🌗 **Dark Mode**: First-class dark mode support via CSS custom properties
- 📦 **Framework Agnostic**: Works with React, Vue, Angular, or vanilla JavaScript
- 🎯 **TypeScript**: Full TypeScript definitions included
- 🎭 **Storybook**: Interactive component documentation
- 🔧 **Tree-shakeable**: Import only what you need

## Getting Started

The fastest way to set up SekiUI in any project:

```bash
npx @sekiui/cli init
```

This interactive wizard will:
- Auto-detect your framework (React, Vue, Angular, or Vanilla HTML)
- Let you pick a color theme: **Neutral · Zinc · Slate · Rose · Blue · Violet**
- Set a border radius style: **None · Default · Rounded · Pill**
- Inject CSS design tokens into your global stylesheet
- Wire up `defineCustomElements()` (or `CUSTOM_ELEMENTS_SCHEMA` for Angular)
- Create a sample component to verify everything works

Then get usage snippets for any component:

```bash
npx @sekiui/cli add button
npx @sekiui/cli add select
npx @sekiui/cli add tooltip --framework vue
npx @sekiui/cli add badge --output src/snippets/badge.txt
```

Each `add` output includes:
1. The setup snippet for your framework
2. The verified examples from [sekiui.com](https://sekiui.com), converted to JSX for React
3. Every tag's attributes, allowed values and events
4. The `--seki-<component>-*` CSS custom properties you can override

`add` accepts a component name or any tag (`npx @sekiui/cli add seki-select-option` prints Select). Its output is generated from the same catalog as the docs site, so it always matches the library version the CLI ships with.

The `add` command works for every component in the [catalog below](#component-catalog). Run `npx @sekiui/cli add` with no name to print the full, always-current list of available components.

### Using SekiUI with AI coding agents

Agents write correct `<seki-*>` markup when they can read the real API instead of guessing it. There are three ways to give it to them:

- **MCP server.** Exposes `list_components`, `search_components`, `get_component` (examples plus props, attributes, events, slots and parts) and `get_usage_guide`. Runs offline.
  ```bash
  claude mcp add sekiui -- npx -y @sekiui/cli mcp
  ```
  For other clients (Cursor, VS Code, …), configure command `npx` with args `["-y", "@sekiui/cli", "mcp"]`.
- **llms.txt.** Point the agent at [`https://sekiui.com/llms.txt`](https://sekiui.com/llms.txt), or at `llms-full.txt` for everything in one file. Every component page has a Markdown version, e.g. `https://sekiui.com/components/button.md`.
- **Custom Elements Manifest.** `@sekiui/elements` ships `custom-elements.json` (declared in `package.json` under `"customElements"`) for tools that read it, plus `vscode-data.json` for HTML autocomplete in VS Code (`"html.customData": ["./node_modules/@sekiui/elements/vscode-data.json"]`).

---

## Component Catalog

SekiUI ships **60+ components** across the categories below. Every tag is a
standalone custom element — compound components (e.g. `seki-select` +
`seki-select-option`) are used together and listed under their parent.

Browse them interactively in [Storybook →](https://sekiui-storybook.pages.dev),
or grab a copy-ready snippet for any of them with `npx @sekiui/cli add <name>`.

### Forms & Inputs

`seki-input` · `seki-textarea` · `seki-input-group` · `seki-input-otp` · `seki-label` · `seki-checkbox` · `seki-radio-group` · `seki-switch` · `seki-slider` · `seki-toggle` · `seki-toggle-group` · `seki-select` · `seki-native-select` · `seki-combobox` · `seki-field` (+ `seki-fieldset`, `seki-field-label`, `seki-field-description`, `seki-field-error`, `seki-field-group`) · `seki-calendar` · `seki-date-picker`

### Buttons & Actions

`seki-button` · `seki-button-group` · `seki-dropdown-menu` · `seki-context-menu` · `seki-command`

### Overlays

`seki-dialog` · `seki-alert-dialog` · `seki-sheet` · `seki-drawer` · `seki-popover` · `seki-hover-card` · `seki-tooltip`

### Navigation

`seki-tabs` · `seki-navigation-menu` · `seki-menubar` · `seki-breadcrumb` · `seki-pagination` · `seki-sidebar`

### Data Display

`seki-table` · `seki-data-table` · `seki-card` · `seki-avatar` · `seki-badge` · `seki-chart` · `seki-carousel` · `seki-accordion` · `seki-collapsible` · `seki-item` · `seki-kbd`

### Feedback & Status

`seki-alert` · `seki-toast` · `seki-sonner` · `seki-progress` · `seki-skeleton` · `seki-spinner` · `seki-empty`

### Layout & Utilities

`seki-separator` · `seki-scroll-area` · `seki-resizable` · `seki-aspect-ratio` · `seki-direction`

### Chat / Messaging

`seki-message` · `seki-bubble` · `seki-attachment` · `seki-message-scroller` · `seki-marker`

> The `npx @sekiui/cli add` catalog is the source of truth for what the CLI can
> scaffold — run it with no arguments to print the current list.

## Installation

### Via npm (Recommended)

```bash
npm install @sekiui/elements
```

**Optional peer dependencies:** a few components wrap third-party libraries that aren't installed by default, to keep the base install lean. Install them only if you use the corresponding component:

| Component | Peer dependency |
|---|---|
| `seki-chart` | `npm install chart.js` |
| `seki-carousel` | `npm install embla-carousel` |
| `seki-calendar`, `seki-date-picker` | `npm install date-fns` |

### Via CDN (No Build Required)

For quick prototyping or projects without a build system, you can load SekiUI directly from a CDN.

**Latest Stable Version (unpkg):**
```html
<script type="module" src="https://unpkg.com/@sekiui/elements@latest/dist/sekiui/sekiui.esm.js"></script>
```

**Latest Stable Version (jsDelivr):**
```html
<script type="module" src="https://cdn.jsdelivr.net/npm/@sekiui/elements@latest/dist/sekiui/sekiui.esm.js"></script>
```

**Specific Version (recommended for production):**
```html
<!-- Replace 0.0.41 with your desired version -->
<script type="module" src="https://unpkg.com/@sekiui/elements@0.0.41/dist/sekiui/sekiui.esm.js"></script>
```

**Complete Example:**
```html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>SekiUI via CDN</title>
</head>
<body>
  <h1>SekiUI Components</h1>

  <!-- Use components directly -->
  <seki-button variant="primary">Click me</seki-button>
  <seki-button variant="secondary">Secondary</seki-button>
  <seki-input type="email" placeholder="you@example.com"></seki-input>

  <!-- Load SekiUI Web Components -->
  <script type="module" src="https://unpkg.com/@sekiui/elements@latest/dist/sekiui/sekiui.esm.js"></script>
</body>
</html>
```

**CDN Notes:**
- ✅ HTTPS enabled on all CDN URLs
- ✅ CORS headers configured for cross-origin requests
- ✅ Versioned URLs cached long-term (immutable)
- ✅ Latest URLs cached short-term (updates automatically)
- ✅ Design tokens are integrated within components (no separate CSS file needed)
- ⚠️ For production, use versioned URLs to ensure consistency

## Usage

SekiUI supports both **lazy-loading all components** (recommended) and **importing individual components** for maximum bundle optimization.

### Import Strategy

**Option 1: Lazy-Load All Components (Recommended)**
- Components are automatically loaded on-demand when used
- Best developer experience with minimal setup
- Small initial bundle (~5-10KB), components load as needed

**Option 2: Import Individual Components**
- Maximum tree-shaking and bundle optimization
- Import only specific components you use
- Best for performance-critical applications

---

### Vanilla JavaScript / HTML

#### Option 1: Using CDN (Recommended for Quick Start)

All components are automatically registered when you load the CDN bundle. No additional setup required.

```html
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
  <!-- Use components directly -->
  <seki-button variant="primary">Click me</seki-button>
  <seki-input type="email" placeholder="you@example.com"></seki-input>

  <!-- Load from CDN - components auto-register -->
  <script type="module" src="https://unpkg.com/@sekiui/elements@latest/dist/sekiui/sekiui.esm.js"></script>
</body>
</html>
```

#### Option 2: Using npm with Lazy-Loading

Components are loaded on-demand when used in the DOM. Requires calling `defineCustomElements()`.

```html
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
  <!-- Components load automatically when rendered -->
  <seki-button variant="primary">Click me</seki-button>
  <seki-input type="email" placeholder="you@example.com"></seki-input>

  <!-- Loader enables lazy-loading -->
  <script type="module">
    import { defineCustomElements } from './node_modules/@sekiui/elements/loader/index.js';
    defineCustomElements();
  </script>
</body>
</html>
```

**Or with a bundler (Vite, Webpack, etc.):**

```js
// main.js - Components lazy-load on-demand
import { defineCustomElements } from '@sekiui/elements/loader';
defineCustomElements();
```

#### Option 3: Import Individual Components

For maximum tree-shaking, import only specific components you need.

```html
<!DOCTYPE html>
<html>
<body>
  <seki-button variant="primary">Click me</seki-button>

  <script type="module">
    // Only imports button component (~3-5KB)
    import { defineCustomElement } from './node_modules/@sekiui/elements/dist/components/seki-button.js';
    defineCustomElement();
  </script>
</body>
</html>
```

**Or with a bundler:**

```js
// Only button component is bundled
import { defineCustomElement } from '@sekiui/elements/dist/components/seki-button.js';
defineCustomElement();
```

---

### React

SekiUI ships standard custom elements, so there is no React-specific wrapper
package (`@sekiui/elements/react` does not exist). React 19 passes props and
events to custom elements natively.

#### Using All Components (Lazy-Loaded)

```jsx
// main.jsx
import { defineCustomElements } from '@sekiui/elements/loader';

// Components lazy-load on demand
defineCustomElements();
```

```jsx
// App.jsx
function App() {
  return (
    <>
      <seki-button variant="primary">Click me</seki-button>
      <seki-input type="email" placeholder="you@example.com"></seki-input>
    </>
  );
}
```

#### Using Individual Components

```jsx
import { defineCustomElement } from '@sekiui/elements/dist/components/seki-button.js';

// Register once at app startup
defineCustomElement();

function App() {
  return <seki-button variant="primary">Click me</seki-button>;
}
```

**TypeScript:** declare the tags you use so JSX accepts them, for example:

```ts
// seki-elements.d.ts
import type { JSX as SekiJSX } from '@sekiui/elements';

declare module 'react' {
  namespace JSX {
    interface IntrinsicElements {
      'seki-button': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> &
        Partial<SekiJSX.SekiButton>;
    }
  }
}
```

---

### Vue 3

#### Using All Components (Lazy-Loaded)

**Global Registration (Recommended):**

```js
// main.js
import { createApp } from 'vue';
import App from './App.vue';
import { defineCustomElements } from '@sekiui/elements/loader';

// Components lazy-load on-demand
defineCustomElements();

createApp(App).mount('#app');
```

```vue
<!-- Any component can now use SekiUI -->
<template>
  <seki-button variant="primary">Click me</seki-button>
  <seki-input type="email" placeholder="you@example.com"></seki-input>
</template>
```

**Component-level Registration:**

```vue
<template>
  <seki-button variant="primary">Click me</seki-button>
</template>

<script setup>
import { defineCustomElements } from '@sekiui/elements/loader';
defineCustomElements();
</script>
```

#### Using Individual Components

```vue
<template>
  <seki-button variant="primary">Click me</seki-button>
</template>

<script setup>
// Only imports button component
import { defineCustomElement } from '@sekiui/elements/dist/components/seki-button.js';
defineCustomElement();
</script>
```

**Vue 3 Config (Optional):**

To prevent Vue warnings about unknown custom elements, add to `vite.config.js`:

```js
export default {
  vue: {
    template: {
      compilerOptions: {
        isCustomElement: (tag) => tag.startsWith('seki-')
      }
    }
  }
}
```

---

### Angular

#### Using All Components (Lazy-Loaded)

```typescript
// app.module.ts
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { defineCustomElements } from '@sekiui/elements/loader';

// Register all components (lazy-loaded)
defineCustomElements();

@NgModule({
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  imports: [BrowserModule],
  // ...
})
export class AppModule { }
```

```html
<!-- app.component.html -->
<seki-button variant="primary">Click me</seki-button>
<seki-input type="email" placeholder="you@example.com"></seki-input>
```

#### Using Individual Components

```typescript
// app.component.ts
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { defineCustomElement } from '@sekiui/elements/dist/components/seki-button.js';

// Only imports button component
defineCustomElement();

@Component({
  selector: 'app-root',
  template: '<seki-button variant="primary">Click me</seki-button>',
  schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class AppComponent {}
```

---

### Bundle Size Comparison

| Import Method | Initial Bundle | Notes |
|--------------|----------------|-------|
| **CDN (lazy-loaded)** | ~5-10KB | Components download on first use |
| **Loader (all components)** | ~5-10KB | Lazy-loads components as needed |
| **Individual component** | ~3-5KB | Only `seki-button` + shared runtime |
| **Multiple individual** | Varies | Each component ~2-4KB + shared runtime |

**Recommendation:** Use the loader approach for most projects. It provides excellent performance through automatic lazy-loading while maintaining the best developer experience.

## License

MIT © SekiUI Team
