# kempo-ui LLM Reference
Lit-based web component library. All custom elements are prefixed `k-`. Components use kempo-css for styling, which is automatically injected into every shadow root.
---
## Install
```bash
npm install kempo-ui
```
## Page Setup
Configure `window.kempo` before importing components. All properties are optional:
```html
```
`pathToStylesheet` defaults to `https://cdn.jsdelivr.net/npm/kempo-css@2/dist/kempo.min.css` if unset. Set it to a local copy of kempo-css to serve the stylesheet yourself.
`pathsToIcons` defaults to `['./icons', '/icons', '../icons', '../../icons']` if unset; these are local paths searched in order when resolving ``.
`overlayRoot` is a CSS selector for the element that fixed-position overlay content should be appended into instead of `document.body` (e.g. to keep it out of a fixed header, or a custom titlebar in an Electron app). Shared by Toast, Dialog, and PhotoViewer. Resolved lazily on first use, so it can be set at any point. Falls back to `document.body` if unset or the selector matches nothing.
---
## Importing Components
Each component file self-registers on import. Import individual files:
```html
```
```js
import 'kempo-ui/src/components/Toggle.js';
```
Lit templates are available from `src/lit-all.min.js`:
```js
import { html, css, LitElement } from 'kempo-ui/src/lit-all.min.js';
```
---
## Components
| Element(s) | File | Description | Docs |
|-----------|------|-------------|------|
| `` `` `` | `Accordion.js` | Collapsible panel groups; `for-panel` attribute links headers to panels | [accordion.html](https://dustinpoissant.github.io/kempo-ui/components/accordion.html) |
| `` `` `` `` `` `` | `Aside.js` | Sidebar/drawer; `main="push"` or `main="overlay"`, `mobile-main="overlay"` (or `push`) used at or below 768px, `push-from-offscreen="collapsed"` / `overlay-from-collapsed="offscreen"` (optional state changes on layout change), `side="left|right"`; `` auto-wraps items sharing a group (2+, `group-min`) in a menu, icon from `group-icons` JSON / `group-icon` / folder | [aside.html](https://dustinpoissant.github.io/kempo-ui/components/aside.html) |
| `` | `AsideBtn.js` | Small floating button (FAB, extends Button, default menu icon, slot replaces it) in a corner (`position="top left"` default, or `top right`, `bottom left`, `bottom right`) that toggles the aside named by `for="id"`; hidden under an open aside by default, `push` keeps it visible and moves it beside the aside; dimmed to 70% opacity until hovered; show or hide by breakpoint with kempo-css classes (`class="d-n m-d-b"`); style with classes | [aside-btn.html](https://dustinpoissant.github.io/kempo-ui/components/aside-btn.html) |
| `` | `Calendar.js` | Inline month-grid date picker widget; `mode="single"` (default) or `mode="range"`; `value` is ISO `YYYY-MM-DD` (single) or comma-separated pair (range); `min`/`max` bounds; `readonly` (Boolean: shows the date and submits it, days cannot be picked, month and year still navigable); form-associated; fires `change` | [calendar.html](https://dustinpoissant.github.io/kempo-ui/components/calendar.html) |
| `` | `Card.js` | Bordered container; optional `label` attribute | [card.html](https://dustinpoissant.github.io/kempo-ui/components/card.html) |
| `` | `CardGrid.js` | Generic version of `` for grids of `` tiles instead of rows — matches Table's selection/pagination/CRUD API (`getSelectedRecords`, `selectAllOnPage`, `deselectAllOnPage`, `selectionChange`, etc.) and sets `controlled` on itself, so `kc-tc-*` controls work in its `slot="top"` unmodified; no columns, so no sorting/filtering/search/inline-editing; `cardTemplate(record, host)` renders each tile | [card-grid.html](https://dustinpoissant.github.io/kempo-ui/components/card-grid.html) |
| `` | `ChatBubble.js` | Round floating chat button (FAB, `--c_primary`) for customer service or any LLM you connect (its `prompt-api` option uses the browser's built-in AI, which is VERY EXPERIMENTAL and not useful yet) fixed to a corner (`position="bottom right"` default, `bottom left`, `top left`, `top right`); click opens a popup `` above (below at the top) and the icon becomes a down chevron, click again (or Escape) minimizes; works for a person or the AI: it slots `controls-top` (the header bar, before the built-in list and + icons; buttons/links are styled for you), `controls-side` (small slot above Send, e.g. a `tel:` call button) and `controls-bottom` (row at the very bottom), the last two passed to the chat; the collapse chevron points up when at the top; forwards `empty-message`, `input` (default `markdown`: a clean textarea; `markdown-editor` adds a compact toolbar), `prompt-api`, `prompt-tools` (property `promptTools`), `persistent-id`, `placeholder`, `show-status`, `enter-newline`, `disabled` to the inner chat, which is `bubble.chat` (`await bubble.updateComplete` first); with `persistent-id` the open/closed state is kept for the tab (sessionStorage) so an open chat survives page navigation, and the first open lists saved conversations (continue / delete after a `Dialog.confirm` / new); an incoming message or finished AI reply while minimized sets `unread` (icon `mark_chat_unread`, wiggle + pulse between primary and danger; cleared on open; set it yourself for server pushes); `heading` (optional; the header bar is hidden without a heading, `controls-top` content or `persistent-id`); `allow-fullscreen` adds a full screen icon to the header (the popup then fills the window one `--spacer` from the edges, clear of the round button; `fullscreen` reflects it, Escape leaves it first, kept with `persistent-id`), method `toggleFullscreen()`, event `fullscreen-change`; methods `show()`, `hide()`, `toggle()`, `showConversations()`; fires `open`, `close` and re-fires the chat's `send`, `response`, `error`, `tool-call`, `message-add`, `conversation-change`, `conversation-save`; `--chat_bubble_size/offset/width/height` | [chat-bubble.html](https://dustinpoissant.github.io/kempo-ui/components/chat-bubble.html) |
| `` | `Chat.js` | Chat-room widget (its `prompt-api`, `promptTools` and `debug` features use the browser's built-in AI, which is VERY EXPERIMENTAL and not useful yet: it could not answer a single question correctly in testing); `empty-message` text centered in the message area while there are no messages (not `placeholder`, which is the input's placeholder); `input` picks what the user types in: `markdown` (default, plain auto-growing box whose text is markdown), `markdown-editor` (embedded `` with tabs and toolbar; `markdown-resize` adds its drag handle), `resize` (handle under the whole chat, the message window grows; no handle by default), `html-editor` (``), `markdown` (plain auto-growing textarea whose text is markdown) or `text` (plain textarea sent escaped); the editors are lazy-loaded only when chosen, `await chat.updateComplete` waits for them; `focus()` focuses the input; slots `controls-top` (row above the input; the toolbar in `markdown-editor`), `controls-side` (beside the input, above Send; `markdown`/`text` only) and `controls-bottom` (row below the input; beside Send in the editors), each takes no room while empty; `send(text?)` sends that text instead of the input; with `html-editor` the `send` `markdown` is the plain text; markdown input via embedded `` (rendered through `marked` with `breaks:true` so single newlines become ` `, then run through `sanitizeHtml` so any inline HTML is filtered against the allow-list); default Enter sends / Shift+Enter newline (Slack-style), add `enter-newline` to invert; `show-status` (or `show-status="text"` / `show-status="icons"`) renders iMessage-style `sending`/`delivered`/`read`/`failed` only on the most recent outgoing message (sending/failed always show); methods `addMessage(msg)`, `updateMessage(id, updates)`, `removeMessage(id)`, `clear()`, `send()`; `prompt-api="/path/to/system-prompt.md"` makes it a chat with the browser's built-in language model (via `promptApi.js`; several space-separated URLs are read in order and joined; empty value = no system prompt; the `promptTools` property takes `[{ name, description, inputSchema, execute(args) }]` the model can call, e.g. to change the page theme, and fires `tool-call` with `{name, arguments, result}`; the reply streams in as an incoming message, `clear()` also resets the model's memory); `persistent-id="name"` saves the messages in IndexedDB (via `conversations.js`; the name is a group) and restores the newest conversation of the group after a reload, giving the model the saved turns as its history; methods `newConversation()`, `loadConversation(id)`, `listConversations()`, `deleteConversation(id)` (`clear()` also deletes the saved one); messages also carry `markdown` and `transient` (never saved); fires `conversation-change` `{id}` and `conversation-save` `{id}`; with `prompt-api`, `debug` records each step of the model conversation (system prompt, what was sent, raw replies, tool calls and results, context used) with the saved conversation, `debug="console"` also prints it, `chat.debugLog` / `exportConversation(id?)` give it as text (with the messages) and `renameConversation(id, title)` sets a title that sticks; fires `message-add` with `{message}` for every added message, `send` with `{id, html, markdown}`, and with `prompt-api` also `response` with `{id, html, markdown}` and `error` with `{error}` | [chat.html](https://dustinpoissant.github.io/kempo-ui/components/chat.html) |
| `` | `CodeEditor.js` | Monaco-powered code editor; `value`, `language`, `controls`, `disabled`/`readonly`/`required` attributes; form-associated (full validity + reset/restore/disabled callbacks); theme-aware; toolbar button controls use the unified `kc-*` prefix and extend `ButtonControl` from `controls/Button.js` | [code-editor.html](https://dustinpoissant.github.io/kempo-ui/components/code-editor.html) |
| `` | `ColorPicker.js` | Full color picker (hex, rgb, hsl, hsv, alpha); `disabled` (Boolean: no changes, left out of the form); `readonly` (Boolean: shows the color and submits it; text field read-only, format select and swatch disabled); `value` property | [color-picker.html](https://dustinpoissant.github.io/kempo-ui/components/color-picker.html) |
| `` | `Combobox.js` | Searchable dropdown with debounced `search` event, dynamic `setOptions()`, `searching` indicator, keyboard nav; `readonly` (Boolean: shows the value and submits it; no typing, the list does not open); options are strings or `{label, value}` objects | [combobox.html](https://dustinpoissant.github.io/kempo-ui/components/combobox.html) |
| `` | `ContentSlider.js` | Swipeable carousel; `index`, `controls`, `loop`, `keyboard-controls`, `global-controls`, `min-height` (any CSS length, a minimum height for the slide area); the previous and next buttons are disabled on the first and last slide unless `loop` is on, and `previous()` / `next()` do nothing there (no events); its children are the slides, only the current one is in the page | [content-slider.html](https://dustinpoissant.github.io/kempo-ui/components/content-slider.html) |
| `` | `controls/NavLink.js` | Link control for navigation bars (`k-nav`, `k-control-bar`): `href`, `target` (`_blank` adds `rel="noopener"`); default slot holds the icon, `menu-text` slot (falls back to `title`) is its label, shown only while in the "more" menu; 40px tall, needs no controlled host | [nav.html](https://dustinpoissant.github.io/kempo-ui/components/nav.html) |
| `` | `ControlBar.js` | Single-row responsive toolbar with `default` (left), `center` and `right` slots spaced with flexbox; never wraps — when the controls no longer fit, they are moved (by switching their `slot` to `overflow`) into a vertical-ellipsis "more" menu one at a time and moved back as the bar grows; `collapse-order` (default `"right center left"`, `left` = `default`) sets which slot is emptied first, always starting from its last control; the "more" menu is a `kc-menu`; menus (`kc-menu`, `kc-vid-menu`, `k-dropdown`), `kc-spacer` and anything with `no-collapse` are never moved; a `k-control-group` moves as one unit, or one control at a time with `split` (each by its own `priority`, or the group's; `no-collapse` stays; a control that moves leaves its group and is listed in the menu in its original order; a group with nothing left is hidden); `priority` on a control (number, default 0, bare = 1) moves it into the menu later than lower-priority ones (unlike `no-collapse`, high priorities still move once the bar is small enough); plain `` and `