Skip to main content
Version: v1 (Current)

Application UI recipes

Use primitive components for custom layouts, domain components for repeatable interactions, and experience pages for complete steps. Import from @gxp-dev/app-ui and load @gxp-dev/app-ui/styles once. Every public API.

State, collections, and selection​

<script setup lang="ts">
import { computed, ref } from 'vue'
import { CollectionGrid, Input, type CollectionItem } from '@gxp-dev/app-ui'
const query = ref('')
const loading = ref(false)
const error = ref<string | null>(null)
const selected = ref<CollectionItem | null>(null)
const items = ref<CollectionItem[]>([
{ id: 'portrait', title: 'Portrait', description: 'Create a studio portrait.' },
{ id: 'poster', title: 'Poster', description: 'Create an event poster.' },
])
const selectedTitle = computed(() => selected.value?.title ?? 'None')
// Replace this demo loader with your platform query and normalize its response.
async function reload() {
loading.value = true
error.value = null
try { items.value = await Promise.resolve([...items.value]) }
catch (cause) { error.value = cause instanceof Error ? cause.message : String(cause) }
finally { loading.value = false }
}
</script>
<template>
<label for="collection-search">Search collections</label>
<Input id="collection-search" v-model="query" type="search" />
<CollectionGrid :items="items" :query="query" :loading="loading" :error="error"
@select="selected = $event" @retry="reload" />
<p role="status">Selected: {{ selectedTitle }}</p>
</template>

CollectionItem requires a unique id and title; optional description, image, imageAlt, disabled, and data preserve your normalized display/data payload. Image alt defaults to empty because the adjacent heading names the card. Supply meaningful alt when the image conveys additional information.

CollectionGrid filters locally. It emits the full item and never fetches or mutates a platform resource. For arbitrary asynchronous content use AsyncState, which prioritizes loading, then error, then empty, then its default slot. Override loading, error, and empty slots when your app needs a different presentation. EmptyState is also usable independently.

Sortable tables​

<script setup lang="ts">
import { DataTable, Badge, type DataTableColumn } from '@gxp-dev/app-ui'
const columns: DataTableColumn[] = [
{ key: 'name', label: 'Participant', sortable: true },
{ key: 'score', label: 'Score', sortable: true },
{ key: 'status', label: 'Status' },
]
const rows = [
{ id: 1, name: 'Morgan', score: 25, status: 'Checked in' },
{ id: 2, name: 'Alex', score: 8, status: 'Registered' },
]
</script>
<template>
<DataTable :columns="columns" :rows="rows" :page-size="10" caption="Event participants">
<template #cell-status="{ value }"><Badge>{{ value }}</Badge></template>
</DataTable>
</template>

query searches visible columns. Sorting is numeric for numbers and natural string order otherwise; each sortable header reports aria-sort. Pagination/search/sort operate on the supplied local rows and do not make requests. Give each row a unique field named by rowKey (default id). For large server-paginated resources, compose the lower-level Table and Pagination primitives and fetch the appropriate slice yourself.

Schema forms​

FormPage and RegistrationPage are lightweight flow pages with native validation and simple conditional fields. For a larger schema or richer field types, use FormRenderer and FormElementDef:

<script setup lang="ts">
import { ref } from 'vue'
import { FormRenderer, type FormSectionDef } from '@gxp-dev/app-ui'
const submitted = ref<Record<string, unknown> | null>(null)
const sections: FormSectionDef[] = [{
id: 'profile', title: 'Your details',
elements: [
{ type: 'text', name: 'name', label: 'Name', required: true },
{ type: 'email', name: 'email', label: 'Email', required: true },
{ type: 'checkbox', name: 'optIn', label: 'Send me event updates' },
],
}]
</script>
<template>
<FormRenderer :sections="sections" layout="cards" @submit="submitted = $event" />
<pre v-if="submitted">{{ submitted }}</pre>
</template>

Layouts include stack, cards, tabs, accordion, and stepper. Conditional fields and sections use when(values); hidden elements are removed from the submit payload. Use #element-{name} slots for custom controls and the exposed form methods for validate/reset/setFieldValue. See the schema form reference.

Quiz and survey answers​

