An open source design system that's fully customizable and agent ready
TypeScript
feat(core): add input-clear-button theme target on the shared clear button wrapper (#5093)
athz955be1908bea
diff --git a/.changeset/input-clear-button-theme-target.md b/.changeset/input-clear-button-theme-target.mdnew file mode 100644index 0000000000..8786ba6ca1--- /dev/null+++ b/.changeset/input-clear-button-theme-target.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[feat] Add `astryx-input-clear-button` theme target on the shared clear button wrapper. Themes can now control the clear button's height and hover independently of other ghost buttons — for example suppressing the hover fill or matching a different element size scale.++@athzdiff --git a/packages/core/src/Field/Field.doc.mjs b/packages/core/src/Field/Field.doc.mjsindex 3350be5232..b46f488fba 100644--- a/packages/core/src/Field/Field.doc.mjs+++ b/packages/core/src/Field/Field.doc.mjs@@ -34,6 +34,7 @@ export const docs = {className: 'astryx-input-status-icon',visualProps: ['size', 'status'],},+ {className: 'astryx-input-clear-button'},{className: 'astryx-input-clear-icon'},],vars: [diff --git a/packages/core/src/Field/InputClearButton.test.tsx b/packages/core/src/Field/InputClearButton.test.tsxindex 55cc61761b..29b766db5e 100644--- a/packages/core/src/Field/InputClearButton.test.tsx+++ b/packages/core/src/Field/InputClearButton.test.tsx@@ -114,4 +114,29 @@ describe('InputClearButton', () => {expect(css).toContain('.astryx-input-clear-icon:hover {');expect(css).toContain('color: var(--color-icon-primary)');});++ it('renders the astryx-input-clear-button target on the button wrapper', () => {+ render(<InputClearButton label="Clear" onClick={() => {}} />);+ const button = screen.getByRole('button', {name: 'Clear'});+ expect(button).toHaveClass('astryx-input-clear-button');+ });++ it('exposes input-clear-button so a theme controls the button size and hover', () => {+ const theme = defineTheme({+ name: 'input-clear-button-test',+ components: {+ 'input-clear-button': {+ base: {+ height: '28px',+ ':hover': {backgroundImage: 'none'},+ },+ },+ },+ });+ const css = generateThemeTestCSS(theme);+ expect(css).toContain('.astryx-input-clear-button {');+ expect(css).toContain('height: 28px');+ expect(css).toContain('.astryx-input-clear-button:hover {');+ expect(css).toContain('background-image: none');+ });});diff --git a/packages/core/src/Field/InputClearButton.tsx b/packages/core/src/Field/InputClearButton.tsxindex f0ad17fddb..7b005d5760 100644--- a/packages/core/src/Field/InputClearButton.tsx+++ b/packages/core/src/Field/InputClearButton.tsx@@ -11,7 +11,8 @@* TextInput, NumberInput, TimeInput, DateInput, DateTimeInput,* DateRangeInput, Selector, MultiSelector, Typeahead, Tokenizer, FileInput —* routes it through here, so the glyph is themed in one place via the- * `astryx-input-clear-icon` target.+ * `astryx-input-clear-icon` target and the button wrapper is themed via the+ * `astryx-input-clear-button` target.*/import type {ReactNode} from 'react';@@ -48,11 +49,13 @@ export function InputClearButton({iconClassName,}: InputClearButtonProps): ReactNode {const {className: iconTargetClassName} = themeProps('input-clear-icon');+ const {className: buttonTargetClassName} = themeProps('input-clear-button');return (<Buttonvariant="ghost"size="sm"label={label}+ className={buttonTargetClassName}icon={<Iconicon="close"