The UI kit
Components with the theme's look for screens and panels of your own: buttons, panels, dialogs, menus, sliders, selects, tooltips, toasts, a timeline. It is Solid on Ark UI, from @v12-engine/client/kit.
Quick start
import { useOverlays, tooltip } from '@v12-engine/client/kit'
// in a component under the game's HUD
const overlays = useOverlays()
overlays.toast('Gold mine collapsed', { tone: 'danger' })
if (await overlays.confirm({ title: 'Leave the game?', danger: true })) leave()
overlays.openMenu({ x, y }, [{ label: 'Rename', key: 'F2', run: rename }])
tooltip(element, 'Attack', { key: 'A' }) // or data-tip="Attack" on any elementA toast, a confirm dialog, a context menu and a tooltip, all in the game's theme and in its element.
Common tasks
Theme the game
hud: { theme: 'moonlight' } // a theme by name
hud: { theme: { accent: '#7fe07a', radius: '6px' } } // values over the default
hud: { theme: (base) => ({ ring: base.danger }) } // worked out from the default
client.theme.set('moonlight'); client.theme.get(); client.theme.reset(); client.theme.onChange(listener)
registerTheme('orc', { accent: '#c0392b' }) // for everyoneThe default (classic) is deep navy with a fine gold edge and Cinzel over Barlow Semi Condensed, the HUD's frames in gold (the skin gilded). stone is the older look: stone panels, a bronze edge, square corners, Alegreya. iron, bone and jade are the HUD's other skins: its frames in another metal (Skins).
Give a race its own look
// over the client's bone skin: its frames in old bone, a green gem
registerTheme('restless', { accent: '#9ccf6a', border: '#2f3d2a' }, 'bone')
export const meleeView: GameView = {
races: { undead: { theme: 'restless', messages: { supplyBlocked: 'Not enough food, build more bone spires' } } },
hud: { messages: { supplyBlocked: 'Not enough food, build more farms' } }
}A RaceLook has a theme, music (tracks in place of the game's), an icon (client.raceLook) and messages. It goes on as the session says the player's race.
Load the styles
import '@v12-engine/client/styles.css' // built: no Tailwind needed
import '@v12-engine/client/fonts.css' // the theme's typefaces, from the package (no font service)A project with its own Tailwind imports @v12-engine/client/tailwind.css instead and builds it with its own. A page that opens the editor adds @v12-engine/editor/styles.css after the client's. The styles apply only inside an element marked data-vg (a game's or the editor's).
Write a panel without Solid
kit.classes.button({ variant: 'primary' })
kit.button(label, run, options)
kit.panel()
kit.render(element, Component, props) // a kit component in an element
kit.searchField(onValue, { placeholder })Add a search field
SearchField takes words, has a clear button, and Ctrl+F or / focuses it while its panel has the keyboard. Filter with matchWords(query, text), filterBy(items, query, textOf) or rankBy(items, query, textOf) (what starts with the words first).
Draw a timeline
import { createSignal } from 'solid-js'
import type { TimelineSelection } from '@v12-engine/client'
import { Timeline, type TimelineEdit, type TimelineLane } from '@v12-engine/client/kit'
const lanes: TimelineLane[] = [{ id: 'camera', items: [{ at: 0 }, { at: 2, for: 3, label: 'A clip' }] }]
const [picked, setPicked] = createSignal<TimelineSelection>({ items: [], markers: [] })
const [now, setNow] = createSignal(0)
const apply = (edit: TimelineEdit) => {
if (edit.kind === 'seek') setNow(edit.at)
if (edit.kind === 'select' && edit.selection !== 'all') setPicked(edit.selection)
}
export const Clips = () => (
<Timeline lanes={lanes} span={20} pps={60} playhead={now()} selection={picked()} markers={[{ at: 1, name: 'Start' }]} onEdit={apply} />
)The Timeline keeps nothing itself: it reports edits as data and you apply them. The editor's Cinematic and Effects panels are made of it.
Give the game's overlays your own look
hud: { overlays: { toast: { component: MyToast }, dialog: { mount: drawDialog } } } // OverlayLooks: tooltip, toast, dialog, menu
startApp({ overlays }) // the app's own screensReference
Components
What only looks: Button, IconButton, Panel, Text, Kbd, Meter, ScrollArea, Field, TextField, TextArea, SearchField, Label, and the looks as classes (classes). What opens, floats, folds and picks is Ark UI underneath (@ark-ui/solid), with the kit's look:
| Kit component | Ark part | Its own props |
|---|---|---|
Dialog, confirm, openDialog | Dialog | open, onClose, title, footer, class, mount |
MenuButton, ContextMenu, openMenu (MenuAt) | Menu | items (a list, or a function asked as it opens), menu |
Popover, Floating | Popover | trigger, placement, open, onOpen, class |
data-tip, tooltip(), tip(), Tooltip | Tooltip | words or a component (tip(() => <AbilityTip />, { rich: true })); key, placement, delay, rich |
toast, shown by OverlayRoot | Toast | tone, seconds, action |
Slider | Slider | value, onValue (while sliding), onCommit (on release), min, max, show |
Toggle | Switch | on, onValue, label |
Select | Select | value, onValue, options, none, placeholder, size, wide, select |
NumberField | Number input | value, onValue, onEmpty, placeholder, size, steppers, settle; =10*3 is worked out (evaluateNumber) |
SearchSelect | one of many, by typing | value, onValue, options (value, label, detail, words), none, find, placeholder, size |
Checkbox | Checkbox | checked (or 'mixed'), onValue |
ColorField | Colour picker | value (#rrggbb), onValue, onCommit, swatches, typed |
Tabs | Tabs | tabs, value, onValue, the content as a function of the tab id |
Collapsible, Combobox, ColorPicker, TreeView, Splitter, Tour | the same, as parts | parts only |
Timeline | none (a pointer machine) | lanes, span, pps, markers, playhead, inOut, selection, onEdit, onZoom |
pickFiles({ accept, multiple }) opens the player's files.
Rules for every component
- Open to change. Each takes
classand every prop of its Ark part (<Dialog role='alertdialog' closeOnInteractOutside={false}>), and gives its parts to put one together (Dialog.Root,Dialog.Content,Menu.Item,Select.Item,Tabs.List…). Use Ark directly (import { Accordion } from '@ark-ui/solid/accordion') withstyled(Part, 'classes'). - The look is classes. Tailwind or your stylesheet over the theme's variables, plus Ark's state attributes (
data-[highlighted]:bg-panel-raised). - Overlays go in their game's element by themselves (
OverlayPlaceContext), so two games on a page stay apart. A part put together by hand goes there with<Portal mount={useOverlayMount()}>. - Tooltips are said, not built:
tipon a kit component,data-tipon an element,tooltip(element, …)on what Solid didn't make. One shared tooltip shows them, so hundreds of buttons cost nothing. A tooltip shows after a moment (data-tip-delay, seconds). - Every control is the kit's in the client and editor (a lint says so):
Button(variant,facewithsizesquare,square-sm,sm,md,pressed;bare;size: 'unsized'),TextFieldandTextArea(variant: 'bare'),Label,Collapsible. No nativebutton,input,select,textarea,detailsorlabel.
Overlays
useOverlays() reaches the game's overlays from a component under its HUD; a dialog left open when the game goes answers undefined. createOverlays() makes a set of your own, shown by <OverlayRoot overlays={...} mount={element} />.
Theme tokens
The theme is CSS variables (Tokens): --vg-panel, --vg-accent, --vg-border, --vg-foreground, --vg-radius, --vg-typeface-display, --vg-motion and the rest. Tailwind's colours are those variables (bg-panel, text-accent, border-border), so whatever uses them follows the theme; they are --vg- ones, so shadcn/ui on the same page keeps its own. Derived: bg-accent-soft, border-accent-line, shadow-raised, shadow-floating. Four tones colour stat lines (--vg-tone-physical, -magic, -defense, -resist). The HUD's frames are the skin's (--vg-metal-light, --vg-metal, --vg-metal-dark, --vg-frame-face, --vg-texture, --vg-key-letter, --vg-gem, --vg-ornament: Skins).
The theme is written onto the game's element (GameClientOptions.root, the canvas's parent by default), so the page and other games keep theirs. The editor has its own theme, editor; registerTheme('editor', …) changes it.
Typefaces
Cinzel for names and titles, Barlow Semi Condensed for the rest; Alegreya and Alegreya Sans for stone and text drawn in the world. They come as files in the package via @v12-engine/client/fonts.css.
Solid
The interface is Solid 1.9, which comes with the client. A project that writes components adds solid-js (^1.9) and vite-plugin-solid. The page must run one copy of Solid (the client's Vite plugin sets resolve.dedupe); in development, launch warns once if two are loaded.
Timeline details
- Lanes are data (
TimelineLane:id,items, eachat,for,label,color,tip). - Edits (
TimelineEdit):select,seek,moveandtrim(phasesstart,live,done,cancel),add(double-click), and from keyssplit,remove,zoom,fit. - Drags snap to what is near (
snapTime,rulerTicks,formatTimeof@v12-engine/client); Ctrl or ⌘ held turns snapping off. Alt drags a copy, the middle button pans, Ctrl+wheel zooms. - Keys:
timelineActions(command, labels)lists them (split,delete,select-all,deselect,zoom-in,zoom-out,fit);timelineActionEdit(id, { playhead, selection })gives the edit each asks. - Custom rows:
lanewith the partsTimelineRow,TimelineKeyframe,TimelineClip,TimelineEdge;createTimelineDrag(items: TimelineItems, options)(pick: 'release',trimFrom).