Skip to content

Commit e1ac732

Browse files
committed
feat(docs): start writing Customization docs section
1 parent 2f209f9 commit e1ac732

File tree

3 files changed

+72
-11
lines changed

3 files changed

+72
-11
lines changed

docs/content/1.getting-started/3.usage.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,4 @@ Make sure the schema is available in your component’s setup scope.
3939

4040
## Customization
4141

42-
Zod v4 introduced support for `meta` data, which allows you to annotate fields:
43-
44-
```ts
45-
export interface GlobalMeta {
46-
title?: string
47-
description?: string
48-
example?: unknown
49-
}
50-
```
51-
52-
`nuxt-auto-form` extends this with its own custom meta fields under `autoForm`. This allows you to define things like UI widgets, visibility conditions, or custom rendering behavior.
42+
If you want to learn how to customize your forms, check out the [Customization](/customization) section.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
title: Customization
2+
icon: i-lucide-sparkles
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
title: Basics
3+
description: One of the key features of Nuxt Auto Form is customization, allowing each form to be unique.
4+
---
5+
6+
There are 3 levels where you can customize a form:
7+
8+
## Global Configuration
9+
10+
Want to change the default submit button or input styles?
11+
12+
In `app.config.ts`, you can define global configuration:
13+
14+
```ts
15+
export default defineAppConfig({
16+
autoForm: {
17+
submitButtonComponent: 'SubmitButton',
18+
},
19+
})
20+
```
21+
22+
## Per-Form Configuration
23+
24+
You can override the [global configuration](#global-configuration) for individual forms using the `ui` prop in the `<AutoForm>` component:
25+
26+
```vue
27+
<template>
28+
<AutoForm
29+
:schema="schema"
30+
:ui="{
31+
submitButtonComponent: 'CustomSubmitButton',
32+
}"
33+
/>
34+
</template>
35+
```
36+
37+
The configuration is merged using \[defu].
38+
39+
## Per-Field Configuration
40+
41+
Zod v4 introduced support for `meta` data, allowing you to annotate fields:
42+
43+
```ts
44+
export interface GlobalMeta {
45+
title?: string
46+
description?: string
47+
example?: unknown
48+
}
49+
```
50+
51+
`nuxt-auto-form` extends this with a custom `autoForm` field inside `meta`. This lets you define UI widgets, visibility conditions, or custom rendering behavior.
52+
53+
Example:
54+
55+
```ts
56+
const schema = z.object({
57+
text: z.string()
58+
.nonempty()
59+
.meta({ title: 'Text Input' }),
60+
bool: z.boolean()
61+
.default(true)
62+
.meta({
63+
title: 'Boolean Input with floatRight',
64+
autoForm: { floatRight: true },
65+
})
66+
})
67+
```
68+
69+
This configuration is fully type-safe.

0 commit comments

Comments
 (0)