will
will

Reputation: 235

how to set the max length to TextareaAutosize

I need my TextareaAutosize max length is 60 , i set the property inputProps equal 60, it doesn't work.

    <TextareaAutosize classes={classes.textarea} ref={textAreaRef} aria-label="empty textarea" rowsMin={5} inputProps={{"maxLength":60}} placeholder="60 Character Limit" />

Upvotes: 1

Views: 2561

Answers (1)

Ryan Le
Ryan Le

Reputation: 8412

For maxLength you put it directly to props

Because TextareaAutosize inherit from HTMLTextAreaElement

<TextareaAutosize
  classes={classes.textarea}
  ref={textAreaRef}
  aria-label="empty textarea"
  rowsMin={5}
  maxLength={60}
  placeholder="60 Character Limit"
/>;

Live example:

Edit Material demo (forked)

Upvotes: 3

Related Questions