Create a widget
How to build, package, and organize a widget for Appinapp.
Folder naming
Your widget folder name must end with
.widget — the app only recognizes folders with this suffix as widgets.Clock.widget
Layout
Every widget folder must contain these files at its root:
Clock.widget/
├── index.jsx # widget code (REQUIRED — the only entry point)
└── config.json # OPTIONAL declarative defaults (geometry, placement, behavior)
A widget is only recognized if the folder contains an
index.jsx. Without index file, the app skips the folder.index.jsx
The app loads
should export React component as default, plus optional config exports.
index.jsx, compiles JSX in place, and reads its exports. Youshould export React component as default, plus optional config exports.
Imports — limited environment
Only three modules resolve inside a widget:
import { useState } from "appinapp-react";
import { Clock } from "appinapp-icons";
import Scritto from "appinapp-animations";
System-audio frames and now-playing info arrive through dedicated
modules (never shell out — widgets must not depend on binaries the user
may not have installed):
modules (never shell out — widgets must not depend on binaries the user
may not have installed):
import { onAudioFrame } from "appinapp-audio";
import { onNowPlaying, onPlayers, togglePlayPause } from "appinapp-music";
Any other
npm deps. Bring your own logic in the file. Relative
(images, fonts,
absolute paths are rejected.
import throws Import not allowed: <name>. Nonpm deps. Bring your own logic in the file. Relative
./ asset imports(images, fonts,
.css) resolve to data URLs / text; .. segments andabsolute paths are rejected.
Minimal widget
import { useState } from "appinapp-react";
export default function Widget() {
return <div className="widget">Hello</div>;
}
Widget props
The app provides
output, error, run, setHeight, setWidth, setX, setY:export const command = "whoami"
export default function Widget({ output, error, run }) {
if (error) {
return <div style={{ color: "red" }}>{error}</div>;
}
return <div>{output}</div>;
}
| Prop | What it is |
|---|---|
output | stdout string from your command (see below) |
error | error if the command failed (null on success) |
run | async (cmd) => stdout — run a shell command in the widget dir (throws on failure) |
setHeight / setWidth / setX / setY | resize/move the live instance (persisted) |
looks | user's customization values merged over your looks schema defaults (see below); {} when you don't export looks |
| Export | Type | Effect |
|---|---|---|
default | Component | The widget UI (or export render) |
command | string | Shell command, stdout → output prop (read once at add-time; afterwards the per-instance copy wins) |
className | string | CSS injected as <style> |
looks | object | Customization schema — a paintbrush button on the widget row opens the Looks editor built from it; values persist per instance and arrive as the looks prop |
index.jsx exports exactly these four things. Geometry, refresh interval,surfaces, z-index, workspaces, click-through, and glass live in
config.json, never in JS.The strings
refreshFreq, surface, allWorkspace(s),visible_on_all_workspaces, and colors do not exist anywhere in the app —never use them.
Looks customization (user "looks")
Export a
app shows a paintbrush button on the widget row (only when a non-empty
user's values per widget instance, and passes the merged values
(schema
looks object to let users customize colors, sizes, fonts, and text. Theapp shows a paintbrush button on the widget row (only when a non-empty
looks exists), opens the Looks editor from the schema, stores theuser's values per widget instance, and passes the merged values
(schema
default + user's edits) to your component as the looks prop.Field types (discriminated on
type):type | Value | Extra keys | Dialog control |
|---|---|---|---|
"text" | string | — | text input |
"color" | string (hex) | — | color picker + hex input |
"font" | string (font-family name, e.g. "Helvetica Neue" or "system-ui") | — | searchable font selector |
"number" | number | min?, max?, step? | number input + slider (clamped) |
"select" | string | options (`(string | { label, value })[]`) |
"checkbox" | boolean | — | checkbox toggle |
const Weather = ({ looks }) => (
<div style={{
background: looks.bg,
color: looks.text,
borderRadius: looks.radius,
fontSize: looks.size,
fontFamily: looks.font,
padding: 14,
}}>
<span style={{ color: looks.accent }}>Tashkent</span> 21° ☀︎
</div>
);
export default Weather;
export const looks = {
bg: { type: "color", label: "Background", default: "#1c1c1e" },
text: { type: "color", label: "Text color", default: "#f5f5f5" },
accent: { type: "color", label: "Accent", default: "#34d399" },
font: { type: "font", label: "Font", default: "system-ui" },
radius: { type: "number", label: "Roundness", default: 14, min: 0, max: 32, step: 1 },
size: { type: "number", label: "Font size", default: 14, min: 10, max: 48 },
};
The
font field:- Value is a plain font-family string — use it directly as
fontFamilyin a style:fontFamily: looks.font. - The selector lists the fonts actually installed on the user's system (detected by the host), each option previewed in its own font. It has a built-in search field.
"system-ui"is a recognized special value meaning the system font; use it as the safedefault.- If the stored value isn't in the detected list, the editor shows it as an extra entry so nothing breaks.
- Don't assume any specific font beyond
"system-ui"is available — treat other families as best-effort.
Notes:
looksis a plain object literal — only the six field types above are recognized.- The
looksprop is always present when you export a schema (keys merged over defaults, sanitized; unknown keys dropped, wrong types fall back todefault, numbers clamped). - Reset in the dialog restores every field's
default. Values persist per instance (active_widgets.json) — editingdefaults later does not change existing instances (delete + re-add to re-seed). - The export is
looksand the prop islooks— the namethemedoes not exist anywhere in the app, never use it.
Config.json (declarative defaults)
Create a
config.json next to index.jsx to provide defaults that apply when users add your widget. All keys optional, canonical keys only — unknown keys are dropped:{
"renderMode": "board",
"zIndex": "top",
"height": 100,
"width": 100,
"x": 10,
"y": 20,
"onAllWorkspaces": true,
"clickThrough": false,
"refreshFrequency": 3000,
"liquidGlass": {
"enabled": false,
"variant": 0,
"corner_radius": 5,
"tint_color": "#FFFFFF80"
}
}
Tip:
refreshFrequency supports * expressions like "5 * 1000" (5 seconds) or "60 * 60 * 1000" (1 hour). 0/null/missing = run command once, no interval.Canonical keys (all optional):
renderMode—"board"|"window"zIndex—"bottom"|"normal"|"top"height,width,x,y— numbersonAllWorkspaces— booleanclickThrough— boolean (window surface only; mouse events pass through the widget)refreshFrequency— ms or*expression (e.g.,"5 * 1000","60 * 60 * 1000")liquidGlass— object withenabled,variant,corner_radius,tint_color
Note:
Note:
liquidGlass is entirely optional - omit for defaults (enabled: false, variant: 0, corner_radius: 5).Note:
command is NOT a config.json key — it comes from the index.jsx export and seeds the per-instance default at add-time. Gallery metadata (name, description, email) is not read from config.json by the app — do not add it here.Precedence (highest wins):
config.json(per-type defaults — read at widget add time)active_widgets.json(per-instance WidgetConfig — user overrides via WindowSettings)index.jsxcommandexport (seeds the per-instance command at add-time only)- Built-in defaults
config.json is read as defaults at add time — WindowSettings edits the per-instance copy afterwards, so editing the file later does not move existing instances (delete + re-add to re-seed).Sizing — window vs board (important)
width / height are plain pixel numbers, and the component always renders inside exactly a width × height box — no matter the surface:windowmode: the widget is its own OS window whose content area is exactlywidth × heightpx.boardmode: the widget is awidth × heightpx rectangle atx, yinside the shared fullscreen transparent overlay (the overlay covers the whole screen; your widget is just a rect inside it).
Never use viewport units (
vw, vh, dvh, dvw) or window.innerWidth/innerHeight. The component has no viewport of its own, and the same stored width/height carry over if the widget's renderMode is later switched between window and board. Example of what breaks: a widget styled with height: 100vh "works" in window mode, but on the board 100vh resolves against the fullscreen overlay, so the content becomes screen-sized inside a small rect — the layout is destroyed.Rules:
- Design for the configured
width × heightbox — treat it as a fixed-size canvas. - Always set concrete pixel
width/heightinconfig.json(e.g.200×80); don't rely on screen-relative guesses. - Make the root fill the box (
width: "100%", height: "100%") and adapt inner content with flex/percent/overflow — percent values are relative to the widget box, which is safe on both surfaces. - Programmatic resizing uses only
setWidth/setHeight— pixel numbers, never"100%"/"100vh"strings (they arenumberparams). - To react to size changes, measure the DOM (
ResizeObserveron your root element), not the window. - Keep both modes in mind: a widget that only looks right fullscreen breaks when moved to a window, and vice versa.
Styling
The app supports Tailwind classnames — write Tailwind utility classes directly in your JSX:
export default function Widget({ output }) {
return (
<div className="flex items-center gap-2 rounded-lg bg-background px-3 py-2 text-sm text-muted-foreground">
{output}
</div>
);
}
No build step, no config, no import — the host compiles the classes your widget uses at runtime (dynamic ones included) and scopes them to the widget, so they never override the app's styles. Variants (
hover:, dark:, md:), arbitrary values (w-[37px]), the app's theme tokens (bg-background, text-muted-foreground, rounded-lg, …), and animate-in/fade-in-* all work out of the box. Tailwind's preflight already applies.Besides Tailwind classnames you can use inline
style={{...}}, imported .css files, and the className export (raw CSS injected as <style>). Don't put @apply in the className export — it's injected verbatim, never compiled; use Tailwind classes in JSX instead.Full example
// index.jsx
export const command = "date +%H:%M:%S";
export const className = `
.clock { font: 600 28px monospace; color: #fff; padding: 12px; }
`;
export default function Clock({ output, error }) {
if (error) return <div className="clock">err</div>;
return <div className="clock">{output || "--:--:--"}</div>;
}
// config.json
{
"renderMode": "board",
"zIndex": "top",
"width": 200,
"height": 80,
"x": 40,
"y": 40,
"onAllWorkspaces": true,
"clickThrough": false,
"refreshFrequency": 1000,
"liquidGlass": {
"enabled": false,
"variant": 0,
"corner_radius": 5
}
}
screenshot.png
A preview image shown in the app gallery. Capture your widget running.
It's aspect ratio should be between
1.3 - 3:Forced UP to
2.25 (9/4) (because they're below the minimum):| Ratio | Value | What it is |
|---|---|---|
1/1 | 1.0 | Square |
4/5 | 0.8 | Instagram portrait |
9/16 | 0.56 | Vertical phone video/story |
3/4 | 0.75 | Portrait photo |
5/4 | 1.25 | Slightly wide print photo |
All of these become
1.3 — the function treats squares and anything portrait-oriented (taller than wide, or just barely wide) as "too narrow" and pushes them up.Left UNCHANGED (already inside
1.3–3):| Ratio | Value | What it is |
|---|---|---|
4/3 | 1.33 | Old TV / classic photo |
3/2 | 1.5 | 35mm film / DSLR photo |
16/9 | 1.78 | Widescreen video/monitor |
2/1 | 2.0 | Wide banner |
21/9 | 2.33 | Ultrawide monitor |
2.35/1 | 2.35 | Cinematic movie |
These pass through exactly as-is since they already fall in the
1.3–3 sweet spot.Forced DOWN to 3 (because they're above the maximum):
| Ratio | Value | What it is |
|---|---|---|
16/5 | 3.2 | Very wide banner |
4/1 | 4.0 | Extreme panorama |
32/9 | 3.56 | Super ultrawide monitor |
All of these become
3 — capped rather than left at their true, more extreme value.Bottom line: the only ratio "zone" that survives untouched is roughly between 4:3 and slightly beyond cinematic widescreen (1.3–3). Anything square or portrait gets pulled up to
2.25.README.md
Describe what the widget does and how to customize it. It will be shown to users when open
your widget. Follow the template below! Examples
your widget. Follow the template below! Examples
- Name
- Description
- Features
- How it works
- Customization
- Notes
- License