omfp/kit
Build every control a widget shows from these components: they follow the theme (light, dark, built-in or user theme)
and the skin, in the window’s own popovers. Native <select>, <input type="checkbox">, radio, range, date,
color and <datalist> do not: their opened lists and pickers are drawn by the platform (a white GTK menu in the
Linux desktop window), whatever the page’s styles say. windows.check_widget warns about each one it finds.
Native controls and their replacements
Section titled “Native controls and their replacements”| Native element | Kit replacement |
|---|---|
<select> |
Select |
<input type="checkbox"> |
Checkbox |
<input type="radio"> |
RadioGroup with Radio |
<input type="range"> |
Select of the steps (or Buttons stepping a value); Progress to only show one |
<input type="date"> |
TextField taking YYYY-MM-DD |
<input type="color"> |
Select of theme colors (var(--omfp-primary), …) |
<datalist> |
SearchField filtering a ListBox, or Select |
window.confirm, <dialog> |
ConfirmDialog, Dialog |
A Select key must be non-empty, so an “All” entry takes a sentinel id such as "*"; hideLabel keeps the label
for screen readers when the context names the field:
import { Select } from "omfp/kit";import { useStored } from "omfp/sdk";
export default function StatusFilter({ statuses }: { statuses: string[] }) { const [status, setStatus] = useStored<string>("status", "*"); const items = [{ id: "*", label: "All" }, ...statuses.map((name) => ({ id: name, label: name }))]; return ( <Select label="Status" hideLabel items={items} selectedKey={status} onSelectionChange={(key) => setStatus(key === null ? "*" : String(key))} /> );}Components
Section titled “Components”Props are typed; the table names the main ones.
| Export | What it is |
|---|---|
Card |
A bordered surface: title, actions, tone (default, error, warning, success). |
BorderBox |
A box titled on its top border: title, level, end. |
EmptyState |
Where nothing is yet: icon, title, the hint as children, action, bare. |
Button |
onPress, variant (primary, secondary, quiet, danger), size (sm, md), isDisabled. |
IconButton |
An icon-only button: label, icon, onPress. |
Progress |
label (required), value (omit for indeterminate), max (default 100), hideLabel. |
Meter |
A usage bar: value, max, label, threshold. |
Log |
Monospace lines that follow the end: lines. |
Badge, Chip |
A status label (tone); a compact item (tone, onRemove). |
StateMark |
A state’s glyph in its color: state (running, awaiting, failed, unread, idle, done), label. |
Icon |
A decorative Lucide icon: name (archive, check, copy, file, folder, inbox, play, plus, search, x, …). |
Kbd, KeyHint |
A key chip (spc n); a hint teaching keys, hidden on touch-only screens: wrap every key hint in one. |
Markdown |
Renders Markdown (no raw HTML): text; draws ```mermaid fences and TeX math ($…$, $$…$$); threadLink renders thread links. |
threadLinkUrl |
threadLinkUrl(id) → "omfp://thread/<id>"; threadLinkId(href) reads it back. |
MermaidDiagram, MathFormula |
A Mermaid diagram (source); a TeX formula (source, display). |
Code |
code, block, language (a name or extension). |
Diff |
A unified patch as numbered lines: patch, language. |
languageOfPath |
languageOfPath("src/lib.rs") → "rust". |
CodeEditor |
CodeMirror with vim bindings: value, path, readOnly, line, onSave(text), onDirtyChange. Fills the height its container gives it (a flex child or a fixed height) and scrolls inside. |
CodeDiff |
Two texts compared: original, value, path, layout (unified, split). Sized like CodeEditor. |
PdfView |
A PDF: url (same-origin, e.g. from useFileUrl), labels. Sized like CodeEditor. |
ImageView |
An image fitted, zoomed and panned: src, alt, labels; before and compare (split, slider) compare two versions. |
ImageDialog |
An image in a modal as large as the window: image, title, labels, onClose. |
WebView |
A web page filling its container, nothing else (a native web view in the desktop app, a sandboxed frame elsewhere): url (absolute http(s), not omfp’s own), title, onNavigate({ url, canGoBack, canGoForward }), onLoad(); desktop app only: scripts, onMessage, onOpenWindow. A browser of your own (address bar, back, forward) is a widget around it. |
WebFrame |
A WebView under a toolbar (URL, Reload, Open in browser): url, title, loadTimeoutMs. |
TerminalEmulator |
xterm.js in the theme’s colors: sessionKey, chunks (base64), onData, onTerminalResize, cols, rows, options. Pair it with useTerminal, as omfp:terminal does. |
PathLink |
An inline button opening a path: reference ({ path, line }), onOpen (from useOpenFile()). |
Tabs |
Tabs with TabList, Tab and TabPanel. |
ListBox |
A selectable list with ListBoxItem. |
Menu |
A menu with MenuItem and MenuTrigger. |
Select |
A drop-down: label (required), hideLabel, items ({ id, label }[], ids non-empty), selectedKey, onSelectionChange(key). |
TextField, TextArea, SearchField |
Text inputs: label, hideLabel, value, onChange; SearchField clears on Escape. |
PathField |
A path input completing on the daemon’s machine: label, value, onChange, onSubmit, complete (from usePathSources()). |
Checkbox |
Its label as children: isSelected, onChange(selected). |
RadioGroup |
One choice among Radio children (value each): label, value, onChange(value). |
Disclosure, Toolbar |
An expandable section; a row of controls. |
Dialog |
A modal dialog: title, children (or a function of { close }), isOpen, onOpenChange, isDismissable; or inside a DialogTrigger. |
ConfirmDialog |
A confirmation step: isOpen, onOpenChange, title, message, confirmLabel, onConfirm, tone: "danger", busy, error. Use it for every confirmation. |
Popover, PopoverDialog |
A non-modal overlay anchored to a trigger; a non-modal dialog in one, inside a DialogTrigger. |
Tooltip |
<TooltipTrigger><Button …/><Tooltip>hint</Tooltip></TooltipTrigger>; around a mark that is no button, wrap it in <Focusable> (it must take a ref and a role, e.g. role="img"). |