open-form create
Create a new form from the starter at forms/<id>/index.tsx, with its own empty theme/index.ts, and print its preview path.
npx open-form create event-registration
npx open-form create event-registration --title "Event Registration"
npx open-form create event-registration --locale zh-TWWrites forms/<id>/index.tsx with a small starter form and
forms/<id>/theme/index.ts, the form's own look, and prints its preview path,
/f/<id>. The look file starts empty, which is the plain base look; your
agent then writes the form's tokens, CSS and components there, from a reference
theme in themes/ or designed for the form. See
Themes.
The id must be kebab-case: lowercase letters, digits and -. It becomes the
folder name and the public URL. create stops if forms/<id> already exists.
Flags
| Flag | Default | Description |
|---|---|---|
-t, --title <title> | the id in title case | The form's title in defineForm(). |
--locale <locale> | the project's locale | The language the form is written in, set as locale in defineForm(): en, zh-TW, zh-CN or ja. |
The starter
The starter's description, labels and button are written in the form's
language: --locale, else the project's locale, else English. With
--locale zh-TW the fields read 姓名, 電子郵件 and 留言, and the button 送出.
import { defineForm, Email, Form, Submit, Text, Textarea } from '@open-form-build/core';
import theme from './theme/index.ts';
export const config = defineForm({
title: 'Event Registration',
description: 'Tell us a little about yourself.',
});
export default function EventRegistrationForm() {
return (
<Form theme={theme}>
<Text name="name" label="Name" required autoComplete="name" />
<Email name="email" label="Email" required />
<Textarea name="message" label="Message" maxLength={2000} />
<Submit>Send</Submit>
</Form>
);
}import { defineTheme } from '@open-form-build/core';
export default defineTheme({});The component is named after the id with Form at the end (contact-form
becomes ContactForm), so it never collides with a component it imports, such
as Form or Email, or with a global like Date. A default export named like
an Open Form component would render itself, so check, dev and build stop
with an error asking for another name.
Replace the body with your own questions, or let your agent take it from here.
Agents following /create-form can scaffold with
create or write the files directly.