Skip to content

Commit 2166f2f

Browse files
authored
docs: polish root README and add per-package READMEs (#18)
* docs: polish root README and add per-package READMEs * docs: mention /formhaus-create-form and /formhaus-figma-connect skills
1 parent 69743cc commit 2166f2f

5 files changed

Lines changed: 262 additions & 7 deletions

File tree

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
[![bundlephobia](https://img.shields.io/bundlephobia/minzip/@formhaus/core?label=core%20size)](https://bundlephobia.com/package/@formhaus/core)
77
[![license](https://img.shields.io/github/license/ignsm/formhaus)](LICENSE)
88

9-
Framework-agnostic form engine with its own compact JSON-based definition format.
10-
Define a form once fields, validation, conditions, stepsin a single file. Render it in React, Vue, Figma, or any framework via the core engine. No JSON Schema spec, no separate UI schema, no boilerplate.
9+
Framework-agnostic form engine with a compact JSON definition format.
10+
Define a form once (fields, validation, conditions, steps) in a single file. Render it in React, Vue, Figma, or anything via the core engine. No JSON Schema spec, no separate UI schema, no boilerplate.
1111

1212
## Packages
1313

@@ -17,9 +17,9 @@ Define a form once — fields, validation, conditions, steps — in a single fil
1717
| `@formhaus/react` | React adapter with native HTML defaults and custom component support | `npm i @formhaus/react` |
1818
| `@formhaus/vue` | Vue 3 adapter with native HTML defaults and custom component support | `npm i @formhaus/vue` |
1919

20-
There is also a Figma plugin (`@formhaus/figma`) that generates form mockups from form definitions. Available via `manifest.json` for now.
20+
`@formhaus/figma` generates form mockups on the Figma canvas from a form definition. Not on Figma Community yet, install as a local plugin via `packages/figma/manifest.json`.
2121

22-
Svelte, Solid, or anything else: use `@formhaus/core` directly. See the [playground](https://formhaus.dev/playground) for an example.
22+
Svelte, Solid, or anything else: use `@formhaus/core` directly. The [playground](https://formhaus.dev/playground.html) has a Svelte example.
2323

2424
## Install
2525

@@ -34,13 +34,13 @@ npm install @formhaus/react # React
3434
npm install @formhaus/vue # Vue
3535
```
3636

37-
Or use `@formhaus/core` directly with any framework. See the [Svelte example in the playground](/playground).
37+
Or use `@formhaus/core` directly with any framework. See the [Svelte example](https://formhaus.dev/playground.html).
3838

3939
## Quick Start
4040

4141
### Define a form
4242

43-
You can write the JSON by hand or use the [Claude skill](.claude/skills/formhaus-create-form/SKILL.md) to generate it from a text description.
43+
Write the JSON by hand, or use the [`/formhaus-create-form`](https://formhaus.dev/guide/formhaus-create-form.html) Claude Code skill to generate it from a text description, a CSV table, or a screenshot of an existing form.
4444

4545
```json
4646
{
@@ -191,7 +191,7 @@ Each field component receives the full `FormField` descriptor, the current value
191191

192192
## Figma Plugin
193193

194-
`@formhaus/figma` is a Figma plugin that takes a formhaus form definition and generates a styled form mockup directly on the canvas. Useful for rapid prototyping and design handoff.
194+
`@formhaus/figma` generates styled form mockups on the Figma canvas from a form definition. Map your design system components to field types via a `componentMap` that the [`/formhaus-figma-connect`](https://formhaus.dev/guide/formhaus-figma-connect.html) Claude Code skill can generate for you by scanning your Figma file. Not on Figma Community yet, install as a local plugin via `packages/figma/manifest.json`.
195195

196196
## Contributing
197197

packages/core/README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# @formhaus/core
2+
3+
Framework-agnostic form engine. Types, validation, visibility, multi-step navigation, async step validation. Zero runtime dependencies, ESM-only.
4+
5+
Part of [Formhaus](https://github.com/ignsm/formhaus). For React, use `@formhaus/react`. For Vue, use `@formhaus/vue`.
6+
7+
## Install
8+
9+
```bash
10+
npm install @formhaus/core
11+
```
12+
13+
Requires Node ≥18.
14+
15+
## Generating a definition
16+
17+
Write the JSON by hand, or use the [`/formhaus-create-form`](https://formhaus.dev/guide/formhaus-create-form.html) Claude Code skill to generate it from a text description, a CSV table, or a screenshot of an existing form.
18+
19+
## Usage
20+
21+
```ts
22+
import { FormEngine, type FormDefinition } from '@formhaus/core';
23+
24+
const definition: FormDefinition = {
25+
id: 'contact',
26+
title: 'Contact Us',
27+
submit: { label: 'Send' },
28+
fields: [
29+
{ key: 'name', type: 'text', label: 'Name', validation: { required: true } },
30+
{ key: 'email', type: 'email', label: 'Email', validation: { required: true } },
31+
],
32+
};
33+
34+
const engine = new FormEngine(definition);
35+
36+
engine.setValue('name', 'Jane');
37+
const errors = engine.validate();
38+
// { email: 'This field is required' }
39+
40+
engine.setValue('email', 'jane@example.com');
41+
engine.validate();
42+
// {}
43+
44+
engine.getSubmitValues();
45+
// { name: 'Jane', email: 'jane@example.com' }
46+
```
47+
48+
## What it covers
49+
50+
- Form state with reactive `subscribe()` / `getSnapshot()` for adapters
51+
- Field validation (required, min/max, pattern, matchField, custom validators)
52+
- Visibility conditions (`show` / `showAny`) with cascade-clearing of hidden values
53+
- Multi-step forms with conditional steps and per-step validation
54+
- Async step validation via `onStepValidate` + `nextStepAsync()`
55+
- Definition validation (duplicate keys, invalid regex, circular show conditions)
56+
57+
## Docs
58+
59+
- Full guide and API reference: https://formhaus.dev
60+
- Live playground: https://formhaus.dev/playground.html
61+
- Source and issues: https://github.com/ignsm/formhaus
62+
63+
## License
64+
65+
MIT

packages/figma/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# @formhaus/figma
2+
3+
Figma plugin that generates styled form mockups on the canvas from a [Formhaus](https://github.com/ignsm/formhaus) form definition. Maps your design system components to field types via a `componentMap`.
4+
5+
Not published to the Figma Community yet. Install as a local plugin.
6+
7+
## Install (local plugin)
8+
9+
1. Clone the repo: `git clone https://github.com/ignsm/formhaus.git`
10+
2. Build the plugin: `cd formhaus && pnpm install && pnpm --filter @formhaus/figma build`
11+
3. In Figma desktop: **Plugins → Development → Import plugin from manifest...**
12+
4. Pick `packages/figma/manifest.json`
13+
14+
## Usage
15+
16+
1. Open a Figma file
17+
2. **Plugins → Development → Formhaus**
18+
3. Paste a Formhaus form definition JSON into the plugin UI
19+
4. Click **Generate**
20+
21+
The plugin creates a frame per step with all fields rendered as instances of your mapped design system components. Buttons, step counters, and layout are set up automatically.
22+
23+
## Component map
24+
25+
The plugin ships with a default component map. To make it use your own design system, you need a JSON that maps each form field type (`text`, `select`, `checkbox`, etc.) to a Figma component key in your library.
26+
27+
Writing that map by hand means digging through the Figma API for component keys. Instead, use the **[`/formhaus-figma-connect`](https://formhaus.dev/guide/formhaus-figma-connect.html) Claude skill**: it scans your Figma design system via MCP, auto-detects form components, shows screenshots for confirmation, and generates the full `componentMap` JSON. Copy the output, open the plugin's **Component Map** tab, paste, save. The plugin remembers the map across runs.
28+
29+
If you don't use Claude Code, the full `ComponentMap` TypeScript interface lives in [`packages/figma/src/constants.ts`](https://github.com/ignsm/formhaus/blob/main/packages/figma/src/constants.ts). Paste a JSON that conforms to it.
30+
31+
## Docs
32+
33+
- Full Formhaus guide: https://formhaus.dev
34+
- Plugin guide: https://formhaus.dev/guide/figma.html
35+
- Source and issues: https://github.com/ignsm/formhaus
36+
37+
## License
38+
39+
MIT

packages/react/README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# @formhaus/react
2+
3+
React adapter for [Formhaus](https://github.com/ignsm/formhaus). Renders forms from a JSON definition with native HTML inputs by default. Drop in your own components via a `components` prop.
4+
5+
## Install
6+
7+
```bash
8+
npm install @formhaus/core @formhaus/react
9+
```
10+
11+
Requires React ≥18 and Node ≥18.
12+
13+
## Generating a definition
14+
15+
Write the form JSON by hand, or use the [`/formhaus-create-form`](https://formhaus.dev/guide/formhaus-create-form.html) Claude Code skill to generate it from a text description, a CSV table, or a screenshot of an existing form.
16+
17+
## Usage
18+
19+
```tsx
20+
import { FormRenderer } from '@formhaus/react';
21+
import definition from './contact-form.json';
22+
23+
export function ContactPage() {
24+
async function handleSubmit(values: Record<string, unknown>) {
25+
await fetch('/api/contact', {
26+
method: 'POST',
27+
body: JSON.stringify(values),
28+
});
29+
}
30+
31+
return <FormRenderer definition={definition} onSubmit={handleSubmit} />;
32+
}
33+
```
34+
35+
## Custom components
36+
37+
Swap native HTML for your own UI kit:
38+
39+
```tsx
40+
import type { FieldComponentMap, FieldComponentProps } from '@formhaus/react';
41+
42+
function MyInput({ field, value, error, onChange, onBlur }: FieldComponentProps) {
43+
return (
44+
<div>
45+
<label>{field.label}</label>
46+
<input
47+
value={value as string}
48+
onChange={(e) => onChange(e.target.value)}
49+
onBlur={onBlur}
50+
/>
51+
{error && <span className="error">{error}</span>}
52+
</div>
53+
);
54+
}
55+
56+
const components: FieldComponentMap = { text: MyInput, email: MyInput };
57+
58+
<FormRenderer definition={definition} onSubmit={handleSubmit} components={components} />;
59+
```
60+
61+
Unmapped field types fall back to native HTML.
62+
63+
## Docs
64+
65+
- Full guide and API reference: https://formhaus.dev
66+
- Live playground: https://formhaus.dev/playground.html
67+
- Source and issues: https://github.com/ignsm/formhaus
68+
69+
## License
70+
71+
MIT

packages/vue/README.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# @formhaus/vue
2+
3+
Vue 3 adapter for [Formhaus](https://github.com/ignsm/formhaus). Renders forms from a JSON definition with native HTML inputs by default. Drop in your own components via a `components` prop.
4+
5+
## Install
6+
7+
```bash
8+
npm install @formhaus/core @formhaus/vue
9+
```
10+
11+
Requires Vue ≥3.3 and Node ≥18.
12+
13+
## Generating a definition
14+
15+
Write the form JSON by hand, or use the [`/formhaus-create-form`](https://formhaus.dev/guide/formhaus-create-form.html) Claude Code skill to generate it from a text description, a CSV table, or a screenshot of an existing form.
16+
17+
## Usage
18+
19+
```vue
20+
<script setup lang="ts">
21+
import { FormRenderer } from '@formhaus/vue';
22+
import definition from './contact-form.json';
23+
24+
async function handleSubmit(values: Record<string, unknown>) {
25+
await fetch('/api/contact', {
26+
method: 'POST',
27+
body: JSON.stringify(values),
28+
});
29+
}
30+
</script>
31+
32+
<template>
33+
<FormRenderer :definition="definition" @submit="handleSubmit" />
34+
</template>
35+
```
36+
37+
## Custom components
38+
39+
Swap native HTML for your own UI kit:
40+
41+
```vue
42+
<!-- MyInput.vue -->
43+
<script setup lang="ts">
44+
import type { FormFieldProps } from '@formhaus/vue';
45+
46+
defineProps<FormFieldProps>();
47+
defineEmits<{ (e: 'update:value', value: unknown): void }>();
48+
</script>
49+
50+
<template>
51+
<div>
52+
<label>{{ field.label }}</label>
53+
<input
54+
:value="value"
55+
@input="$emit('update:value', ($event.target as HTMLInputElement).value)"
56+
/>
57+
<span v-if="error">{{ error }}</span>
58+
</div>
59+
</template>
60+
```
61+
62+
```vue
63+
<FormRenderer
64+
:definition="definition"
65+
:components="{ text: MyInput, email: MyInput }"
66+
@submit="handleSubmit"
67+
/>
68+
```
69+
70+
Unmapped field types fall back to native HTML.
71+
72+
## Docs
73+
74+
- Full guide and API reference: https://formhaus.dev
75+
- Live playground: https://formhaus.dev/playground.html
76+
- Source and issues: https://github.com/ignsm/formhaus
77+
78+
## License
79+
80+
MIT

0 commit comments

Comments
 (0)