Skip to content

Commit d545b4a

Browse files
committed
Add ability to control TextArea resize via resize prop
1 parent e7dba13 commit d545b4a

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

packages/core/src/common/classes.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@ export const RESIZABLE_INPUT_SPAN = `${NS}-resizable-input-span`;
192192

193193
export const TEXT_AREA = `${NS}-text-area`;
194194
export const TEXT_AREA_AUTO_RESIZE = `${TEXT_AREA}-auto-resize`;
195+
export const TEXT_AREA_RESIZE_NONE = `${TEXT_AREA}-resize-none`;
196+
export const TEXT_AREA_RESIZE_VERTICAL = `${TEXT_AREA}-resize-vertical`;
197+
export const TEXT_AREA_RESIZE_HORIZONTAL = `${TEXT_AREA}-resize-horizontal`;
198+
export const TEXT_AREA_RESIZE_BOTH = `${TEXT_AREA}-resize-both`;
195199

196200
export const CONTROL = `${NS}-control`;
197201
export const CONTROL_INDICATOR = `${CONTROL}-indicator`;

packages/core/src/components/forms/_input.scss

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,20 @@ textarea.#{$ns}-input {
7878
// we are controlling vertical resizing automatically, so restrict user resizing to horizontal dimension only
7979
resize: horizontal;
8080
}
81+
82+
&.#{$ns}-text-area-resize-none {
83+
resize: none;
84+
}
85+
86+
&.#{$ns}-text-area-resize-vertical {
87+
resize: vertical;
88+
}
89+
90+
&.#{$ns}-text-area-resize-horizontal {
91+
resize: horizontal;
92+
}
93+
94+
&.#{$ns}-text-area-resize-both {
95+
resize: both;
96+
}
8197
}

packages/core/src/components/forms/textArea.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ export interface TextAreaProps extends IntentProps, Props, React.TextareaHTMLAtt
6161
*/
6262
large?: boolean;
6363

64+
/**
65+
* Controls the CSS `resize` property of the textarea. Set to control whether the text area can be manually resized
66+
* and in which direction(s). If not set, the default browser behavior applies.
67+
*/
68+
resize?: "none" | "vertical" | "horizontal" | "both";
69+
6470
/**
6571
* Whether the text area should appear with small styling.
6672
*
@@ -162,6 +168,7 @@ export class TextArea extends AbstractPureComponent<TextAreaProps, TextAreaState
162168
intent,
163169
// eslint-disable-next-line @typescript-eslint/no-deprecated
164170
large,
171+
resize,
165172
size = "medium",
166173
// eslint-disable-next-line @typescript-eslint/no-deprecated
167174
small,
@@ -176,6 +183,10 @@ export class TextArea extends AbstractPureComponent<TextAreaProps, TextAreaState
176183
{
177184
[Classes.FILL]: fill,
178185
[Classes.TEXT_AREA_AUTO_RESIZE]: autoResize,
186+
[Classes.TEXT_AREA_RESIZE_NONE]: resize === "none",
187+
[Classes.TEXT_AREA_RESIZE_VERTICAL]: resize === "vertical",
188+
[Classes.TEXT_AREA_RESIZE_HORIZONTAL]: resize === "horizontal",
189+
[Classes.TEXT_AREA_RESIZE_BOTH]: resize === "both",
179190
},
180191
className,
181192
);

0 commit comments

Comments
 (0)