question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Request to add autosizing to Textarea

See original GitHub issue

Is your feature request related to a problem? Please describe. This is a pretty standard feature for textareas nowadays

Describe the solution you’d like Simply add maxRows and minRows as props, and auto-grow/shrink with content

Describe alternatives you’ve considered Currently going to have to implement react-textarea-autosize and figure out how to do the styling independent of Chakra 😢

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:18
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

54reactions
segunadebayocommented, Aug 6, 2020

Here’s a solution I used recently on a project.

import { Textarea } from "@chakra-ui/core";
import ResizeTextarea from "react-textarea-autosize";
import React from "react";

export const AutoResizeTextarea = React.forwardRef((props, ref) => {
  return (
    <Textarea
      minH="unset"
      overflow="hidden"
      w="100%"
      resize="none"
      ref={ref}
      minRows={1}
      as={ResizeTextarea}
      {...props}
    />
  );
});

Hope you find this useful.

18reactions
Jossciicommented, Nov 15, 2021

Here’s a solution I used recently on a project.

import { Textarea } from "@chakra-ui/core";
import ResizeTextarea from "react-textarea-autosize";
import React from "react";

export const AutoResizeTextarea = React.forwardRef((props, ref) => {
  return (
    <Textarea
      minH="unset"
      overflow="hidden"
      w="100%"
      resize="none"
      ref={ref}
      minRows={1}
      as={ResizeTextarea}
      {...props}
    />
  );
});

Hope you find this useful.

for any one who wants a typescript version:

import { Textarea, TextareaProps } from "@chakra-ui/react";
import ResizeTextarea from "react-textarea-autosize";
import React from "react";

export const AutoResizeTextarea = React.forwardRef<
  HTMLTextAreaElement,
  TextareaProps
>((props, ref) => {
  return (
    <Textarea
      minH="unset"
      overflow="hidden"
      w="100%"
      resize="none"
      ref={ref}
      minRows={1}
      as={ResizeTextarea}
      {...props}
    />
  );
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating a textarea with auto-resize - javascript - Stack Overflow
OPTION 1 (With jQuery). This option requires jQuery and has been tested and is working with 1.7.2 - 3.6. Simple (Add this jquery...
Read more >
How to create auto-resize textarea using JavaScript/jQuery
Create a textarea and the task is to automatically resize it when we type or paste the content in it. It can be...
Read more >
how to auto resize a textarea field? - Jotform
1. First, you can use the default "Textarea" field under the "Form Tools" section. · 2. You can also try re-adding the Textarea...
Read more >
Creating a Custom Auto Resize TextArea Component For ...
Creating a Custom Auto Resize TextArea Component For Your React Web Application · 1. Creating the base component · 2. Creating the onChange ......
Read more >
Make a Textarea Auto Resize to fit Contents - Impressive Webs
Some JavaScript and CSS to add to your page to add textarea auto resize capabilities. This ensues textarea elements will grow with content ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found