โ๏ธ 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
โ Requires overflow value other than visible
โ Resizing behavior depends on browser & platform
๐ฆ Syntax
resize syntax
resize: none | both | horizontal | vertical | block | inline;| Value | Description |
|---|---|
| none | User cannot resize the element. |
| both | Resizable in both horizontal and vertical directions. |
| horizontal | Resizable only leftโright. |
| vertical | Resizable only upโdown. |
| block | Resizable in the block direction (depends on writing-mode). |
| inline | Resizable 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 ๐