# Function page reference

> SDUI spec syntax, imports, component directives, and actions—quick lookup for function page authors.

## Overview

Quick reference for authoring **function pages**: imports, `render`, component directives, and catalog actions. For conceptual background, see [Get started](https://developer.rippling.com/documentation/rippling-platform/sdui/getting-started). For calling your function from the page, see [Server round-trips](https://developer.rippling.com/documentation/rippling-platform/sdui/server-round-trips).

**On this page:** [Imports](https://developer.rippling.com/documentation/rippling-platform/sdui/reference#import-rippling-modules) · [Render](https://developer.rippling.com/documentation/rippling-platform/sdui/reference#render-the-page) · [Component configuration](https://developer.rippling.com/documentation/rippling-platform/sdui/reference#component-configuration) · [Actions](https://developer.rippling.com/documentation/rippling-platform/sdui/reference#actions)

* * *

## Import Rippling modules

Function page specs use two packages from the SDUI toolchain: the core module and the custom-apps catalog.

### Main module

Baseline spec helpers, logic utilities, and types.

-   **Import path:** `@rippling/pebble-sdui-web`
-   **What's included:** `createSpec`, logic helpers (`equals`, `neq`, `truthy`), and types (`SpecContext`).

### Catalog module

Components, layout helpers, actions, and catalog introspection.

-   **Import path:** `@rippling/pebble-sdui-web/catalogs/custom-apps`
-   **What's included:** UI components (`Button`, `Text`), action creators (`setState`), `render`, and lookup helpers (`getComponent`, `getAction`).

### Inspect catalog definitions

```typescript
import {
  getAction,
  getComponent,
} from '@rippling/pebble-sdui-web/catalogs/custom-apps';

const button = getComponent('Button');
const notification = getAction('showNotification');

console.log(button.events);
console.log(button.propsSchema);
console.log(notification.paramsSchema);
```

### Import example

```typescript
// Core logic and state helpers
import { createSpec, equals, truthy } from '@rippling/pebble-sdui-web';

// Components, actions, and render
import {
  Button,
  Text,
  VStack,
  render,
  setState,
} from '@rippling/pebble-sdui-web/catalogs/custom-apps';
```

* * *

## Render the page

`render` flattens your component tree into the JSON structure Rippling renders as a function page. Declare every state path up front—even empty strings, arrays, or `false` toggles—so the runtime can watch them.

```typescript
import { createSpec } from '@rippling/pebble-sdui-web';
import { Text, VStack, render } from '@rippling/pebble-sdui-web/catalogs/custom-apps';

interface AppState {
  title: string;
  todos: string[];
  showSummary: boolean;
}

// ✅ Provide starting values for every path the spec will use
const state: AppState = {
  title: 'Todos',
  todos: [],
  showSummary: false,
};

// ❌ Missing paths break tracking when actions later write to them
// const state: AppState = {};

const { $state } = createSpec<AppState>({ state });

const root = VStack({
  id: 'root',
  children: [
    Text({ props: { text: $state('/title') } }),
  ],
});

export default async function renderTodos() {
  return render({ root, state });
}
```

Return the result of `render({ root, state })` inside your `init` response as `spec: JSON.stringify(spec)`.

* * *

## Component configuration

Every catalog component supports the same structural fields:

```typescript
Component({
  id,
  props,
  visible,
  repeat,
  on,
  children,
});
```

> **Note:**
> Not every component supports all fields. Leaf components such as `Text` do not accept `children`, and only components with defined events accept `on`.

### Style & text (`props`)

Component-specific settings—labels, styles, values.

```typescript
import { Text } from '@rippling/pebble-sdui-web/catalogs/custom-apps';

Text({
  props: {
    text: 'Hello',
    typestyle: 'typestyleBodyMedium',
  },
});
```

### Visibility (`visible`)

Show or hide elements with booleans or logic helpers.

```typescript
import { createSpec, equals, truthy } from '@rippling/pebble-sdui-web';
import { Button, Text } from '@rippling/pebble-sdui-web/catalogs/custom-apps';

interface AppState {
  showAdminTools: boolean;
  user: { role: string; isSignedIn: boolean };
}

const state: AppState = {
  showAdminTools: false,
  user: { role: 'member', isSignedIn: true },
};

const { $state } = createSpec<AppState>({ state });

const signedInMessage = Text({
  visible: truthy($state('/user/isSignedIn')),
  props: { text: 'Signed in' },
});

const adminButton = Button({
  visible: equals($state('/user/role'), 'admin'),
  props: { label: 'Admin action' },
});
```

### Looping (`repeat`)

Render one child template per item in a state array.

```typescript
import { createSpec } from '@rippling/pebble-sdui-web';
import { Text, VStack } from '@rippling/pebble-sdui-web/catalogs/custom-apps';

interface AppState {
  todos: Array<{ id: string; title: string }>;
}

const state: AppState = { todos: [] };
const { repeat } = createSpec<AppState>({ state });
const [todosRepeat, todo] = repeat('/todos', 'id');

const rows = VStack({
  repeat: todosRepeat,
  children: [
    Text({ props: { text: todo.$('title') } }),
  ],
});
```

### Interaction events (`on`)

Wire user actions to catalog actions.

```typescript
import { Button, showNotification } from '@rippling/pebble-sdui-web/catalogs/custom-apps';

Button({
  props: { label: 'Save', appearance: 'PRIMARY' },
  on: {
    press: showNotification({ message: 'Saved', variant: 'success' }),
  },
});
```

### Nesting (`children`)

Nest supported components inside layout containers.

```typescript
import { Button, Text, VStack } from '@rippling/pebble-sdui-web/catalogs/custom-apps';

VStack({
  props: { gap: 'space300' },
  children: [
    Text({ props: { text: 'Title' } }),
    Button({ props: { label: 'Continue' } }),
  ],
});
```

* * *

## Actions

Assign actions on components via `on`. State paths inside actions must be JSON-pointer strings starting with `/`.

> **Note:**
> All `statePath` values must start with `/` (for example `/todos`, not `todos`).

### Available actions

| Action | Required parameters | Optional parameters | Description |
| --- | --- | --- | --- |
| `navigate` | `path` | `openInNewTab` | Navigate to a URL path. Set `openInNewTab` for external links. |
| `openChatAssistantWithMessage` | `text` | `target` | Opens the Rippling AI Chat Assistant in a new conversation and sends `text` immediately. |
| `pushState` | `statePath`, `value` | `clearStatePath` | Append to an array at `statePath`. |
| `removeState` | `statePath`, `index` | None | Remove an array item by index. |
| `setState` | `statePath`, `value` | None | Overwrite a state path. |
| `showNotification` | `message`, `variant` | None | Show a toast notification; it auto-dismisses after seven seconds. |
| `triggerFunction` | `functionApiName`, `inputs.action` | `responsePath`, `onSuccess`, `onError` | Call a Rippling Function; all `inputs` keys are sent as `event.parameters`. |

### Navigation & alerts

```typescript
import {
  Button,
  navigate,
  showNotification,
} from '@rippling/pebble-sdui-web/catalogs/custom-apps';

const openDetails = Button({
  props: { label: 'Open details' },
  on: {
    press: navigate({ path: '/apps/todos/details', openInNewTab: false }),
  },
});

const notify = showNotification({
  message: 'Todo saved',
  variant: 'success',
});
```

### Rippling AI Chat Assistant

`openChatAssistantWithMessage` always opens a new Rippling AI Chat Assistant conversation. Its `text` value must contain at least one non-whitespace character. Use `target` only when you need a specific surface: `sidepane`, `fullscreen`, or `copilot`.

```typescript
import {
  Button,
  openChatAssistantWithMessage,
} from '@rippling/pebble-sdui-web/catalogs/custom-apps';

const askAssistant = Button({
  props: { label: 'Explain this report' },
  on: {
    press: openChatAssistantWithMessage({
      text: 'Summarize the key changes in this report.',
      target: 'sidepane',
    }),
  },
});
```

### Backend interaction

`triggerFunction` invokes your handler with custom `inputs`; `inputs` must include an `action` string. Use `responsePath` to write the response body directly into state. The response body must match that path's state shape (for example, return an array rather than `{ data: array }`).

`onSuccess` and `onError` are client-side handlers. Use the runtime format `{ set: { '/path': value } }`, rather than `actions.set()`.

```typescript
const loadSummary = Button({
  props: { label: 'Load summary' },
  on: {
    press: triggerFunction({
      functionApiName: 'renderTodos',
      inputs: { action: 'loadSummary' },
      responsePath: '/summary',
    }),
  },
});
```

Source: https://developer.rippling.com/documentation/rippling-platform/sdui/reference

> For the complete documentation index, see [llms.txt](https://developer.rippling.com/llms.txt). Public pages have a Markdown version at the same URL with .md added.
