Skip to content
Playground

Quick Start

Try a project form, copy its code, and adapt it to your app.

Build a project form with a name, region, notes, and a submit button. This example shows a confirmation message in the browser; it does not save to a server.

First, complete Installation. You should already be able to render a styled Zenos button.

Try it, copy it, make it yours

One working form takes you through the basics.

  1. Try the preview
    In this guide

    Enter a name → submit → see confirmation

    Test the form below before changing anything.

  2. Copy the code
    In your editor

    Code tab → ProjectForm.tsx → your page

    Use the same source that powers the preview.

  3. Connect your app
    Your next step

    Your fields + validation + save action

    The demo confirms locally. Your app decides how to save real data.

Enter a project name, choose a region, and select Create project. You should see “Project created locally.” without a page reload.

Use a name your team will recognize.

The name is required. Try submitting with it empty, then use Tab and the arrow keys to move through the form and select a region.

Open Code in the preview and copy the example into a component file, such as src/ProjectForm.tsx. The displayed code comes from the same source as the working preview.

Add this line at the end of the copied file so another file can import it:

TSX
export default FormExample;

Then render it from your page. For a Vite app, your src/App.tsx could be:

src/App.tsx
import ProjectForm from "./ProjectForm"; export default function App() {  return <ProjectForm />;}

In Next.js, add "use client" at the top of the form file because it uses React state. In Astro, render the form with client:load. The framework setup examples show where styles and client boundaries belong.

Start with the labels, placeholders, and region choices. Then replace the example’s setCreated(true) with your app’s save operation, including loading and error states.

The form is built from a few pieces:

  • FormLayout arranges the fields in one column, then two from the md breakpoint.
  • Field connects a label, input, description, and any error message.
  • Input, Select, and Textarea let people enter and choose values.
  • Button submits the form. Text announces the local confirmation.
How does a label connect to an input?

Keep the control inside its Field.Root. Field.Control passes the field’s ID, required state, and accessible relationships to the Input through render:

TSX
<Field.Root required>  <Field.Label>Project name</Field.Label>  <Field.Control render={<Input name="projectName" />} />  <Field.Description>Use a name your team will recognize.</Field.Description></Field.Root>

Add your application’s validation rules when connecting a real save operation. Use invalid and Field.Error to display an error that explains how to fix the value. See Field for the full API.

How do I change the columns or spacing?

Change the layout props on the form:

TSX
<FormLayout as="form" columns={{ base: 1, md: 2 }} gap="4">  {/* Fields and actions */}</FormLayout>

base: 1 means one column on smaller screens. md: 2 means two columns from the medium breakpoint. gap="4" uses the spacing scale.

The preview also uses a few Tailwind classes for width, alignment, and the Notes field’s span. If your app does not use Tailwind, replace those classes with your own CSS. Zenos components and responsive layout props work with the package stylesheet alone.

See FormLayout and Layout composition for more layouts.

When should my app manage a field’s value?

The example’s Select uses defaultValue="singapore", so it manages the selected region itself. Use value with onValueChange when your app needs to read, reset, or coordinate that selection. See the controlled Select example.

Native inputs such as Input use their normal React props, including value and onChange. Keep your save logic and validation in your form or feature code.

Before connecting real data:

  1. Submit a filled form and confirm it updates without reloading the page.
  2. Use only the keyboard to enter values, choose a region, and submit.
  3. Resize the page and check that fields remain readable and in the right order.
  4. Check both themes if your app supports dark mode.
  5. Run your app’s tests, type check, and production build.

Next, try Dialog for an edit flow, AppShell for a full page, or Working with AI to give your assistant the Zenos context.