diff --git a/fakemui/fakemui/inputs/TextField.tsx b/fakemui/fakemui/inputs/TextField.tsx index 16d2c8da2..1ae7e2b0f 100644 --- a/fakemui/fakemui/inputs/TextField.tsx +++ b/fakemui/fakemui/inputs/TextField.tsx @@ -1,4 +1,4 @@ -import React, { forwardRef } from 'react' +import React, { forwardRef, useId } from 'react' import { FormLabel } from './FormLabel' import { FormHelperText } from './FormHelperText' import { Input, InputProps } from './Input' @@ -10,13 +10,18 @@ export interface TextFieldProps extends InputProps { } export const TextField = forwardRef( - ({ label, helperText, error, className = '', ...props }, ref) => ( -
- {label && {label}} - - {helperText && {helperText}} -
- ) + ({ label, helperText, error, className = '', id: providedId, ...props }, ref) => { + const generatedId = useId() + const id = providedId ?? generatedId + + return ( +
+ {label && {label}} + + {helperText && {helperText}} +
+ ) + } ) TextField.displayName = 'TextField'