diff --git a/apps/storybook/stories/text-input.stories.tsx b/apps/storybook/stories/text-input.stories.tsx
index b4c5943b..8ace0518 100644
--- a/apps/storybook/stories/text-input.stories.tsx
+++ b/apps/storybook/stories/text-input.stories.tsx
@@ -12,6 +12,9 @@ export default {
autoComplete: {
control: 'text',
},
+ description: {
+ control: 'text',
+ },
disabled: {
control: 'boolean',
},
@@ -183,6 +186,25 @@ export function Error() {
);
}
+export function Description() {
+ const [value, setValue] = useState('1234567');
+
+ return (
+
+ );
+}
+
export function AddOns() {
return (
diff --git a/packages/ui/src/TextInput/TextInput.tsx b/packages/ui/src/TextInput/TextInput.tsx
index 28d90bce..6765f132 100644
--- a/packages/ui/src/TextInput/TextInput.tsx
+++ b/packages/ui/src/TextInput/TextInput.tsx
@@ -62,6 +62,7 @@ type EndAddOnProps =
type BaseProps = Readonly<{
defaultValue?: string;
+ description?: React.ReactNode;
endIcon?: React.ComponentType
>;
errorMessage?: React.ReactNode;
id?: string;
@@ -99,6 +100,7 @@ const stateClasses: Record<
function TextInput(
{
defaultValue,
+ description,
disabled,
endAddOn,
endAddOnType,
@@ -119,7 +121,7 @@ function TextInput(
const hasError = errorMessage != null;
const generatedId = useId();
const id = idParam ?? generatedId;
- const errorId = useId();
+ const messageId = useId();
const state: State = hasError ? 'error' : 'normal';
const { input: inputClass, container: containerClass } = stateClasses[state];
@@ -175,7 +177,9 @@ function TextInput(
})()}
- {errorMessage && (
-
- {errorMessage}
+ {(errorMessage ?? description) && (
+
+ {errorMessage ?? description}
)}