Documentation · UI Designer

Integrate the designer into your Vue app.

This guide follows the UI Designer README for version 0.2.1. Use the editor for authoring, or render saved templates in your own application.

01 · Install

Install the package and its peer dependencies.

The editor requires Vue 3 and Pinia. Import the stylesheet once in your application entry point; it includes the editor styles and bundled Material Symbols font, with no Google Fonts request.

bash
npm install @aham.ro/ui-designer@0.2.1 vue pinia
javascript
import '@aham.ro/ui-designer/style.css'

02 · Quick start

Mount the editor and handle saves.

This version-matched example mounts Designer into an existing #app element, restores a saved workspace from local storage, and saves changes when requested.

javascript
import { createPinia } from 'pinia'
import { createApp, h } from 'vue'
import { Designer } from '@aham.ro/ui-designer'
import '@aham.ro/ui-designer/style.css'

const storageKey = 'ui-designer-demo'
const template = { id: 'login', name: 'Login', icon: 'login', channel: 'ui', version: '1', changed: false }
const options = {
  subject: 'Authentication',
  templates: [template],
  value: JSON.parse(localStorage.getItem(storageKey) || 'null') || undefined,
}

createApp({
  render: () => h(Designer, {
    options,
    onSave: (workspace, done, _html, fail) => {
      try { localStorage.setItem(storageKey, JSON.stringify(workspace)); done() }
      catch (error) { if (fail) fail(error); else console.error('Save failed.', error) }
    },
  }),
})
  .use(createPinia())
  .mount('#app')

Use a unique storage key per editor or workspace. This example stores WorkspaceData directly; production apps will usually load and save it through their own API.

The editor applies a defensive CSS reset inside its root, but it does not use Shadow DOM. Highly specific host-page selectors and !important rules can still override editor styles. Canvas zoom is persisted in local storage as aham-ui-designer-zoom; use Reset size to restore the default for the current device.

03 · Configure

Provide templates and editor options.

Designer expects an options object with a subject and at least one template. Templates require id, name, icon, channel, version, and changed. Use ui for interactive screens and email for email templates.

typescript
import type { Options, Template } from '@aham.ro/ui-designer'

const templates: Template[] = [
  {
    id: 'login',
    name: 'Login',
    description: 'Sign in with an email address and password.',
    icon: 'login',
    channel: 'ui',
    version: '1',
    changed: false,
    hasDraft: true,
    draftVersionId: 'login-draft-1',
    requiredComponents: ['emailInput', 'passwordInput', 'submitButton'],
    type: 'predefined',
  },
]

const options: Options = {
  subject: 'Authentication',
  templates,
  value: undefined,
  theme: { mode: 'default', darkModeChangeable: true },
  size: 'medium',
  warnBeforeUnload: true,
}

Designer props

optionsOptionsTemplates, workspace value, theme, and editor configuration.
debugbooleanEnables workspace debugging details.
currentTemplatestringSelects the active template by ID.
device'phone' | 'tablet' | 'desktop'Sets the active device view.
publishedTemplateIdsstring[]Marks the listed template IDs as published.

Options

subjectstringName shown in the editor header and workspace.
templatesTemplate[]Templates available in the editor.
valueWorkspaceDataInitial saved workspace to restore.
theme.mode'custom' | 'default'Selects the editor theme mode.
theme.darkModeChangeablebooleanAllows users to switch the editor theme.
size'small' | 'medium' | 'large'Editor sizing option.
sharedbooleanShows that the current workspace is shared.
warnBeforeUnloadbooleanWarns before leaving with unsaved changes; enabled by default.
moreItemsMoreMenuItem[]Adds application-specific actions to the editor menu.
linksRecord<string, string>Resolves template/link names used by components.
identityProvidersOAuthProviderDefinition[]Configures identity-provider components.

Optional template metadata includes description, variables, requiredComponents, type, and draft fields such as hasDraft and draftVersionId. When identityProviders is configured, the palette offers a combined Identity Providers component and individual provider buttons in the configured order.

04 · Save and publish

Your application owns persistence.

Persist the workspace before calling the save success callback. For email templates, the event can also include a rendered HTML snapshot. Call the optional failure callback when persistence fails so the editor can report the error and leave its saving state.

typescript
function saveWorkspace(
  workspace: WorkspaceData,
  done: (versionId?: string) => void,
  htmlSnapshot?: string,
  fail?: (cause: unknown) => void,
) {
  saveToApi(workspace, htmlSnapshot)
    .then(({ versionId }) => done(versionId))
    .catch((cause: unknown) => fail?.(cause))
}

To enable publishing, set hasDraft: true and provide a draftVersionId. The publish event includes the template ID, draft version ID, and success/error callbacks. Publishing is disabled until a draft exists and its required-component checklist is complete.

05 · Events

Connect editor events to your application.

save(workspace, done, htmlSnapshot?, fail?)
publish(templateId, versionId, done, fail?)
template-select(template)
template-add(template)
template-rename(templateId, name)
translation-update(fieldId, value, language)
theme-update(color)
device-change(device)
component-drop(componentType)
template-info(templateId, templateName)
dirty-change(dirty)
notify(message, theme?) — info, success, warning, or danger
more-select(itemId)
readyNo payload

06 · Build a custom template UI

Render saved templates outside the editor.

Import Renderer for a Vue layout or use the standalone render helper to render into an existing DOM target. Template data contains its components and may also include document props, theme, translations, and reusable templates. Set form: false to disable form submission handling.

javascript
import { render } from '@aham.ro/ui-designer'

render(templateData, '#template-preview', {
  links: { Login: '/login' },
  form: {
    submit: (payload) => {
      console.log('Submitted template data:', payload)
    },
  },
})

The package exports UI components including Alert, Container, Document, EmailInput, Heading, IdentityProviders, Layout, LayoutRef, OtpInput, PasswordInput, SubmitButton, Text, TextInput, TextLink, WebAuthn. It also exports workspace data and device types, theme/translation/workspace stores, and withProperties for defining editable component properties. The standalone app is available from @aham.ro/ui-designer/demo; the Demo component can also be mounted by a host-managed Vue app.

07 · WebAuthn

Connect passkey authentication to your server.

Provide webAuthn in Designer options or preview render options. Your server must issue fresh request options for each login attempt. Convert its base64url challenge and credential IDs to browser-ready ArrayBuffer values; send the resulting credential assertion back to your server for verification.

javascript
const webAuthn = {
  async getRequestOptions() {
    const response = await fetch('/webauthn/login/options', { method: 'POST' })
    if (!response.ok) throw new Error('Could not start passkey login.')
    return toPublicKeyCredentialRequestOptions(await response.json())
  },
  async verifyCredential(credential) {
    await submitPasskeyAssertion(credential)
  },
}

const options = {
  subject: 'Sign in',
  templates,
  webAuthn,
}

The WebAuthn button is disabled unless both getRequestOptions and verifyCredential callbacks are provided.

08 · Development

Run the package demo locally.

bash
npm install
npm run dev
npm run build

src/demo.js is the minimal JavaScript integration example. The development app mounts src/Demo.vue with dev: true to show its toolbar. The toolbar is hidden by default with <Demo />; enable it with <Demo :dev="true" />. The standalone demo stores its workspace, draft/publish state, and email snapshots under aham-ui-designer:standalone-workspace.

09 · License and contributing

Review the project and third-party notices.

UI Designer is available under the MIT License. The bundled Material Symbols font is separately licensed under Apache-2.0. See the MIT license, third-party notices and project issues.