@@ -5,7 +5,7 @@ import styled, {
55} from 'styled-components' ;
66import css from '@styled-system/css' ;
77import VisuallyHidden from '@reach/visually-hidden' ;
8- import { uniqueId } from 'lodash-es ' ;
8+ import { useId } from '@reach/auto-id ' ;
99import { Text } from '../Text' ;
1010import { Stack } from '../Stack' ;
1111import { InputComponent } from '../Input' ;
@@ -53,9 +53,9 @@ export const Textarea: React.FC<ITextareaProps> = ({
5353 autosize,
5454 ...props
5555} ) => {
56- const id = props . id || uniqueId ( 'form_' ) ;
5756 const [ wordCount , setWordCount ] = useState ( 0 ) ;
5857 const [ value , setValue ] = useState ( '' ) ;
58+ const id = useId ( props . id ) ;
5959
6060 const Wrapper = useCallback (
6161 ( { children } ) =>
@@ -98,15 +98,15 @@ export const Textarea: React.FC<ITextareaProps> = ({
9898 < >
9999 { props . placeholder && ! label ? (
100100 < VisuallyHidden >
101- < label htmlFor = { id } > { props . placeholder } </ label >
101+ < label htmlFor = { props . id || id } > { props . placeholder } </ label >
102102 </ VisuallyHidden >
103103 ) : null }
104104 { label ? (
105105 < Text
106106 as = "label"
107107 size = { 2 }
108108 marginBottom = { 2 }
109- htmlFor = { id }
109+ htmlFor = { props . id || id }
110110 style = { { display : 'block' } }
111111 >
112112 { label }
@@ -117,7 +117,7 @@ export const Textarea: React.FC<ITextareaProps> = ({
117117 value = { value }
118118 onChange = { update }
119119 onKeyPress = { keyPress }
120- id = { id }
120+ id = { props . id || id }
121121 { ...props }
122122 />
123123 { maxLength ? (
0 commit comments