On this page

Requirements

  • A NitroUI 0.2 app (nitro-ui-renderer, nitro-ui-core, nitro-ui-cli). The kit is tested against NitroUI 0.2.1.
  • Bun 1.4 for the NitroUI CLI, and Xcode with an iOS 26 simulator for iOS builds.
  • React 19.3, which NitroUI uses.

Install

The kit is a private workspace package (packages/nitro-ui-sdk) in this repository. Run commands from an app directory inside the workspace (such as apps/example, or a new app under apps/):

pnpm add "nitro-ui-sdk@workspace:*" nitro-ui-glass@0.2.1

Quote "nitro-ui-sdk@workspace:*" in zsh and other shells that expand * before passing arguments to pnpm. Equivalently, add both entries to the app’s package.json:

{
  "dependencies": {
    "nitro-ui-sdk": "workspace:*",
    "nitro-ui-glass": "0.2.1"
  }
}

Then install from the workspace root and let the NitroUI CLI link the native code from your app directory:

pnpm install
bun run nitro-ui prepare

nitro-ui prepare discovers the kit’s native module (KitControls, declared in its nitro.json), generates the Swift, Kotlin and JavaScript bindings for its views, and wires them into the app’s native projects. Run it again, and rebuild the app, whenever the kit’s native code changes. The example app lists node_modules/nitro-ui-glass under modules in its app.json so the glass views are linked too:

{
  "name": "MyApp",
  "modules": ["Modules/*", "node_modules/nitro-ui-glass"]
}

Wrap the app in ThemeProvider

Every family reads its tokens from ThemeProvider. Pass the current scheme; the other props are optional.

import { Appearance, registerApp } from "nitro-ui-renderer";
import { ThemeProvider } from "nitro-ui-sdk/theme";
import { Home } from "./Home";

function App() {
  const scheme = Appearance.getColorScheme() === "dark" ? "dark" : "light";
  return (
    <ThemeProvider scheme={scheme}>
      <Home />
    </ThemeProvider>
  );
}

registerApp(App);
Prop Type Default Description
scheme "light" | "dark" required Which token set to use.
tokens Record<Scheme, ThemeTokens> defaultTokens Your tokens, usually from createTokens.
glass boolean true Request Liquid Glass in MaterialView, MaterialGroup and families built on them. false draws their opaque fallback (system-presented native overlays still follow iOS).
reducedMotion boolean false Collapse animation durations to zero.
reducedTransparency boolean false Draw opaque surfaces instead of glass.

See Theming for tokens and dark mode.

Render a first component

Import each family from its subpath. Most interactive controls require a label (while structured families take item labels or a presentation title, such as Tabs and Sheet): it is the spoken name and the name agents see.

import { Button } from "nitro-ui-sdk/button";

export function SaveButton({ onSave }: { onSave(): Promise<void> }) {
  return <Button.Root label="Save" onPress={() => onSave()} />;
}

Without custom children, Button.Root renders Button.BusyIndicator and Button.Label automatically (if you supply custom children, include Button.BusyIndicator or Button.Leading to keep the spinner). An onPress that returns a promise keeps the button busy, with a native spinner and a stable label, until the promise settles. A second press while it is busy returns "disabled".

Drive it with a controller

Create one controller per mounted instance with the primitive’s createApi and pass it as api. While the component is mounted, controller.current holds the same actions touch uses. For destructive, payment or send actions, pass confirm so an agent press waits for a person to approve it:

import { useState } from "react";
import { Button, buttonPrimitive } from "nitro-ui-sdk/button";

export function Checkout({ pay }: { pay(): Promise<void> }) {
  const [payButton] = useState(buttonPrimitive.createApi);

  // From a keyboard shortcut, a test or a deep link:
  // payButton.current?.press();  // "accepted" | "disabled" | "refused" | "unavailable"

  return (
    <Button.Root
      api={payButton}
      label="Pay"
      confirm={{ message: "Pay now?", approveLabel: "Pay", cancelLabel: "Cancel" }}
      onPress={() => pay()}
    />
  );
}

onPress receives details.source: "user" for touch, "agent" for the agent and "api" for payButton.current?.press(). Only touch plays a haptic. Read Controllers and values for value families such as Switch and Slider.

Next steps

  • Components: every family with its anatomy, props and controller.
  • Agent API: make a screen drivable by an agent.
  • Example app: run every component on the simulator.