Skip to content

[DRAFT] Add rightElement and leftElement to textArea#7694

Draft
cameronjoyner wants to merge 10 commits intodevelopfrom
cj/text-area-elements
Draft

[DRAFT] Add rightElement and leftElement to textArea#7694
cameronjoyner wants to merge 10 commits intodevelopfrom
cj/text-area-elements

Conversation

@cameronjoyner
Copy link
Contributor

@cameronjoyner cameronjoyner commented Jan 7, 2026

Fixes #7511

Checklist

  • Includes tests
  • Update documentation

Changes proposed in this pull request:

Bring leftElement and rightElement to textarea in much the same way that we have for inputGroup. The example below if from the original issue.

image

Screenshot

Screenshot 2026-01-07 at 4 41 53 PM

@changelog-app
Copy link

changelog-app bot commented Jan 7, 2026

Generate changelog in packages/core/changelog/@unreleased

Type (Select exactly one)

  • Feature (Adding new functionality)
  • Improvement (Improving existing functionality)
  • Fix (Fixing an issue with existing functionality)
  • Break (Creating a new major version by breaking public APIs)
  • Deprecation (Removing functionality in a non-breaking way)
  • Migration (Automatically moving data/functionality to a new system)

Description

[DRAFT] Add rightElement and leftElement to textArea


Generate changelog in packages/demo-app/changelog/@unreleased

Type (Select exactly one)

  • Feature (Adding new functionality)
  • Improvement (Improving existing functionality)
  • Fix (Fixing an issue with existing functionality)
  • Break (Creating a new major version by breaking public APIs)
  • Deprecation (Removing functionality in a non-breaking way)
  • Migration (Automatically moving data/functionality to a new system)

Description

[DRAFT] Add rightElement and leftElement to textArea


Check the box to generate changelog(s)

  • Generate changelog entry

@svc-palantir-github
Copy link

removing some fluff from =TextAreaExample

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

Comment on lines +63 to +73
/**
* Element to render on the left side of the textarea.
*/
leftElement?: React.JSX.Element;

/**
* Element to render on the right side of the textarea.
* For best results, use a minimal button, tag, or small spinner.
*/
rightElement?: React.JSX.Element;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A concern/possibility that I'm considering is that this implementation is really [top]leftElement and [top]RightElement. There is a part of me that thinks we'd be missing a good opportunity to provide slightly more robust options and allow textArea to be even more useful. I bring that up because if we want to do it its probably worth doing in this PR and considering the right API. For example do we instead call it textAreaElement and accept React.JSX.Element and an enum of top-left, top-right, bottom-left, bottom-right? Or do we let the API sprawl a bit and go with bottomLeftElement... etc?

Screenshot 2026-01-07 at 4 36 14 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My personal preference is that we some how provide all four corners, especially as the bottomRight is so commonly used for some kind of send or submit button.

Comment on lines +249 to +259
const textareaClasses = classNames(
Classes.INPUT_GROUP,
Classes.intentClass(intent),
Classes.sizeClass(size, { large, small }),
{
[Classes.DISABLED]: htmlProps.disabled,
[Classes.READ_ONLY]: htmlProps.readOnly,
[Classes.FILL]: fill,
},
className,
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

took precedent form inputGroup

Comment on lines +275 to +301
private maybeRenderLeftElement() {
const { leftElement } = this.props;

if (leftElement != null) {
return (
<span className={Classes.INPUT_LEFT_CONTAINER} ref={this.refHandlers.leftElement}>
{leftElement}
</span>
);
}

return undefined;
}

private maybeRenderRightElement() {
const { rightElement } = this.props;

if (rightElement != null) {
return (
<span className={Classes.INPUT_ACTION} ref={this.refHandlers.rightElement}>
{rightElement}
</span>
);
}

return undefined;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similarly followed existing codebase precedent

<TabsExample />
<TagExample />
<TagInputExample />
<TextAreaExample />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

surprised that we didn't have this yet and thought it was worth adding

Comment on lines +245 to +247
if (!hasLeftOrRightElement) {
return textareaElement;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid a breaking change

@svc-palantir-github
Copy link

Merge branch 'develop' into cj/text-area-elements

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add rightElement and leftElement to textArea

2 participants