shadcn.io is not affiliated with official shadcn/ui
Input Group examples · Custom
Textarea with Counter Input Group for React
A message textarea with a 500-character limit and a Post button under it.
A post composer with its limit in view: under the textarea, InputGroupText shows 0/500 and a Post button with a send icon sits at the end. maxLength on the textarea enforces the limit.
Preview
Installation
FAQ
What enforces the 500-character limit?
maxLength={500} on InputGroupTextarea: the browser stops input at 500 characters.
Does 0/500 update as people type?
No, it's fixed text. Keep the textarea's value in state and render its length, as in the Field gallery's Textarea with Character Count.
How are the count and the button laid out?
Both sit in one block-end InputGroupAddon. The count comes first and ms-auto on the button pushes it to the end.
How is the send icon placed in the button?
After the text, with data-icon="inline-end" so the button spaces it as a trailing icon.
Related
- Textarea with Actions Input GroupA message textarea with a Submit button
- Simple AI Prompt Input GroupAn AI prompt box with an enhance button
- Input with Character CounterA field that counts the characters typed
- AI Prompt Input Input GroupAn AI prompt box with a mode menu, a
- Min/Max Length Validation FormA username of 3 to 20 characters and a
- Search Button Input GroupA search input with a labeled Search