Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(themes): secondary selector triggers match the theme's secondary Button (#7548)

Cindy Zhangfe8cad01cdc6
diff --git a/.changeset/secondary-selector-theme-parity.md b/.changeset/secondary-selector-theme-parity.md
new file mode 100644
index 0000000000..79104af3ce
--- /dev/null
+++ b/.changeset/secondary-selector-theme-parity.md
@@ -0,0 +1,13 @@
+---
+'@astryxdesign/cli': patch
+'@astryxdesign/core': patch
+'@astryxdesign/theme-butter': patch
+'@astryxdesign/theme-chocolate': patch
+'@astryxdesign/theme-gothic': patch
+'@astryxdesign/theme-stone': patch
+'@astryxdesign/theme-y2k': patch
+---
+
+[fix] A `secondary` Selector, MultiSelector, or ComplexSelector now matches the theme's secondary Button: under butter, chocolate, gothic, stone, and y2k it takes that Button's border, fill, text color, and hover instead of the default borderless neutral fill, so a toolbar mixing secondary buttons and selectors reads as one set of controls. Disabled and read-only triggers keep a still fill on hover, as a disabled Button does, and a Selector or MultiSelector inside an InputGroup keeps the group's neutral fill and edges. The default theme is unchanged, the selector docs now say `secondary` follows the theme's secondary Button, and themes added with the CLI get the same parity.
+
+@cixzhang
diff --git a/docs/specs/AST-079-selector-trigger-hierarchy/spec.md b/docs/specs/AST-079-selector-trigger-hierarchy/spec.md
index 1c1bdbad1b..3e4e81d017 100644
--- a/docs/specs/AST-079-selector-trigger-hierarchy/spec.md
+++ b/docs/specs/AST-079-selector-trigger-hierarchy/spec.md
@@ -143,10 +143,6 @@ selection, and component geometry remain outside this record.
InputGroup surface rules; this record projects those rules onto the adopted
trigger value without changing them.
- The Button component retains its released variant map and rendering.
-- Implementation gap: under a theme that restyles its secondary `Button`
- (butter, chocolate, gothic, stone, y2k), the three selectors' `secondary`
- triggers keep the default borderless, neutral-filled treatment instead of
- matching it.
- `architecture:public-component-api` continues to own additive API admission,
defaults, and compatibility. `architecture:component-theming-surface`
continues to own target and visual-prop propagation.
diff --git a/packages/cli/assets/templates/themes/butter/butterTheme.ts b/packages/cli/assets/templates/themes/butter/butterTheme.ts
index ddbf7ae752..809d469071 100644
--- a/packages/cli/assets/templates/themes/butter/butterTheme.ts
+++ b/packages/cli/assets/templates/themes/butter/butterTheme.ts
@@ -43,6 +43,55 @@ const butterSyntax = defineSyntaxTheme({
},
});
+/**
+ * The secondary Button treatment. Selector, MultiSelector, and ComplexSelector
+ * reuse it for their `secondary` trigger so every secondary control in this
+ * theme matches (AST-079 FR2).
+ *
+ * Secondary: blue outline + label in light, butter yellow in dark.
+ */
+const SECONDARY_BUTTON = {
+ backgroundColor: 'transparent',
+ borderWidth: '1.5px',
+ borderStyle: 'solid',
+ borderColor: 'light-dark(#225BFF, #FDEE8C)',
+ color: 'light-dark(#225BFF, #FDEE8C)',
+ ':hover': {
+ backgroundColor: 'light-dark(#225BFF14, #FDEE8C14)',
+ },
+} as const;
+
+/**
+ * The secondary Button treatment on Selector and MultiSelector triggers
+ * (AST-079 FR2). Inside an InputGroup a trigger keeps the neutral fill and the
+ * group's edges instead (FR6). The hover stays off disabled and read-only
+ * triggers, which carry `data-disabled` and `data-readonly`.
+ */
+const SECONDARY_SELECTOR = {
+ ':not(.astryx-input-group *)': {
+ backgroundColor: SECONDARY_BUTTON.backgroundColor,
+ borderWidth: SECONDARY_BUTTON.borderWidth,
+ borderStyle: SECONDARY_BUTTON.borderStyle,
+ borderColor: SECONDARY_BUTTON.borderColor,
+ color: SECONDARY_BUTTON.color,
+ },
+ ':hover:not([data-disabled], [data-readonly], .astryx-input-group *)':
+ SECONDARY_BUTTON[':hover'],
+} as const;
+
+/**
+ * The secondary Button treatment on ComplexSelector triggers (AST-079 FR2), with
+ * the hover kept off a disabled trigger, whose inner button is disabled.
+ */
+const SECONDARY_COMPLEX_SELECTOR = {
+ backgroundColor: SECONDARY_BUTTON.backgroundColor,
+ borderWidth: SECONDARY_BUTTON.borderWidth,
+ borderStyle: SECONDARY_BUTTON.borderStyle,
+ borderColor: SECONDARY_BUTTON.borderColor,
+ color: SECONDARY_BUTTON.color,
+ ':hover:not(:has(> :disabled))': SECONDARY_BUTTON[':hover'],
+} as const;
+
export const butterTheme = defineTheme({
name: 'butter',
@@ -276,17 +325,7 @@ export const butterTheme = defineTheme({
paddingBlock: 'var(--spacing-3)',
paddingInline: 'var(--spacing-4)',
},
- // Secondary: blue outline + label in light, butter yellow in dark.
- 'variant:secondary': {
- backgroundColor: 'transparent',
- borderWidth: '1.5px',
- borderStyle: 'solid',
- borderColor: 'light-dark(#225BFF, #FDEE8C)',
- color: 'light-dark(#225BFF, #FDEE8C)',
- ':hover': {
- backgroundColor: 'light-dark(#225BFF14, #FDEE8C14)',
- },
- },
+ 'variant:secondary': SECONDARY_BUTTON,
// Ghost: same accent color as secondary, no background.
'variant:ghost': {
color: 'light-dark(#225BFF, #FDEE8C)',
@@ -534,6 +573,7 @@ export const butterTheme = defineTheme({
'status:success': {'--color-success': '#91D143'},
'status:warning': {'--color-warning': '#ffc502'},
'status:error': {'--color-error': '#fc473b'},
+ 'variant:secondary': SECONDARY_SELECTOR,
},
'multi-selector': {
base: {
@@ -544,7 +584,9 @@ export const butterTheme = defineTheme({
'status:success': {'--color-success': '#91D143'},
'status:warning': {'--color-warning': '#ffc502'},
'status:error': {'--color-error': '#fc473b'},
+ 'variant:secondary': SECONDARY_SELECTOR,
},
+ 'complex-selector': {'variant:secondary': SECONDARY_COMPLEX_SELECTOR},
typeahead: {
base: {
paddingBlock: 'var(--spacing-2)',
diff --git a/packages/cli/assets/templates/themes/chocolate/chocolateTheme.ts b/packages/cli/assets/templates/themes/chocolate/chocolateTheme.ts
index cc724c1ab4..e7ef8fdf5e 100644
--- a/packages/cli/assets/templates/themes/chocolate/chocolateTheme.ts
+++ b/packages/cli/assets/templates/themes/chocolate/chocolateTheme.ts
@@ -34,6 +34,30 @@ const chocolateSyntax = defineSyntaxTheme({
},
});
+/**
+ * The secondary Button treatment. Selector, MultiSelector, and ComplexSelector
+ * reuse it for their `secondary` trigger so every secondary control in this
+ * theme matches (AST-079 FR2).
+ */
+const SECONDARY_BUTTON = {
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: 'var(--color-border-emphasized)',
+} as const;
+
+/**
+ * The secondary Button treatment on Selector and MultiSelector triggers
+ * (AST-079 FR2). Inside an InputGroup a trigger keeps the neutral fill and the
+ * group's edges instead (FR6).
+ */
+const SECONDARY_SELECTOR = {
+ ':not(.astryx-input-group *)': {
+ borderWidth: SECONDARY_BUTTON.borderWidth,
+ borderStyle: SECONDARY_BUTTON.borderStyle,
+ borderColor: SECONDARY_BUTTON.borderColor,
+ },
+} as const;
+
export const chocolateTheme = defineTheme({
name: 'chocolate',
@@ -219,12 +243,12 @@ export const chocolateTheme = defineTheme({
base: {
borderRadius: 'var(--radius-full)',
},
- 'variant:secondary': {
- borderWidth: '1px',
- borderStyle: 'solid',
- borderColor: 'var(--color-border-emphasized)',
- },
+ 'variant:secondary': SECONDARY_BUTTON,
},
+ // Secondary selector triggers match the secondary Button (AST-079 FR2).
+ selector: {'variant:secondary': SECONDARY_SELECTOR},
+ 'multi-selector': {'variant:secondary': SECONDARY_SELECTOR},
+ 'complex-selector': {'variant:secondary': SECONDARY_BUTTON},
card: {
base: {
diff --git a/packages/cli/assets/templates/themes/gothic/gothicTheme.ts b/packages/cli/assets/templates/themes/gothic/gothicTheme.ts
index 740d15f534..345092f345 100644
--- a/packages/cli/assets/templates/themes/gothic/gothicTheme.ts
+++ b/packages/cli/assets/templates/themes/gothic/gothicTheme.ts
@@ -52,6 +52,36 @@ const gothicSyntax = defineSyntaxTheme({
},
});
+/**
+ * The secondary Button treatment. Selector, MultiSelector, and ComplexSelector
+ * reuse it for their `secondary` trigger so every secondary control in this
+ * theme matches (AST-079 FR2).
+ *
+ * Primary inherits default — light pill with dark text via
+ * --color-accent / --color-on-accent (matches the cream badge).
+ * Secondary uses the dark-slate "neutral" badge treatment.
+ */
+const SECONDARY_BUTTON = {
+ backgroundColor: 'var(--color-background-gray)',
+ color: 'var(--color-text-gray)',
+ borderColor: 'transparent',
+ borderWidth: '0',
+} as const;
+
+/**
+ * The secondary Button treatment on Selector and MultiSelector triggers
+ * (AST-079 FR2). Inside an InputGroup a trigger keeps the neutral fill and the
+ * group's edges instead (FR6).
+ */
+const SECONDARY_SELECTOR = {
+ ':not(.astryx-input-group *)': {
+ backgroundColor: SECONDARY_BUTTON.backgroundColor,
+ color: SECONDARY_BUTTON.color,
+ borderColor: SECONDARY_BUTTON.borderColor,
+ borderWidth: SECONDARY_BUTTON.borderWidth,
+ },
+} as const;
+
export const gothicTheme = defineTheme({
name: 'gothic',
@@ -236,15 +266,7 @@ export const gothicTheme = defineTheme({
components: {
button: {
- // Primary inherits default — light pill with dark text via
- // --color-accent / --color-on-accent (matches the cream badge).
- // Secondary uses the dark-slate "neutral" badge treatment.
- 'variant:secondary': {
- backgroundColor: 'var(--color-background-gray)',
- color: 'var(--color-text-gray)',
- borderColor: 'transparent',
- borderWidth: '0',
- },
+ 'variant:secondary': SECONDARY_BUTTON,
'variant:ghost': {
':hover': {
backgroundColor: 'var(--color-overlay-hover)',
@@ -257,6 +279,10 @@ export const gothicTheme = defineTheme({
color: 'var(--color-text-red)',
},
},
+ // Secondary selector triggers match the secondary Button (AST-079 FR2).
+ selector: {'variant:secondary': SECONDARY_SELECTOR},
+ 'multi-selector': {'variant:secondary': SECONDARY_SELECTOR},
+ 'complex-selector': {'variant:secondary': SECONDARY_BUTTON},
badge: {
base: {
diff --git a/packages/cli/assets/templates/themes/stone/stoneTheme.ts b/packages/cli/assets/templates/themes/stone/stoneTheme.ts
index 4db4a099d8..26ed5651d1 100644
--- a/packages/cli/assets/templates/themes/stone/stoneTheme.ts
+++ b/packages/cli/assets/templates/themes/stone/stoneTheme.ts
@@ -66,6 +66,50 @@ const stoneSyntax = defineSyntaxTheme({
},
});
+/**
+ * The secondary Button treatment. Selector, MultiSelector, and ComplexSelector
+ * reuse it for their `secondary` trigger so every secondary control in this
+ * theme matches (AST-079 FR2).
+ */
+const SECONDARY_BUTTON = {
+ backgroundColor: 'transparent',
+ borderWidth: '1.5px',
+ borderStyle: 'solid',
+ borderColor: 'var(--color-border-emphasized)',
+ ':hover': {
+ backgroundColor: 'var(--color-neutral)',
+ },
+} as const;
+
+/**
+ * The secondary Button treatment on Selector and MultiSelector triggers
+ * (AST-079 FR2). Inside an InputGroup a trigger keeps the neutral fill and the
+ * group's edges instead (FR6). The hover stays off disabled and read-only
+ * triggers, which carry `data-disabled` and `data-readonly`.
+ */
+const SECONDARY_SELECTOR = {
+ ':not(.astryx-input-group *)': {
+ backgroundColor: SECONDARY_BUTTON.backgroundColor,
+ borderWidth: SECONDARY_BUTTON.borderWidth,
+ borderStyle: SECONDARY_BUTTON.borderStyle,
+ borderColor: SECONDARY_BUTTON.borderColor,
+ },
+ ':hover:not([data-disabled], [data-readonly], .astryx-input-group *)':
+ SECONDARY_BUTTON[':hover'],
+} as const;
+
+/**
+ * The secondary Button treatment on ComplexSelector triggers (AST-079 FR2), with
+ * the hover kept off a disabled trigger, whose inner button is disabled.
+ */
+const SECONDARY_COMPLEX_SELECTOR = {
+ backgroundColor: SECONDARY_BUTTON.backgroundColor,
+ borderWidth: SECONDARY_BUTTON.borderWidth,
+ borderStyle: SECONDARY_BUTTON.borderStyle,
+ borderColor: SECONDARY_BUTTON.borderColor,
+ ':hover:not(:has(> :disabled))': SECONDARY_BUTTON[':hover'],
+} as const;
+
export const stoneTheme = defineTheme({
name: 'stone',
@@ -269,15 +313,7 @@ export const stoneTheme = defineTheme({
base: {
borderRadius: 'var(--radius-full)',
},
- 'variant:secondary': {
- backgroundColor: 'transparent',
- borderWidth: '1.5px',
- borderStyle: 'solid',
- borderColor: 'var(--color-border-emphasized)',
- ':hover': {
- backgroundColor: 'var(--color-neutral)',
- },
- },
+ 'variant:secondary': SECONDARY_BUTTON,
'variant:destructive': {
backgroundColor: 'var(--color-background-red)',
color: 'var(--color-text-red)',
@@ -396,8 +432,12 @@ export const stoneTheme = defineTheme({
'number-input': INPUT_STATUS_VARS,
'date-input': INPUT_STATUS_VARS,
'time-input': INPUT_STATUS_VARS,
- selector: INPUT_STATUS_VARS,
- 'multi-selector': INPUT_STATUS_VARS,
+ selector: {...INPUT_STATUS_VARS, 'variant:secondary': SECONDARY_SELECTOR},
+ 'multi-selector': {
+ ...INPUT_STATUS_VARS,
+ 'variant:secondary': SECONDARY_SELECTOR,
+ },
+ 'complex-selector': {'variant:secondary': SECONDARY_COMPLEX_SELECTOR},
typeahead: INPUT_STATUS_VARS,
tokenizer: INPUT_STATUS_VARS,
diff --git a/packages/cli/assets/templates/themes/y2k/y2kTheme.ts b/packages/cli/assets/templates/themes/y2k/y2kTheme.ts
index b5a90f0928..27fda0969f 100644
--- a/packages/cli/assets/templates/themes/y2k/y2kTheme.ts
+++ b/packages/cli/assets/templates/themes/y2k/y2kTheme.ts
@@ -40,6 +40,53 @@ const y2kSyntax = defineSyntaxTheme({
},
});
+/**
+ * The secondary Button treatment. Selector, MultiSelector, and ComplexSelector
+ * reuse it for their `secondary` trigger so every secondary control in this
+ * theme matches (AST-079 FR2).
+ */
+const SECONDARY_BUTTON = {
+ backgroundColor: 'var(--color-background-green)',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: 'var(--color-text-green)',
+ color: 'var(--color-text-green)',
+ ':hover': {
+ backgroundColor: 'var(--color-border-green)',
+ },
+} as const;
+
+/**
+ * The secondary Button treatment on Selector and MultiSelector triggers
+ * (AST-079 FR2). Inside an InputGroup a trigger keeps the neutral fill and the
+ * group's edges instead (FR6). The hover stays off disabled and read-only
+ * triggers, which carry `data-disabled` and `data-readonly`.
+ */
+const SECONDARY_SELECTOR = {
+ ':not(.astryx-input-group *)': {
+ backgroundColor: SECONDARY_BUTTON.backgroundColor,
+ borderWidth: SECONDARY_BUTTON.borderWidth,
+ borderStyle: SECONDARY_BUTTON.borderStyle,
+ borderColor: SECONDARY_BUTTON.borderColor,
+ color: SECONDARY_BUTTON.color,
+ },
+ ':hover:not([data-disabled], [data-readonly], .astryx-input-group *)':
+ SECONDARY_BUTTON[':hover'],
+} as const;
+
+/**
+ * The secondary Button treatment on ComplexSelector triggers (AST-079 FR2), with
+ * the hover kept off a disabled trigger, whose inner button is disabled.
+ */
+const SECONDARY_COMPLEX_SELECTOR = {
+ backgroundColor: SECONDARY_BUTTON.backgroundColor,
+ borderWidth: SECONDARY_BUTTON.borderWidth,
+ borderStyle: SECONDARY_BUTTON.borderStyle,
+ borderColor: SECONDARY_BUTTON.borderColor,
+ color: SECONDARY_BUTTON.color,
+ ':hover:not(:has(> :disabled))': SECONDARY_BUTTON[':hover'],
+} as const;
+
export const y2kTheme = defineTheme({
name: 'y2k',
@@ -264,16 +311,7 @@ export const y2kTheme = defineTheme({
color: 'var(--color-background-body)',
borderColor: 'transparent',
},
- 'variant:secondary': {
- backgroundColor: 'var(--color-background-green)',
- borderWidth: '1px',
- borderStyle: 'solid',
- borderColor: 'var(--color-text-green)',
- color: 'var(--color-text-green)',
- ':hover': {
- backgroundColor: 'var(--color-border-green)',
- },
- },
+ 'variant:secondary': SECONDARY_BUTTON,
'variant:ghost': {
borderColor: 'transparent',
},
@@ -285,6 +323,10 @@ export const y2kTheme = defineTheme({
borderColor: 'var(--color-text-red)',
},
},
+ // Secondary selector triggers match the secondary Button (AST-079 FR2).
+ selector: {'variant:secondary': SECONDARY_SELECTOR},
+ 'multi-selector': {'variant:secondary': SECONDARY_SELECTOR},
+ 'complex-selector': {'variant:secondary': SECONDARY_COMPLEX_SELECTOR},
badge: {
base: {
diff --git a/packages/core/src/ComplexSelector/ComplexSelector.doc.mjs b/packages/core/src/ComplexSelector/ComplexSelector.doc.mjs
index f0d0406f53..39ebf344ea 100644
--- a/packages/core/src/ComplexSelector/ComplexSelector.doc.mjs
+++ b/packages/core/src/ComplexSelector/ComplexSelector.doc.mjs
@@ -160,7 +160,7 @@ export const docs = {
name: 'variant',
type: "'input' | 'secondary' | 'ghost'",
description:
- 'Visual trigger style. Input is the bordered form treatment; secondary is borderless and neutral-filled to match secondary buttons; ghost is borderless and transparent to match ghost buttons.',
+ 'Visual trigger style. Input is the bordered form treatment; secondary matches the secondary buttons of the active theme (borderless and neutral-filled by default); ghost is borderless and transparent to match ghost buttons.',
default: "'input'",
},
{
diff --git a/packages/core/src/MultiSelector/MultiSelector.doc.mjs b/packages/core/src/MultiSelector/MultiSelector.doc.mjs
index a9cc737fcd..a2c6827cfb 100644
--- a/packages/core/src/MultiSelector/MultiSelector.doc.mjs
+++ b/packages/core/src/MultiSelector/MultiSelector.doc.mjs
@@ -216,7 +216,7 @@ export const docs = {
name: 'variant',
type: "'input' | 'secondary' | 'ghost'",
description:
- 'Visual trigger style. input is the bordered input treatment for forms; secondary is borderless and neutral-filled, matching secondary buttons for navs and toolbars; ghost is borderless and transparent, matching ghost buttons for toolbar usage.',
+ 'Visual trigger style. input is the bordered input treatment for forms; secondary matches the secondary buttons of the active theme (borderless and neutral-filled by default) for navs and toolbars; ghost is borderless and transparent, matching ghost buttons for toolbar usage.',
default: "'input'",
},
{
@@ -693,7 +693,7 @@ export const docsDense = {
placeholder: 'text when nothing selected',
size: 'size variant',
variant:
- 'visual trigger style: input bordered control, secondary neutral-filled control, or ghost transparent control',
+ 'visual trigger style: input bordered control, secondary control matching the theme secondary buttons, or ghost transparent control',
triggerDisplay: 'how to show selected in trigger',
formatValue:
'formats count/labels trigger text; receives selected items',
diff --git a/packages/core/src/MultiSelector/MultiSelector.tsx b/packages/core/src/MultiSelector/MultiSelector.tsx
index 4df4938cc1..1a6159d764 100644
--- a/packages/core/src/MultiSelector/MultiSelector.tsx
+++ b/packages/core/src/MultiSelector/MultiSelector.tsx
@@ -762,7 +762,8 @@ export interface MultiSelectorProps<
/**
* Visual style of the selector trigger.
* - 'input': bordered input-style trigger for forms
- * - 'secondary': borderless, neutral-filled trigger matching secondary buttons
+ * - 'secondary': matches the theme's secondary buttons (borderless and
+ * neutral-filled by default)
* - 'ghost': borderless, transparent trigger matching ghost buttons
* @default 'input'
*/
diff --git a/packages/core/src/Selector/Selector.doc.mjs b/packages/core/src/Selector/Selector.doc.mjs
index 7ba8a431fb..24d71c660f 100644
--- a/packages/core/src/Selector/Selector.doc.mjs
+++ b/packages/core/src/Selector/Selector.doc.mjs
@@ -247,7 +247,7 @@ export const docs = {
name: 'variant',
type: "'input' | 'secondary' | 'ghost'",
description:
- 'Visual trigger style. input is the bordered input treatment for forms; secondary is borderless and neutral-filled, matching secondary buttons for navs and toolbars; ghost is borderless and transparent, matching ghost buttons for toolbar usage.',
+ 'Visual trigger style. input is the bordered input treatment for forms; secondary matches the secondary buttons of the active theme (borderless and neutral-filled by default) for navs and toolbars; ghost is borderless and transparent, matching ghost buttons for toolbar usage.',
default: "'input'",
},
{
@@ -440,7 +440,7 @@ export const docs = {
{
guidance: true,
description:
- 'Use variant="secondary" when a selector sits in a nav or toolbar beside secondary buttons or a segmented control, so it shares their neutral fill instead of reading as a form field. Use variant="ghost" when a selector sits in a toolbar with ghost buttons. If validation status is needed there, prefer statusVariant="tooltip" so the toolbar height stays compact.',
+ 'Use variant="secondary" when a selector sits in a nav or toolbar beside secondary buttons or a segmented control, so it shares their treatment instead of reading as a form field. Use variant="ghost" when a selector sits in a toolbar with ghost buttons. If validation status is needed there, prefer statusVariant="tooltip" so the toolbar height stays compact.',
},
{
guidance: true,
diff --git a/packages/core/src/Selector/Selector.tsx b/packages/core/src/Selector/Selector.tsx
index cbce9ea6e8..487e0f149c 100644
--- a/packages/core/src/Selector/Selector.tsx
+++ b/packages/core/src/Selector/Selector.tsx
@@ -686,9 +686,9 @@ interface SelectorPropsBase<
/**
* Visual style of the selector trigger.
* - 'input': bordered input-style trigger for forms
- * - 'secondary': borderless, neutral-filled trigger matching secondary
- * buttons, for navs and toolbars where the selector sits beside
- * secondary actions
+ * - 'secondary': matches the theme's secondary buttons (borderless and
+ * neutral-filled by default), for navs and toolbars where the selector
+ * sits beside secondary actions
* - 'ghost': borderless trigger matching ghost buttons, for toolbars
* @default 'input'
*/
diff --git a/packages/themes/butter/src/butterTheme.ts b/packages/themes/butter/src/butterTheme.ts
index ddbf7ae752..809d469071 100644
--- a/packages/themes/butter/src/butterTheme.ts
+++ b/packages/themes/butter/src/butterTheme.ts
@@ -43,6 +43,55 @@ const butterSyntax = defineSyntaxTheme({
},
});
+/**
+ * The secondary Button treatment. Selector, MultiSelector, and ComplexSelector
+ * reuse it for their `secondary` trigger so every secondary control in this
+ * theme matches (AST-079 FR2).
+ *
+ * Secondary: blue outline + label in light, butter yellow in dark.
+ */
+const SECONDARY_BUTTON = {
+ backgroundColor: 'transparent',
+ borderWidth: '1.5px',
+ borderStyle: 'solid',
+ borderColor: 'light-dark(#225BFF, #FDEE8C)',
+ color: 'light-dark(#225BFF, #FDEE8C)',
+ ':hover': {
+ backgroundColor: 'light-dark(#225BFF14, #FDEE8C14)',
+ },
+} as const;
+
+/**
+ * The secondary Button treatment on Selector and MultiSelector triggers
+ * (AST-079 FR2). Inside an InputGroup a trigger keeps the neutral fill and the
+ * group's edges instead (FR6). The hover stays off disabled and read-only
+ * triggers, which carry `data-disabled` and `data-readonly`.
+ */
+const SECONDARY_SELECTOR = {
+ ':not(.astryx-input-group *)': {
+ backgroundColor: SECONDARY_BUTTON.backgroundColor,
+ borderWidth: SECONDARY_BUTTON.borderWidth,
+ borderStyle: SECONDARY_BUTTON.borderStyle,
+ borderColor: SECONDARY_BUTTON.borderColor,
+ color: SECONDARY_BUTTON.color,
+ },
+ ':hover:not([data-disabled], [data-readonly], .astryx-input-group *)':
+ SECONDARY_BUTTON[':hover'],
+} as const;
+
+/**
+ * The secondary Button treatment on ComplexSelector triggers (AST-079 FR2), with
+ * the hover kept off a disabled trigger, whose inner button is disabled.
+ */
+const SECONDARY_COMPLEX_SELECTOR = {
+ backgroundColor: SECONDARY_BUTTON.backgroundColor,
+ borderWidth: SECONDARY_BUTTON.borderWidth,
+ borderStyle: SECONDARY_BUTTON.borderStyle,
+ borderColor: SECONDARY_BUTTON.borderColor,
+ color: SECONDARY_BUTTON.color,
+ ':hover:not(:has(> :disabled))': SECONDARY_BUTTON[':hover'],
+} as const;
+
export const butterTheme = defineTheme({
name: 'butter',
@@ -276,17 +325,7 @@ export const butterTheme = defineTheme({
paddingBlock: 'var(--spacing-3)',
paddingInline: 'var(--spacing-4)',
},
- // Secondary: blue outline + label in light, butter yellow in dark.
- 'variant:secondary': {
- backgroundColor: 'transparent',
- borderWidth: '1.5px',
- borderStyle: 'solid',
- borderColor: 'light-dark(#225BFF, #FDEE8C)',
- color: 'light-dark(#225BFF, #FDEE8C)',
- ':hover': {
- backgroundColor: 'light-dark(#225BFF14, #FDEE8C14)',
- },
- },
+ 'variant:secondary': SECONDARY_BUTTON,
// Ghost: same accent color as secondary, no background.
'variant:ghost': {
color: 'light-dark(#225BFF, #FDEE8C)',
@@ -534,6 +573,7 @@ export const butterTheme = defineTheme({
'status:success': {'--color-success': '#91D143'},
'status:warning': {'--color-warning': '#ffc502'},
'status:error': {'--color-error': '#fc473b'},
+ 'variant:secondary': SECONDARY_SELECTOR,
},
'multi-selector': {
base: {
@@ -544,7 +584,9 @@ export const butterTheme = defineTheme({
'status:success': {'--color-success': '#91D143'},
'status:warning': {'--color-warning': '#ffc502'},
'status:error': {'--color-error': '#fc473b'},
+ 'variant:secondary': SECONDARY_SELECTOR,
},
+ 'complex-selector': {'variant:secondary': SECONDARY_COMPLEX_SELECTOR},
typeahead: {
base: {
paddingBlock: 'var(--spacing-2)',
diff --git a/packages/themes/chocolate/src/chocolateTheme.ts b/packages/themes/chocolate/src/chocolateTheme.ts
index cc724c1ab4..e7ef8fdf5e 100644
--- a/packages/themes/chocolate/src/chocolateTheme.ts
+++ b/packages/themes/chocolate/src/chocolateTheme.ts
@@ -34,6 +34,30 @@ const chocolateSyntax = defineSyntaxTheme({
},
});
+/**
+ * The secondary Button treatment. Selector, MultiSelector, and ComplexSelector
+ * reuse it for their `secondary` trigger so every secondary control in this
+ * theme matches (AST-079 FR2).
+ */
+const SECONDARY_BUTTON = {
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: 'var(--color-border-emphasized)',
+} as const;
+
+/**
+ * The secondary Button treatment on Selector and MultiSelector triggers
+ * (AST-079 FR2). Inside an InputGroup a trigger keeps the neutral fill and the
+ * group's edges instead (FR6).
+ */
+const SECONDARY_SELECTOR = {
+ ':not(.astryx-input-group *)': {
+ borderWidth: SECONDARY_BUTTON.borderWidth,
+ borderStyle: SECONDARY_BUTTON.borderStyle,
+ borderColor: SECONDARY_BUTTON.borderColor,
+ },
+} as const;
+
export const chocolateTheme = defineTheme({
name: 'chocolate',
@@ -219,12 +243,12 @@ export const chocolateTheme = defineTheme({
base: {
borderRadius: 'var(--radius-full)',
},
- 'variant:secondary': {
- borderWidth: '1px',
- borderStyle: 'solid',
- borderColor: 'var(--color-border-emphasized)',
- },
+ 'variant:secondary': SECONDARY_BUTTON,
},
+ // Secondary selector triggers match the secondary Button (AST-079 FR2).
+ selector: {'variant:secondary': SECONDARY_SELECTOR},
+ 'multi-selector': {'variant:secondary': SECONDARY_SELECTOR},
+ 'complex-selector': {'variant:secondary': SECONDARY_BUTTON},
card: {
base: {
diff --git a/packages/themes/gothic/src/gothicTheme.ts b/packages/themes/gothic/src/gothicTheme.ts
index 740d15f534..345092f345 100644
--- a/packages/themes/gothic/src/gothicTheme.ts
+++ b/packages/themes/gothic/src/gothicTheme.ts
@@ -52,6 +52,36 @@ const gothicSyntax = defineSyntaxTheme({
},
});
+/**
+ * The secondary Button treatment. Selector, MultiSelector, and ComplexSelector
+ * reuse it for their `secondary` trigger so every secondary control in this
+ * theme matches (AST-079 FR2).
+ *
+ * Primary inherits default — light pill with dark text via
+ * --color-accent / --color-on-accent (matches the cream badge).
+ * Secondary uses the dark-slate "neutral" badge treatment.
+ */
+const SECONDARY_BUTTON = {
+ backgroundColor: 'var(--color-background-gray)',
+ color: 'var(--color-text-gray)',
+ borderColor: 'transparent',
+ borderWidth: '0',
+} as const;
+
+/**
+ * The secondary Button treatment on Selector and MultiSelector triggers
+ * (AST-079 FR2). Inside an InputGroup a trigger keeps the neutral fill and the
+ * group's edges instead (FR6).
+ */
+const SECONDARY_SELECTOR = {
+ ':not(.astryx-input-group *)': {
+ backgroundColor: SECONDARY_BUTTON.backgroundColor,
+ color: SECONDARY_BUTTON.color,
+ borderColor: SECONDARY_BUTTON.borderColor,
+ borderWidth: SECONDARY_BUTTON.borderWidth,
+ },
+} as const;
+
export const gothicTheme = defineTheme({
name: 'gothic',
@@ -236,15 +266,7 @@ export const gothicTheme = defineTheme({
components: {
button: {
- // Primary inherits default — light pill with dark text via
- // --color-accent / --color-on-accent (matches the cream badge).
- // Secondary uses the dark-slate "neutral" badge treatment.
- 'variant:secondary': {
- backgroundColor: 'var(--color-background-gray)',
- color: 'var(--color-text-gray)',
- borderColor: 'transparent',
- borderWidth: '0',
- },
+ 'variant:secondary': SECONDARY_BUTTON,
'variant:ghost': {
':hover': {
backgroundColor: 'var(--color-overlay-hover)',
@@ -257,6 +279,10 @@ export const gothicTheme = defineTheme({
color: 'var(--color-text-red)',
},
},
+ // Secondary selector triggers match the secondary Button (AST-079 FR2).
+ selector: {'variant:secondary': SECONDARY_SELECTOR},
+ 'multi-selector': {'variant:secondary': SECONDARY_SELECTOR},
+ 'complex-selector': {'variant:secondary': SECONDARY_BUTTON},
badge: {
base: {
diff --git a/packages/themes/stone/src/stoneTheme.ts b/packages/themes/stone/src/stoneTheme.ts
index 4db4a099d8..26ed5651d1 100644
--- a/packages/themes/stone/src/stoneTheme.ts
+++ b/packages/themes/stone/src/stoneTheme.ts
@@ -66,6 +66,50 @@ const stoneSyntax = defineSyntaxTheme({
},
});
+/**
+ * The secondary Button treatment. Selector, MultiSelector, and ComplexSelector
+ * reuse it for their `secondary` trigger so every secondary control in this
+ * theme matches (AST-079 FR2).
+ */
+const SECONDARY_BUTTON = {
+ backgroundColor: 'transparent',
+ borderWidth: '1.5px',
+ borderStyle: 'solid',
+ borderColor: 'var(--color-border-emphasized)',
+ ':hover': {
+ backgroundColor: 'var(--color-neutral)',
+ },
+} as const;
+
+/**
+ * The secondary Button treatment on Selector and MultiSelector triggers
+ * (AST-079 FR2). Inside an InputGroup a trigger keeps the neutral fill and the
+ * group's edges instead (FR6). The hover stays off disabled and read-only
+ * triggers, which carry `data-disabled` and `data-readonly`.
+ */
+const SECONDARY_SELECTOR = {
+ ':not(.astryx-input-group *)': {
+ backgroundColor: SECONDARY_BUTTON.backgroundColor,
+ borderWidth: SECONDARY_BUTTON.borderWidth,
+ borderStyle: SECONDARY_BUTTON.borderStyle,
+ borderColor: SECONDARY_BUTTON.borderColor,
+ },
+ ':hover:not([data-disabled], [data-readonly], .astryx-input-group *)':
+ SECONDARY_BUTTON[':hover'],
+} as const;
+
+/**
+ * The secondary Button treatment on ComplexSelector triggers (AST-079 FR2), with
+ * the hover kept off a disabled trigger, whose inner button is disabled.
+ */
+const SECONDARY_COMPLEX_SELECTOR = {
+ backgroundColor: SECONDARY_BUTTON.backgroundColor,
+ borderWidth: SECONDARY_BUTTON.borderWidth,
+ borderStyle: SECONDARY_BUTTON.borderStyle,
+ borderColor: SECONDARY_BUTTON.borderColor,
+ ':hover:not(:has(> :disabled))': SECONDARY_BUTTON[':hover'],
+} as const;
+
export const stoneTheme = defineTheme({
name: 'stone',
@@ -269,15 +313,7 @@ export const stoneTheme = defineTheme({
base: {
borderRadius: 'var(--radius-full)',
},
- 'variant:secondary': {
- backgroundColor: 'transparent',
- borderWidth: '1.5px',
- borderStyle: 'solid',
- borderColor: 'var(--color-border-emphasized)',
- ':hover': {
- backgroundColor: 'var(--color-neutral)',
- },
- },
+ 'variant:secondary': SECONDARY_BUTTON,
'variant:destructive': {
backgroundColor: 'var(--color-background-red)',
color: 'var(--color-text-red)',
@@ -396,8 +432,12 @@ export const stoneTheme = defineTheme({
'number-input': INPUT_STATUS_VARS,
'date-input': INPUT_STATUS_VARS,
'time-input': INPUT_STATUS_VARS,
- selector: INPUT_STATUS_VARS,
- 'multi-selector': INPUT_STATUS_VARS,
+ selector: {...INPUT_STATUS_VARS, 'variant:secondary': SECONDARY_SELECTOR},
+ 'multi-selector': {
+ ...INPUT_STATUS_VARS,
+ 'variant:secondary': SECONDARY_SELECTOR,
+ },
+ 'complex-selector': {'variant:secondary': SECONDARY_COMPLEX_SELECTOR},
typeahead: INPUT_STATUS_VARS,
tokenizer: INPUT_STATUS_VARS,
diff --git a/packages/themes/y2k/src/y2kTheme.ts b/packages/themes/y2k/src/y2kTheme.ts
index b5a90f0928..27fda0969f 100644
--- a/packages/themes/y2k/src/y2kTheme.ts
+++ b/packages/themes/y2k/src/y2kTheme.ts
@@ -40,6 +40,53 @@ const y2kSyntax = defineSyntaxTheme({
},
});
+/**
+ * The secondary Button treatment. Selector, MultiSelector, and ComplexSelector
+ * reuse it for their `secondary` trigger so every secondary control in this
+ * theme matches (AST-079 FR2).
+ */
+const SECONDARY_BUTTON = {
+ backgroundColor: 'var(--color-background-green)',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: 'var(--color-text-green)',
+ color: 'var(--color-text-green)',
+ ':hover': {
+ backgroundColor: 'var(--color-border-green)',
+ },
+} as const;
+
+/**
+ * The secondary Button treatment on Selector and MultiSelector triggers
+ * (AST-079 FR2). Inside an InputGroup a trigger keeps the neutral fill and the
+ * group's edges instead (FR6). The hover stays off disabled and read-only
+ * triggers, which carry `data-disabled` and `data-readonly`.
+ */
+const SECONDARY_SELECTOR = {
+ ':not(.astryx-input-group *)': {
+ backgroundColor: SECONDARY_BUTTON.backgroundColor,
+ borderWidth: SECONDARY_BUTTON.borderWidth,
+ borderStyle: SECONDARY_BUTTON.borderStyle,
+ borderColor: SECONDARY_BUTTON.borderColor,
+ color: SECONDARY_BUTTON.color,
+ },
+ ':hover:not([data-disabled], [data-readonly], .astryx-input-group *)':
+ SECONDARY_BUTTON[':hover'],
+} as const;
+
+/**
+ * The secondary Button treatment on ComplexSelector triggers (AST-079 FR2), with
+ * the hover kept off a disabled trigger, whose inner button is disabled.
+ */
+const SECONDARY_COMPLEX_SELECTOR = {
+ backgroundColor: SECONDARY_BUTTON.backgroundColor,
+ borderWidth: SECONDARY_BUTTON.borderWidth,
+ borderStyle: SECONDARY_BUTTON.borderStyle,
+ borderColor: SECONDARY_BUTTON.borderColor,
+ color: SECONDARY_BUTTON.color,
+ ':hover:not(:has(> :disabled))': SECONDARY_BUTTON[':hover'],
+} as const;
+
export const y2kTheme = defineTheme({
name: 'y2k',
@@ -264,16 +311,7 @@ export const y2kTheme = defineTheme({
color: 'var(--color-background-body)',
borderColor: 'transparent',
},
- 'variant:secondary': {
- backgroundColor: 'var(--color-background-green)',
- borderWidth: '1px',
- borderStyle: 'solid',
- borderColor: 'var(--color-text-green)',
- color: 'var(--color-text-green)',
- ':hover': {
- backgroundColor: 'var(--color-border-green)',
- },
- },
+ 'variant:secondary': SECONDARY_BUTTON,
'variant:ghost': {
borderColor: 'transparent',
},
@@ -285,6 +323,10 @@ export const y2kTheme = defineTheme({
borderColor: 'var(--color-text-red)',
},
},
+ // Secondary selector triggers match the secondary Button (AST-079 FR2).
+ selector: {'variant:secondary': SECONDARY_SELECTOR},
+ 'multi-selector': {'variant:secondary': SECONDARY_SELECTOR},
+ 'complex-selector': {'variant:secondary': SECONDARY_COMPLEX_SELECTOR},
badge: {
base: {
diff --git a/scripts/check-secondary-selector-parity.test.mjs b/scripts/check-secondary-selector-parity.test.mjs
new file mode 100644
index 0000000000..69682095a7
--- /dev/null
+++ b/scripts/check-secondary-selector-parity.test.mjs
@@ -0,0 +1,102 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @file Secondary selector trigger parity guard.
+ *
+ * AST-079 FR2 (and Selector DD1) require the `secondary` trigger of Selector,
+ * MultiSelector, and ComplexSelector to match the active theme's secondary
+ * Button. Themes restyle the Button through `components.button`, and that rule
+ * reaches only Buttons, so a theme that restyles its secondary Button must give
+ * the three selector targets the same `variant:secondary` treatment. A theme
+ * that leaves the Button at its default leaves the selectors at theirs. The
+ * selector copy keeps its border off triggers inside an InputGroup (FR6) and
+ * its hover off disabled and read-only triggers.
+ *
+ * @input The seven first-party theme objects.
+ * @output Fails when a selector target's `variant:secondary` differs from the
+ * theme's secondary Button entry.
+ * @position Repo-level guard, sibling of the other scripts/check-*.
+ */
+
+import {describe, it, expect} from 'vitest';
+import {butterTheme} from '../packages/themes/butter/src/butterTheme.ts';
+import {chocolateTheme} from '../packages/themes/chocolate/src/chocolateTheme.ts';
+import {gothicTheme} from '../packages/themes/gothic/src/gothicTheme.ts';
+import {matchaTheme} from '../packages/themes/matcha/src/matchaTheme.ts';
+import {neutralTheme} from '../packages/themes/neutral/src/neutralTheme.ts';
+import {stoneTheme} from '../packages/themes/stone/src/stoneTheme.ts';
+import {y2kTheme} from '../packages/themes/y2k/src/y2kTheme.ts';
+
+const THEMES = {
+ butter: butterTheme,
+ chocolate: chocolateTheme,
+ gothic: gothicTheme,
+ matcha: matchaTheme,
+ neutral: neutralTheme,
+ stone: stoneTheme,
+ y2k: y2kTheme,
+};
+
+const SELECTOR_TARGETS = ['selector', 'multi-selector', 'complex-selector'];
+/**
+ * Selector and MultiSelector triggers inside an InputGroup keep the neutral
+ * fill and the group's edges (FR6), so their treatment applies outside one.
+ */
+const OUTSIDE_INPUT_GROUP = ':not(.astryx-input-group *)';
+/** Hover scopes that keep the Button's hover off disabled and read-only triggers. */
+const HOVER_SCOPES = {
+ selector:
+ ':hover:not([data-disabled], [data-readonly], .astryx-input-group *)',
+ 'multi-selector':
+ ':hover:not([data-disabled], [data-readonly], .astryx-input-group *)',
+ 'complex-selector': ':hover:not(:has(> :disabled))',
+};
+const GROUPED_TARGETS = new Set(['selector', 'multi-selector']);
+
+/** Split a style entry into resting declarations and its `:hover` block. */
+function splitButton(entry = {}) {
+ const resting = {};
+ let hover;
+ for (const [key, value] of Object.entries(entry)) {
+ if (key === ':hover') hover = value;
+ else resting[key] = value;
+ }
+ return {resting, hover};
+}
+
+/**
+ * Read a selector entry back as the treatment a standalone, enabled, editable
+ * trigger gets: its resting declarations and its hover.
+ */
+function readSelector(entry = {}, target) {
+ const resting = {};
+ let hover;
+ for (const [key, value] of Object.entries(entry)) {
+ if (key === HOVER_SCOPES[target]) hover = value;
+ else if (GROUPED_TARGETS.has(target) && key === OUTSIDE_INPUT_GROUP) {
+ Object.assign(resting, value);
+ } else if (key.startsWith(':') || GROUPED_TARGETS.has(target)) {
+ // A grouped target may only style outside an InputGroup.
+ throw new Error(`${target}: unexpected key ${key}`);
+ } else resting[key] = value;
+ }
+ return {resting, hover};
+}
+
+describe('secondary selector triggers match the secondary Button', () => {
+ for (const [name, theme] of Object.entries(THEMES)) {
+ const button = theme.components?.button?.['variant:secondary'];
+ for (const target of SELECTOR_TARGETS) {
+ it(`${name}: ${target}`, () => {
+ const entry = theme.components?.[target]?.['variant:secondary'];
+ if (button === undefined) {
+ // A theme that leaves the Button at its default leaves the selectors
+ // at theirs.
+ expect(entry).toBeUndefined();
+ return;
+ }
+ expect(readSelector(entry, target)).toEqual(splitButton(button));
+ });
+ }
+ }
+});