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
| API | Contract |
|---|---|
[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.Instance | Generated 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
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
<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
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
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# type | Behavior |
|---|---|
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 / ulong | TypeScript bigint |
| Enum | TypeScript union of string enum names |
See State and collections and DTO rules for initialization and supported shapes.
UI image exports
| API | Contract |
|---|---|
LoomImageSource | Opaque generated type for Texture2D, Sprite, and RenderTexture state |
LoomImage | Requires 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.
NavigationProvider
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.
| Prop | Default | Behavior |
|---|---|---|
bindings | { submit: 'south', back: 'east' } | Partial button-binding overrides |
timing | See below | Partial directional timing overrides |
keyboard | true | Enables 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.
NavigationScope
Requires an ancestor NavigationProvider. Renders a div and accepts its
ordinary HTML attributes and children.
| Prop | Required / behavior |
|---|---|
name | Required string identifying the scope and its remembered focus |
defaultFocus | Optional selector for initial/fallback focus; a remembered eligible control takes precedence |
backTarget | Optional 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
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.
| Command | Use |
|---|---|
| Setup UI Project | Creates the starter UI/ app and installs dependencies; does not overwrite an existing app |
| Setup UI in Current Scene | Adds LoomUI and configures the project’s URP renderers |
| Sync UI Dependencies | Updates bundled Loom UI packages to match the Unity package |
| Regenerate Types | Manually rewrites the UI bridge contract; Loom also generates it automatically after C# recompilation outside Play mode |
| Start Dev Server | Starts Loom’s managed Vite server without entering Play |
| Restart Dev Server | Restarts Loom’s managed Vite server |
| Stop Dev Server | Stops Loom’s managed Vite server |
| Force UI Reload | Reloads the UI in Play mode, starting the dev server first if needed |
| Open Browser DevTools | Opens Firefox’s remote debugging page for the live UI on 127.0.0.1:6080 |
| Open UI Source | Shows the UI/ folder in Finder or Explorer |
| Open Generated bridge.d.ts | Shows the generated bridge declarations in Finder or Explorer |
| Doctor | Reports the environment checks in the Unity Console |
| Status Window | Shows the same checks in a dockable window |
| Build UI for Player | Runs the production UI build |
| License Info | Shows Loom’s license and third-party notice information |