Official

ui

The look of the app's components: buttons, list rows, cards, settings, callouts, and the blocks and tables of replies. Edit a component here and the whole app draws with it.

The app opens the listing; nothing installs until an agent in your Plugins workspace has read the files and you enable the plugin. In a terminal: dvg install divergence/ui@0.1.2

Permissions in 0.1.2

  • Change app settings settings.writeHighChanges the app settings.Apply the components' look to the window

Files

components/button.tsx4.8 KB
/** @jsxRuntime classic */
/** @jsx template */
// A button: a label, an icon or both, in one of seven looks. The kernel
// makes any `role="button"` div a Tab stop that Enter and Space press,
// draws its focus ring and keeps a press from taking the keyboard.
import { prop, variants, when, type Definition, template } from "../define.ts";

// The looks with a fill and a field's size.
const FILLED = ["default", "outline", "primary", "accent", "ghost", "danger"];

export const button: Definition = {
  props: {
    label: null,
    icon: null,
    variant: "default",
    small: false,
    disabled: false,
    loading: false,
    // The selected look (a chip that is on, a rail button).
    active: false,
    tooltip: null,
    // Drawn in the muted text colour: a quiet control beside muted marks.
    muted: false,
    // A short count on the button's corner.
    badge: null,
    // The icon's size in px, for a glyph that reads narrower than its neighbours'.
    iconSize: null,
  },
  template: (
    <div role="button" label={prop("label", { else: prop("tooltip") })} tooltip={prop("tooltip")} isDisabled={prop("disabled")} stopPropagation={true} position="relative" display="flex" flexDirection="row" flexShrink={0} alignItems="center" justifyContent="center" height="density.fieldHeight" paddingX="0.5rem" borderRadius="field" lineHeight="125%" $when={[
          ...variants({
            variant: {
              default: { background: "muted", color: "foreground" },
              outline: { background: "muted", color: "foreground" },
              primary: { background: "primary", color: "primaryForeground" },
              accent: { background: "accent", color: "foreground" },
              ghost: { color: "foreground" },
              danger: { background: "danger", color: "dangerForeground", elevation: "raised" },
              chip: { background: "muted/40", color: "mutedForeground", fontSize: "xs" },
            },
          }),
          ...variants(
            {
              variant: {
                default: { hover: { background: "hover" }, active: { background: "accent" } },
                outline: { hover: { background: "hover" }, active: { background: "accent" } },
                primary: { hover: { background: "primaryHover" }, active: { background: "primaryActive" } },
                accent: { hover: { background: "accent/140" }, active: { background: "accent/160" } },
                ghost: { hover: { background: "hover" }, active: { background: "accent" } },
                danger: { hover: { background: "dangerHover" }, active: { background: "dangerActive" } },
                chip: { hover: { background: "hover" }, active: { background: "accent" } },
              },
            },
            "!disabled",
            "!loading",
          ),
          when("small", { height: "1.5rem" }),
          when("!label", { width: "1.5rem", paddingX: 0 }),
          // An icon alone on no fill keeps the toolbar's square.
          when([{ variant: "ghost" }, "!label"], { width: "2rem", height: "2rem", borderRadius: "sm" }),
          when([{ variant: "ghost" }, "!label", "small"], { width: "1.5rem", height: "1.5rem" }),
          when({ variant: "chip" }, { height: "1.25rem", paddingX: "0.25rem", borderRadius: "md" }),
          when([{ variant: "chip" }, "!label"], { width: "1.25rem", paddingX: 0 }),
          when([{ variant: FILLED }, "disabled"], { color: "mutedForeground/50" }),
          ...variants(
            {
              variant: { primary: { background: "primary/15" }, danger: { background: "danger/15", elevation: "edge" } },
            },
            "disabled",
          ),
          when(["muted", "!disabled"], { color: "mutedForeground" }),
          when("loading", { isDisabled: true, opacity: 0.8 }),
          when("active", { background: "accent", color: "foreground" }),
        ]}>
      <div display="flex" flexDirection="row" alignItems="center" justifyContent="center" gap="0.25rem" width="fill" height="fill" minWidth={0} overflow="hidden" whiteSpace="nowrap" fontSize="sm" $when={[when({ variant: "chip" }, { fontSize: "xs" })]}>
          <icon $if={["icon", "!loading"]} name={prop("icon")} size={prop("iconSize")} small $when={[when([{ variant: "ghost" }, "!label", "!small"], { small: false })]} />
          <spinner $if={["icon", "loading"]} activity />
          <text $if="label" text={prop("label")} $when={[when({ variant: FILLED }, { fontSize: 12.5 }), when({ variant: "chip" }, { truncate: true })]} />
        </div>
      <div $if="badge" position="absolute" top={-4} right={-6} minWidth={14} height={14} paddingX={3} display="flex" alignItems="center" justifyContent="center" borderRadius="full" background="warning" color="warningForeground" fontSize={9} lineHeight={14} fontWeight={600}><text text={prop("badge")} /></div>
    </div>
  ),
};

Versions

VersionPublishedPlugin APISizePermissionsStatus
0.1.2latestNov 21, 2026>=5 <610.6 KB1 permissionListed
0.1.1Nov 16, 2026>=5 <610.2 KB1 permissionListed
0.1.0Nov 9, 2026>=5 <68.8 KB1 permissionListed

Reviews and comments

0 threads · 0 reviews

No comments yet.