diff --git a/docs/components/content/examples/FormGroupErrorSlotExample.vue b/docs/components/content/examples/FormGroupErrorSlotExample.vue new file mode 100644 index 0000000000..d09826bf42 --- /dev/null +++ b/docs/components/content/examples/FormGroupErrorSlotExample.vue @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + diff --git a/docs/content/3.forms/9.form-group.md b/docs/content/3.forms/9.form-group.md index 8329a45ac3..15b02a821f 100644 --- a/docs/content/3.forms/9.form-group.md +++ b/docs/content/3.forms/9.form-group.md @@ -190,6 +190,115 @@ code: >- This will only work with form elements that support the `size` prop. :: +## Slots + +### `label` + +Use the `#label` slot to set the custom content for label. + +::component-card +--- +slots: + label: + default: +--- + +#label + :u-avatar{src="https://avatars.githubusercontent.com/u/739984?v=4" size="3xs" class="mr-2 inline-flex"} + +#default + :u-input{model-value="benjamincanac" placeholder="you@example.com"} +:: + +### `description` + +Use the `#description` slot to set the custom content for description. + +::component-card +--- +slots: + description: Write only valid email address + default: +props: + label: 'Email' +--- + +#description + Write only valid email address :u-icon{name="i-heroicons-information-circle" class="align-middle"} + +#default + :u-input{model-value="benjamincanac" placeholder="you@example.com"} +:: + +### `hint` + +Use the `#hint` slot to set the custom content for hint. + +::component-card +--- +slots: + hint: + default: +props: + label: 'Step 1' +--- + +#hint + :u-icon{name="i-heroicons-arrow-right-20-solid"} + +#default + :u-input{model-value="benjamincanac" placeholder="you@example.com"} +:: + +### `help` + +Use the `#help` slot to set the custom content for help. + +::component-card +--- +slots: + help: Here are some examples + default: +props: + label: 'Email' +--- + +#help + Here are some examples :u-icon{name="i-heroicons-information-circle" class="align-middle"} + +#default + :u-input{model-value="benjamincanac" placeholder="you@example.com"} +:: + +### `error` + +Use the `#error` slot to set the custom content for error. + +::component-example +#default +:form-group-error-slot-example{class="w-60"} + +#code +```vue + + + + + + + + + + + + + + +``` +:: + ## Props :component-props diff --git a/src/runtime/components/forms/FormGroup.vue b/src/runtime/components/forms/FormGroup.vue index 09e87847f5..727d5c54ff 100644 --- a/src/runtime/components/forms/FormGroup.vue +++ b/src/runtime/components/forms/FormGroup.vue @@ -1,19 +1,37 @@ - - {{ label }} - {{ hint }} + + + + {{ label }} + + + + {{ hint }} + - - {{ description }} + + + + + {{ description }} + + - - {{ error }} + + + + + {{ error }} + - - {{ help }} + + + + {{ help }} +
- {{ description }} + +
+ + + {{ description }} +
- {{ error }} + +
+ + + {{ error }} +
- {{ help }} +
+ + + {{ help }} +