-
+
@@ -41,6 +41,8 @@ const feedbacks = [
:size="size"
label="Email"
description="This is a description"
+ hint="This is a hint"
+ help="This is a help"
name="email"
>
diff --git a/src/runtime/components/FormField.vue b/src/runtime/components/FormField.vue
index f8d8a3ff..02322b0c 100644
--- a/src/runtime/components/FormField.vue
+++ b/src/runtime/components/FormField.vue
@@ -2,6 +2,7 @@
import type { AppConfig } from '@nuxt/schema'
import theme from '#build/ui/form-field'
import type { ComponentConfig } from '../types/utils'
+import { createReusableTemplate } from '@vueuse/core'
type FormField = ComponentConfig
@@ -20,6 +21,8 @@ export interface FormFieldProps {
help?: string
error?: string | boolean
hint?: string
+
+ variant?: 'default' | 'inline'
/**
* @defaultValue 'md'
*/
@@ -61,6 +64,7 @@ const appConfig = useAppConfig() as FormField['AppConfig']
const ui = computed(() => tv({ extend: tv(theme), ...(appConfig.ui?.formField || {}) })({
size: props.size,
+ variant: props.variant,
required: props.required
}))
@@ -87,9 +91,28 @@ provide(formFieldInjectionKey, computed(() => ({
help: props.help,
ariaId
}) as FormFieldInjectedOptions))
+
+const [DefineHintTemplate, ReuseHintTemplate] = createReusableTemplate()
+const [DefineDescriptionTemplate, ReuseDescriptionTemplate] = createReusableTemplate()
+
+
+
+ {{ hint }}
+
+
+
+
+
+
+
+ {{ description }}
+
+
+
+
@@ -98,20 +121,12 @@ provide(formFieldInjectionKey, computed(() => ({
{{ label }}
-
-
- {{ hint }}
-
-
+
-
-
-
- {{ description }}
-
-
+
+
diff --git a/src/theme/form-field.ts b/src/theme/form-field.ts
index b05281ab..e034be80 100644
--- a/src/theme/form-field.ts
+++ b/src/theme/form-field.ts
@@ -18,6 +18,14 @@ export default {
lg: { root: 'text-sm' },
xl: { root: 'text-base' }
},
+
+ variant: {
+ inline: {
+ root: 'inline-flex',
+ label: 'mt-1.5 mx-2',
+ container: 'mt-0'
+ }
+ },
required: {
true: {
label: `after:content-['*'] after:ms-0.5 after:text-error`