@hanzo/ui

Workbench

import { A2UIWorkbench } from '@hanzo/ui/a2ui'

Live Review, Edit & Codegen

Preview the surface, edit JSONL live, and copy or save compiled @hanzo/ui TSX.

ClusterScale
1 surface · 5 nodes
Scale Workload
Edit JSON or inspect compiled @hanzo/ui TSX across tabs.
3
// Trigger an action button to inspect the scoped { surfaceId, name, context } event.
// Undeclared dataModel keys stay private in the browser.
Local dataModel keys: cluster, replicas, autoscale, kubeSecret
export function Default() {
  const [savedLen, setSavedLen] = useState<number | null>(null)
  return (
    <YStack width="100%" gap="$2">
      <A2UIWorkbench
        title="ClusterScale"
        initialPayload={PAYLOAD}
        onSave={(_, tsx) => setSavedLen(tsx.length)}
      />
      {savedLen !== null ? (
        <Text fontFamily="$mono" fontSize="$2" color="$color11">
          Saved compiled TSX ({savedLen} chars)
        </Text>
      ) : null}
    </YStack>
  )
}

Types

export type A2UIWorkbenchTab = 'preview' | 'json' | 'tsx'
export interface A2UIWorkbenchProps {
  /** Initial A2UI 1.0 JSON/JSONL payload. */
  initialPayload: string
  /** Optional header title (e.g. surface or preset name). */
  title?: string
  /** Zero-trust action callback fired when a button inside the surface triggers an event. */
  onAction?: (event: A2UIActionEvent) => void
  /** Optional save callback receiving the current A2UI JSON and compiled `@hanzo/ui` TSX. */
  onSave?: (payload: string, tsx: string) => void
  /** Optional callback fired whenever the editable JSON payload changes. */
  onChange?: (payload: string) => void
  /** Optional custom or override catalog components merged on top of `defaultA2UICatalog`. */
  catalog?: Partial<A2UICatalog>
  /** Disable editing and surface controls. */
  readOnly?: boolean
  /** Initial active tab (defaults to `'preview'`). */
  defaultTab?: A2UIWorkbenchTab
  /** Optional CSS class on the outer container. */
  className?: string
  /** Optional inline styles on the outer container. */
  style?: CSSProperties
}

Exports

A2UIWorkbenchtype A2UIWorkbenchPropstype A2UIWorkbenchTab