Skip to content

chore: Adds internal style api v2 to prompt input - #5254

Draft
vvaliyev wants to merge 1 commit into
mainfrom
style-v2-prompt-input
Draft

vvaliyev wants to merge 1 commit into
mainfrom
style-v2-prompt-input

Conversation

@vvaliyev

@vvaliyev vvaliyev commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Description

Adds the internal Style API v2 to Prompt input: root, textarea (the native textarea, or the editable element when tokens is set), actionButton forwards to Button.root, token forwards to Token.root, menu forwards to Dropdown.container. Menu options have no slot and paint their own background, so a menu background shows only outside the options.

Changes outside the component / behaviour changes:

  • src/prompt-input/styles.scss: the disabled placeholder (both modes) now reads --awsui-style-placeholder-color when it is set; default rendering is unchanged.
  • The height calculation reads the text element's padding and re-measures when the root, textarea, token or action button class changes, so minRows and maxRows hold with a consumer padding; padding or font set only under :hover, :focus or :focus-within is measured at the next content, rows, density, width or class change. Default heights are unchanged. In token mode p.paragraph inherits the font family of the text element.

The style-docs snapshot and the VR registration of the dev page follow in one PR for all components.

Tracker section: P3d34KdbCd6o.

Related links, issue #, if available: n/a

How has this been tested?

Unit tests for every slot and forward, dev page prompt-input/style-api-v2, build and lint green.

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov

codecov Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.84%. Comparing base (d25043b) to head (ea268fd).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5254   +/-   ##
=======================================
  Coverage   97.83%   97.84%           
=======================================
  Files        1008     1008           
  Lines       32590    32612   +22     
  Branches    12098    12114   +16     
=======================================
+ Hits        31886    31908   +22     
  Misses        698      698           
  Partials        6        6           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The font-family override does not reach entered text when tokens are enabled because the paragraph reset prevents inheritance from the editable element.

1 open issue
What changed in this PR

Adds internal Style API v2 support to PromptInput, enabling custom styling in both native textarea and token modes.

Changes:

  • Adds root and textarea slots, with forwarding to action buttons, tokens, and dropdown menus.
  • Supports placeholder styling tokens, including disabled placeholder colors.
  • Adds slot-forwarding unit tests and a demo page covering component states.
File Description
src/​prompt-input/​tokens/​use-token-mode.tsx Applies editable-element and inline-token classes.
src/​prompt-input/​styles.scss Declares style slots and integrates placeholder tokens.
src/​prompt-input/​internal.tsx Accepts and distributes style classes.
src/​prompt-input/​components/​token-mode.tsx Forwards menu styling to the dropdown container.
src/​prompt-input/​__tests__/​style-api.test.tsx Tests slot classes, forwarding, and DOM prop filtering.
pages/​prompt-input/​style-api-v2.scss Defines custom styles for demo states and slots.
pages/​prompt-input/​style-api-v2.page.tsx Demonstrates styling across native and token modes.

Review effort: Balanced

Comment thread src/prompt-input/styles.scss Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Textarea height calculations still use stock padding and do not rerun when the slot class changes, potentially violating row limits and leaving content clipped or incorrectly sized.

2 open issues
1 resolved since last review

Review effort: Balanced

Comment thread src/prompt-input/internal.tsx Resolved
Comment thread src/prompt-input/styles.scss Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Changing only styleClassNames.token can alter token widths and wrapping without triggering height remeasurement, leaving the editable element at a stale fixed height even with maxRows={-1}.

2 open issues
1 resolved since last review

Review effort: Balanced

Comment thread src/prompt-input/internal.tsx Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

5 open issues

Review effort: Lite

Comment on lines +48 to +55
// Style API v2
export interface StyleClassNames {
root?: string;
textarea?: string;
actionButton?: string;
token?: string;
menu?: string;
}
Comment thread src/prompt-input/internal.tsx Outdated
Comment on lines 191 to 207
// A Style API `padding` on the text element changes its block padding; add its difference from the
// stock padding to the row bounds so they still fit `minRows`/`maxRows` lines. The difference is 0 by default.
const computedStyle = getComputedStyle(element);
const paddingTop = toPaddingLength(computedStyle.paddingTop, designTokens.spaceFieldVertical);
const paddingBottom = toPaddingLength(computedStyle.paddingBottom, designTokens.spaceFieldVertical);
const paddingDelta = `(${paddingTop} + ${paddingBottom} - 2 * ${designTokens.spaceFieldVertical})`;
const minRowsHeight = isTokenMode
? `calc(${minRows} * (${LINE_HEIGHT} + ${PADDING} / 2) + ${PADDING})`
: `calc(${LINE_HEIGHT} + ${designTokens.spaceFieldVertical} * 2)`;
? `calc(${minRows} * (${LINE_HEIGHT} + ${PADDING} / 2) + ${PADDING} + ${paddingDelta})`
: `calc(${LINE_HEIGHT} + ${paddingTop} + ${paddingBottom})`;
const scrollHeight = `calc(${element.scrollHeight}px)`;

if (maxRows === -1) {
element.style.height = `max(${scrollHeight}, ${minRowsHeight})`;
} else {
const maxRowsHeight = `calc(${maxRows <= 0 ? DEFAULT_MAX_ROWS : maxRows} * (${LINE_HEIGHT} + ${PADDING} / 2) + ${PADDING})`;
const maxRowsHeight = `calc(${maxRows <= 0 ? DEFAULT_MAX_ROWS : maxRows} * (${LINE_HEIGHT} + ${PADDING} / 2) + ${PADDING} + ${paddingDelta})`;
element.style.height = `min(max(${scrollHeight}, ${minRowsHeight}), ${maxRowsHeight})`;
}
Comment on lines +1151 to 1158
key={container.id}
variant="inline"
label={container.label}
disabled={!!disabled}
readOnly={!!readOnly}
styleClassNames={{ root: styleClassNames?.token }}
/>,
container.element

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment on lines +193 to +195
const paddingTop = toPaddingLength(computedStyle.paddingTop, designTokens.spaceFieldVertical);
const paddingBottom = toPaddingLength(computedStyle.paddingBottom, designTokens.spaceFieldVertical);
const paddingDelta = `(${paddingTop} + ${paddingBottom} - 2 * ${designTokens.spaceFieldVertical})`;
Comment on lines +195 to +197
const paddingDelta = `(${paddingTop} + ${paddingBottom} - 2 * ${designTokens.spaceFieldVertical})`;
const minRowsHeight = isTokenMode
? `calc(${minRows} * (${LINE_HEIGHT} + ${PADDING} / 2) + ${PADDING})`
: `calc(${LINE_HEIGHT} + ${designTokens.spaceFieldVertical} * 2)`;
? `calc(${minRows} * (${LINE_HEIGHT} + ${PADDING} / 2) + ${PADDING} + ${paddingDelta})`

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment on lines +193 to +195
const paddingTop = toPaddingLength(computedStyle.paddingTop, designTokens.spaceFieldVertical);
const paddingBottom = toPaddingLength(computedStyle.paddingBottom, designTokens.spaceFieldVertical);
const paddingDelta = `(${paddingTop} + ${paddingBottom} - 2 * ${designTokens.spaceFieldVertical})`;

This branch was successfully deployed

3 active deployments
dev-pages-react18 — ea268fd7 Deployed Nov 9, 2026 by vvaliyev via deploy (React 18) / deploy #3239
dev-pages-react16 — ea268fd7 Deployed Nov 9, 2026 by vvaliyev via deploy (React 16) / deploy #3239
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.

2 participants