Skip to content

Commit 5ee9f0a

Browse files
committed
docs(FormLabel): component documentation
1 parent e88fc88 commit 5ee9f0a

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

apps/docs/.vitepress/config.mts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ export default defineConfig({
3636
{ text: 'Custom validators', link: '/guide/customization/custom-validators' }
3737
]
3838
},
39+
{
40+
text: 'Components',
41+
items: [
42+
{ text: 'FormLabel', link: '/guide/components/FormLabel' },
43+
]
44+
},
3945
{
4046
text: 'Composables',
4147
items: [
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
outline: [2,3]
3+
---
4+
# FormLabel <Badge type="tip" text=">=2.7.0"/>
5+
> A label component that automatically handles the labelIcon property and position.
6+
7+
## Usage
8+
:::code-group
9+
```vue [template]
10+
<template>
11+
<FormLabel
12+
:label-icon="labelIcon"
13+
:label-icon-position="labelIconPosition"
14+
:label="field.label"
15+
:field-id="props.id"
16+
/>
17+
</template>
18+
```
19+
```vue [script setup]
20+
<script setup>
21+
import { toRefs } from 'vue'
22+
import { FormLabel, useLabelIcon, useFieldProps } from '@kevinkosterr/vue3-form-generator'
23+
24+
const props = defineProps(useFieldProps())
25+
26+
const { field, model } = toRefs(props)
27+
const { labelIcon, labelIconPosition } = useLabelIcon(field.value.labelIcon)
28+
</script>
29+
```
30+
:::
31+
32+
## Props
33+
### `labelIcon` <Badge type="info" text="string | ComponentPublicInstance | null" />
34+
Either a string webfont class, a component or `LabelIconDefinition`.
35+
36+
### `labelIconPosition` <Badge type="info" text="'left' | 'right' | null" />
37+
Either `'left'`, `'right'` or `null`
38+
39+
### `label` <Badge type="info" text="string" />
40+
Label as set by the field schema.
41+
42+
### `fieldId` <Badge type="info" text="string" />
43+
Computed field id, taken from props.

0 commit comments

Comments
 (0)