@letar/forms

ReadOnly View

Display form data in a read-only format using the same Zod schema

Overview

Form.ReadOnlyView renders form data as a read-only display, extracting labels from your Zod schema's .meta({ ui: { title } }). No form context needed — just data and schema.

import { Form } from '@letar/forms'

;<Form.ReadOnlyView data={{ name: 'John Doe', email: 'john@example.com', role: 'admin' }} schema={UserSchema} />

Props

PropTypeDefaultDescription
dataRecord<string, unknown>requiredData to display
schemaZodObjectrequiredSchema for labels via .meta()
compactbooleanfalseCompact layout (single line per field)
excludestring[][]Fields to hide
labelsRecord<string, string>{}Manual label overrides

Compact Mode

<Form.ReadOnlyView data={user} schema={UserSchema} compact />

Standard mode shows label above value. Compact mode shows label and value on the same line.

Use Cases

  • Profile page: Display user profile without edit capability
  • Confirmation step: Show submitted data before final confirmation
  • Print view: Clean data display for printing
  • Detail pages: Show record details in admin panels

Live Example

Try the interactive example on forms-example.letar.best.

On this page