<script setup lang="ts">
import { ref } from 'vue'
import { QuestionCard } from '@gxp-dev/app-ui'
const interests = ref<string[]>([])
const feedback = ref('')
const options = [
{ value: 'design', label: 'Design' },
{ value: 'engineering', label: 'Engineering' },
]
function previewAnswer(answer: string | string[]) {
feedback.value = `Local preview: ${Array.isArray(answer) ? answer.join(', ') : answer}`
}
</script>
<template>
<QuestionCard v-model="interests" multiple title="What interests you?"
:options="options" :feedback="feedback" @answer="previewAnswer" />
</template>

This example previews the selection locally; it does not save a survey response, start a quiz attempt or score an answer. The model is a string for single choice and string array for multiple choice. Required questions reject empty, stale, or disabled choice values. answer fires only on explicit submission. Supply confirmed feedback/disabled state after your API evaluates or saves an answer; scoring and correct-answer rules belong to that service. useQuestion is available for custom question components, with question text, hints, correctness feedback and option normalization.

Attendee credentials and check-in​

<AttendeeBadge name="Morgan Lee" subtitle="Demo participant" credential="demo-ticket-42" />

AttendeeBadge displays identity; QrCode generates its QR image locally. Supply your service's appropriate credential value. It is presentation only: check-in authorization and attendance changes happen in the app/service. ScanPage wraps BarcodeScanner with a manual-code fallback. BarcodeScanner starts on explicit request by default and requires secure-context camera permission. useNfcListener handles supported NFC input; PinPad and OnScreenKeyboard provide kiosk entry alternatives.

File selection and media capture​

<FileUploader :accept-images="true" :accept-videos="false" :accept-audio="false"
:max-file-size="10 * 1024 * 1024" @file-selected="handleFile" @upload-error="showError" />

maxFileSize limits original bytes before processing (0 is unlimited). Watch useMedia().recordingError to surface asynchronous recorder/export failures in custom capture UIs. The built-in capture pages emit these errors to ExperienceFlow.

Image processing can re-encode; the emitted FileSelectedPayload contains original file, processed blob, media type, processed size, name, and mimeType. The native picker accept filter is backed by runtime validation. Selecting the same file again works. Multiple mode emits once per selected valid file. Set dropzone to add drag/drop alongside the accessible picker button. disabled prevents both selection paths. File selection does not upload data.

Capture pages use useMedia for camera/microphone acquisition and recording. Use HTTPS/localhost and grant device permissions in the embedding host. Your app owns user consent, upload, and any service-specific metadata. SignaturePad emits a data URL and exposes clear/isEmpty/toDataURL; its canvas colors resolve CSS variables before drawing. App theme changes affect new strokes, not existing pixels.

<PrintJobStatus :status="job.status" :job-id="job.id" :busy="changingJob"
can-cancel @retry="retryPrint" @cancel="cancelPrint" />

PrintJobState is pending, printing, completed, failed, or cancelled. Normalize backend states before passing them in. Retry appears only for failed jobs; cancellation appears only for active jobs with canCancel. The host creates jobs, subscribes/polls, and performs cancellation/retry. PrintStatusPage supplies a complete flow step; useExperienceApi.createPrintJob is the optional named API operation for job creation.

Chat and live session composition​

The chat primitives cover transcript/list rendering, message composition, participant rows, local preview, video tiles/grid, media controls and connection status. Use useChatMessages to manage message/history state through its injected API, useChatMedia for live tracks, useWebSocket for connection/reconnection, and useStreamingAudio for buffered audio playback. They do not establish an authenticated platform session automatically. Read their typed helper options and methods and Storybook demos before connecting the platform's session/realtime services.

Date intervals​

Compose two DatePicker controls when an app needs a reporting or event interval. Their models are DateValue objects from @internationalized/date, not ISO strings. Use toString() when normalizing the values for your API.

<script setup lang="ts">
import { ref } from 'vue'
import type { DateValue } from '@internationalized/date'
import { DatePicker } from '@gxp-dev/app-ui'
const start = ref<DateValue>()
const end = ref<DateValue>()
</script>
<template>
<div class="grid gap-4 sm:grid-cols-2">
<div><p>Start date</p><DatePicker v-model="start" placeholder="Choose start date" /></div>
<div><p>End date</p><DatePicker v-model="end" :min-value="start" placeholder="Choose end date" /></div>
</div>
</template>

For custom calendar anatomy, Calendar's default scoped slot supplies grid and weekDays; compose its public CalendarHeader/Grid/Cell controls as shown in Storybook's CalendarParts example. Calendar supports single/multiple selection. Date intervals use separate values and your service's validation.