โ†”๏ธ CSS resize โ€” Complete Tutorial

๐ŸŒ What Is resize?

The resize property allows users to manually resize elements on the pageโ€”typically <textarea>, but also any element with overflow not set to visible. It gives users control over how big or small resizable components become.

>>โ€œUse resize to let users dynamically adjust UI elements like textareas or panels.โ€

Note

โœ” Commonly used on textareas
โœ” Requires overflow value other than visible
โœ” Resizing behavior depends on browser & platform

๐Ÿ“ฆ Syntax

resize syntax

resize: none | both | horizontal | vertical | block | inline;
ValueDescription
noneUser cannot resize the element.
bothResizable in both horizontal and vertical directions.
horizontalResizable only leftโ€“right.
verticalResizable only upโ€“down.
blockResizable in the block direction (depends on writing-mode).
inlineResizable in inline direction (depends on writing-mode).

๐Ÿ“Œ Important Requirement: overflow

For resizing to work, overflow must NOT be visible.

Required overflow

textarea {
  resize: both;
  overflow: auto; /* Required */
}

Note

If overflow: visible; is set, the resize handle will not appear.

๐Ÿ“Œ 1. Make a Textarea Resizable in Both Directions

Textarea both resize

textarea {
  resize: both;
  overflow: auto;
}

This is the default behavior in many browsers.

๐Ÿ“Œ 2. Disable Resizing Completely

Disable resize

textarea {
  resize: none;
}

Useful when you want strict layout control.

๐Ÿ“Œ 3. Allow Only Vertical Resize

Vertical only

textarea {
  resize: vertical;
  overflow: auto;
}

๐Ÿ“Œ 4. Allow Only Horizontal Resize

Horizontal only

textarea {
  resize: horizontal;
  overflow: auto;
}

๐Ÿ“Œ 5. Resize Block/Inline Direction (Writing Mode Aware)

Writing-mode example

.panel {
  writing-mode: vertical-rl;
  resize: block;   /* resizes top-bottom in this mode */
  overflow: auto;
}

block and inline resizing follow the documentโ€™s writing mode.

๐Ÿ“Œ 6. Add a Custom Resizable Panel

Custom resizable panel

.resizable-box {
  width: 200px;
  height: 150px;
  padding: 12px;
  background: #fafafa;
  border: 2px solid #ddd;
  resize: both;
  overflow: auto;
}

You can make any element resizable โ€” not just textareas.

๐Ÿงช Real-World Examples

1๏ธโƒฃ Resizable Chat Input Field

Chat textarea

.chat-input {
  resize: vertical;
  overflow: auto;
}

2๏ธโƒฃ Code Editor Panel

Editor panel

.editor {
  resize: both;
  overflow: auto;
  min-width: 250px;
  min-height: 150px;
}

3๏ธโƒฃ Resizable Dashboard Widget

Dashboard widget

.widget {
  resize: both;
  overflow: hidden;
  border: 1px solid #ccc;
  padding: 16px;
}

โš ๏ธ Common Mistakes

  • โŒ Forgetting to set overflow โ†’ resize handle won't appear
  • โŒ Expecting resize to work on inline elements (it must be block-level or replaced)
  • โŒ Using resize on form controls with strict layout requirements
  • โŒ Forgetting that browser UI for resizing differs across platforms

Note

Resize improves UX but should be used thoughtfully to avoid breaking layouts.

๐Ÿ”ฅ Summary

The resize property enables user-controlled resizing of elements. Itโ€™s mostly used for textareas, panels, widgets, and editable containers that benefit from flexible size adjustments.

>>โ€œGive users control when they need itโ€”use resize wisely.โ€

Learn more โ†’MDN Docs ๐Ÿ“˜