API reference API reference
API reference

API reference

Look up bridge declarations, Solid startup and event APIs, navigation options, images, and Editor commands.

C# APIs use the Loom namespace. Import the Solid APIs and TypeScript types below from @loomgui/bridge. For a walkthrough, start with The bridge model.

Bridge declarations

APIContract
[Bridge]Marks the single root class; it must be partial and inherit LoomBridgeBase
[BridgeAction]Exposes a public method on the root or a nested state DTO
[BridgeIgnore]Excludes a public state or event member
[BridgeName("name")]Overrides a member’s generated camelCase name
UIBridge.InstanceGenerated accessor on your bridge class; available after Loom initializes it

Public value properties expose state. Assigning a property sends the updated value to the UI. Computed getters do not automatically notify when their inputs change; see Computed values.

UI startup and context

bootBridge

ts
bootBridge(options: LoomBootOptions): Bridge

Creates the bridge at app startup, normally in UI/src/bridge.ts. Supply initial state and, for browser previews, mock action handlers. See the bootBridge reference for options, return behavior, environment selection, and an example.

BridgeProvider

TSX
<BridgeProvider value={bridge}>
  <App />
</BridgeProvider>

Requires a Bridge value, normally returned by bootBridge. Wrap the app so its components can use bridge context. The starter does this in index.tsx.

useBridge

ts
useBridge(): Bridge

Call during component setup beneath BridgeProvider; it throws when the provider is missing. Returns the bridge object with its generated properties and methods. Read state in Solid’s reactive expressions, and request game changes through actions.

onEvent

ts
onEvent<K extends keyof BridgeEvents>(
  name: K,
  handler: (data: BridgeEvents[K]) => void,
): void

Call during component setup beneath BridgeProvider. Payloads follow the generated event type. The subscription is removed when its Solid owner is disposed; no unsubscribe value is returned. Do not call at module scope or from a click callback. See Events.

Actions and events in C#

A [BridgeAction] method accepts supported DTO or scalar parameters and may return void, a value, Task, or Task<T>. The generated UI call always returns a Promise; an exception rejects it. See Actions.

Declare an event with public Event<DamageEvent> TookDamage { get; } = new(); and send it with TookDamage.Fire(payload). An event is not replayed after a reload. Store values the UI needs to recover in state.

Collections and value types

C# typeBehavior
List<T> / T[] / Dictionary<K,V>Snapshot; reassign the property to sync changes
ReactiveList<T> / ReactiveMap<K,V>Sends individual inserts, removals, and updates
long / ulongTypeScript bigint
EnumTypeScript union of string enum names

See State and collections and DTO rules for initialization and supported shapes.

UI image exports

APIContract
LoomImageSourceOpaque generated type for Texture2D, Sprite, and RenderTexture state
LoomImageRequires a source prop accepting LoomImageSource, null, or undefined; accepts ordinary image attributes such as alt, class, and style
createMockImageSource(url: string)Returns a LoomImageSource backed by a browser URL for mock state

Use <LoomImage source={bridge.icon} alt="Item" />. A null or temporarily unavailable source displays no image. Texture2D and Sprite are snapshots; RenderTexture stays live without reassignment. Image references are state-only, not action parameters, return values, or event payloads. See Unity image sources.

Built-in state

Every bridge includes read-only loom state. Do not supply it in initial. See Built-in Loom state for the field table.

Wrap the app once. It supplies the controller used by nested NavigationScope components and is disposed with its Solid owner. Its options configure the controller when the provider is created.

PropDefaultBehavior
bindings{ submit: 'south', back: 'east' }Partial button-binding overrides
timingSee belowPartial directional timing overrides
keyboardtrueEnables the provider’s keyboard handling; independent of Unity action maps and LoomRuntime.KeyboardMode

Timing defaults are deadZone: 0.55, releaseZone: 0.35, initialRepeatDelay: 350, and repeatInterval: 100. Delay and interval are in milliseconds; releaseZone must be lower than deadZone.

Requires an ancestor NavigationProvider. Renders a div and accepts its ordinary HTML attributes and children.

PropRequired / behavior
nameRequired string identifying the scope and its remembered focus
defaultFocusOptional selector for initial/fallback focus; a remembered eligible control takes precedence
backTargetOptional selector for the control clicked by the back command

Buttons, links, and form controls are discovered automatically when visible and enabled. Use stable element IDs for remembered focus. Directional attributes are data-loom-nav-up, data-loom-nav-right, data-loom-nav-down, and data-loom-nav-left; their values are an ID selector within the scope, auto, or none.

LOOM_NAVIGATION_EVENT is loomnavigation, a bubbling, cancelable event whose detail has command, source, and scope. Prevent its default to handle a command yourself. See Keyboard and gamepad navigation for bindings, focus behavior, and complete examples.

Keyboard mode in Unity

C#
LoomRuntime.KeyboardMode = LoomKeyboardMode.Gameplay;   // default
LoomRuntime.KeyboardMode = LoomKeyboardMode.Navigation; // Tab / Shift+Tab traversal

Switch the game’s action map and visible screen alongside this property. Input forwarding does not consume Unity gameplay input; see Keyboard ownership.

Editor menus

All commands are under Tools > Loom.

CommandUse
Setup UI ProjectCreates the starter UI/ app and installs dependencies; does not overwrite an existing app
Setup UI in Current SceneAdds LoomUI and configures the project’s URP renderers
Sync UI DependenciesUpdates bundled Loom UI packages to match the Unity package
Regenerate TypesManually rewrites the UI bridge contract; Loom also generates it automatically after C# recompilation outside Play mode
Start Dev ServerStarts Loom’s managed Vite server without entering Play
Restart Dev ServerRestarts Loom’s managed Vite server
Stop Dev ServerStops Loom’s managed Vite server
Force UI ReloadReloads the UI in Play mode, starting the dev server first if needed
Open Browser DevToolsOpens Firefox’s remote debugging page for the live UI on 127.0.0.1:6080
Open UI SourceShows the UI/ folder in Finder or Explorer
Open Generated bridge.d.tsShows the generated bridge declarations in Finder or Explorer
DoctorReports the environment checks in the Unity Console
Status WindowShows the same checks in a dockable window
Build UI for PlayerRuns the production UI build
License InfoShows Loom’s license and third-party notice information
Loom documentation

Search docs

Esc

Type a word or phrase to search the documentation.

Type a word or phrase to search the documentation.