OpenUI Lang: Allow registered formatting functions

Open
#390 0 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@Aditya-thesys is already working on this.

Since Mar 25, 2026.

Assessment

This issue has not been assessed yet.

Description

enhancement

Is your feature request related to a problem? Please describe.
OpenUI Lang can render structured UI from model output, but there is not a clear way for host applications to expose safe, reusable functions that generated UI can call when displaying values.

Many apps need formatting or transformation logic that should live in application code, not in model output. Examples include formatCurrency, formatDate, formatPercent, formatFileSize, formatDuration, formatStatus, and getDisplayName.

Without first-class support for registered functions, developers either need to pre-format all values before passing them to OpenUI, create one-off components for simple display logic, or let the model decide raw formatting. That makes generated UI less reusable and can lead to inconsistent formatting across an app.

Describe the solution you'd like
Add support for user-defined, host-registered functions in OpenUI Lang.

The model should be able to reference named functions that the host application explicitly registers, without emitting arbitrary executable code.

Ideally, this should support:

  • Registering named functions in the renderer/runtime.
  • Calling those functions from OpenUI Lang expressions or component props.
  • Passing arguments from state, query results, literals, or other expressions.
  • Synchronous formatting functions for common display transforms.
  • Type/schema metadata so prompts can describe available functions to the model.
  • Clear error handling when a function is missing or receives invalid arguments.
  • React support first, with the core behavior living in @openuidev/lang-core where possible.
  • Documentation and examples for common formatters such as currency, dates, and percentages.

Describe alternatives you've considered

  • Pre-format values before passing data into OpenUI.
  • Add more built-in formatting helpers to OpenUI Lang.
  • Create custom components for each formatting need.
  • Allow arbitrary JavaScript expressions in generated output.

These alternatives either duplicate logic, do not cover app-specific formatting needs, or introduce safety concerns.

Additional context
The key constraint is safety. The model should only be able to call functions that the host application has registered and described. It should not be able to emit arbitrary JavaScript or access runtime globals.

This would make OpenUI Lang more useful for dashboards, reports, financial UI, analytics views, and any generated UI that needs consistent app-specific display formatting.

Dominant language
TypeScript
Stars
10k
Forks
698
Avg merge
1d 3h
Merged PRs (30d)
133

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from thesysdev/openui

All issues in thesysdev/openui

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.