diff --git a/docs/components/input.md b/docs/components/input.md
index 88e07265..2bcc927a 100644
--- a/docs/components/input.md
+++ b/docs/components/input.md
@@ -104,6 +104,75 @@ const name = ref('')
```
+## Error Messages
+
+- Set validation status via `validationStatus` prop, which accepts `'success'` or `'error'`.
+- Add error messages directly via `error-message` prop.
+- Add success messages directly via `success-message` prop.
+- Control visibility of messages with the `hide-details` prop.
+
+
+```vue
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+```
+
## Extra CSS classes
Sometimes it is required to add some customization to the input or the input wrapper.
diff --git a/docs/components/input/examples/FwbInputExampleErrorMessage.vue b/docs/components/input/examples/FwbInputExampleErrorMessage.vue
new file mode 100644
index 00000000..2ad4b200
--- /dev/null
+++ b/docs/components/input/examples/FwbInputExampleErrorMessage.vue
@@ -0,0 +1,131 @@
+
+
+
Error Messages Examples
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Using error-message prop
+
+
+
+
+
Using validation slot
+
+
+
+
+ Please enter your full address
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/components/FwbInput/FwbInput.vue b/src/components/FwbInput/FwbInput.vue
index 1d49b2bc..aa87707d 100644
--- a/src/components/FwbInput/FwbInput.vue
+++ b/src/components/FwbInput/FwbInput.vue
@@ -30,12 +30,32 @@
+
+
+ {{ errorMessage }}
+
+
+
+
+
+ {{ successMessage }}
+
+
+
+
+
+ errorMessage?: string // New prop for direct error messaging
+ successMessage?: string // New prop for success messaging
+ hideDetails?: boolean // To control visibility of error/helper messages
}
defineOptions({
@@ -85,16 +108,30 @@ const props = withDefaults(defineProps(), {
autocomplete: 'off',
validationStatus: undefined,
blockClasses: undefined,
+ errorMessage: '',
+ successMessage: '',
+ hideDetails: false,
})
const model = useVModel(props, 'modelValue')
const { inputClasses, inputBlockClasses, labelClasses } = useInputClasses(toRefs(props))
+// Computed properties to determine visibility of messages
+const showErrorMessage = computed(() =>
+ !props.hideDetails &&
+ (props.validationStatus === validationStatusMap.Error || props.errorMessage)
+)
+
+const showSuccessMessage = computed(() =>
+ !props.hideDetails &&
+ props.validationStatus === validationStatusMap.Success &&
+ props.successMessage
+)
+
const validationWrapperClasses = computed(() => twMerge(
'mt-2 text-sm',
props.validationStatus === validationStatusMap.Success ? 'text-green-600 dark:text-green-500' : '',
props.validationStatus === validationStatusMap.Error ? 'text-red-600 dark:text-red-500' : '',
-
))
-
+
\ No newline at end of file