# Auto-Resize Textarea

> A textarea that grows with its content using field-sizing: content, capped at a max height, with no JavaScript.

- Category: [CSS Form Elements](https://copy-css.com/category/forms)
- Tags: textarea, auto grow, field-sizing, comment box, message, resize
- Live preview: https://copy-css.com/snippets/auto-resize-textarea
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```html
<label class="grow-area">
  <span>Your message</span>
  <textarea name="message" rows="2" placeholder="Type a few lines and watch me grow…"></textarea>
</label>
```

## CSS

```css
.grow-area {
  display: grid;
  gap: 6px;
  width: 260px;
  color: #0c4a6e;
  font: 600 13px system-ui, sans-serif;
}

.grow-area textarea {
  box-sizing: border-box;
  width: 100%;
  min-height: 3lh;
  max-height: 8lh;
  padding: 10px 12px;
  border: 1.5px solid #bae6fd;
  border-radius: 12px;
  background: #fff;
  color: #0f172a;
  font: 400 15px/1.5 system-ui, sans-serif;
  resize: vertical;
  field-sizing: content;
}

.grow-area textarea:focus-visible {
  border-color: #0284c7;
  outline: none;
  box-shadow: 0 0 0 4px rgba(2, 132, 199, 0.15);
}

@supports (field-sizing: content) {
  .grow-area textarea {
    resize: none;
  }
}
```

## Notes

- This CSS Auto-Resize Textarea is 34 lines of pure CSS (0.6 KB) with no JavaScript and no dependencies. It uses field-sizing, box shadows, CSS Grid and keyboard focus styles.
- field-sizing: Chrome and Edge 123+ and Safari 26.2+. Firefox support is very recent; older browsers keep the field at a fixed size.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
