Skip to content

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

TypeScript

feat(Selectors): add secondary variants across selector inputs (#7252)

Ernestf15a900856d8
diff --git a/.changeset/selector-family-secondary-variants.md b/.changeset/selector-family-secondary-variants.md
new file mode 100644
index 0000000000..a77abc45a0
--- /dev/null
+++ b/.changeset/selector-family-secondary-variants.md
@@ -0,0 +1,8 @@
+---
+'@astryxdesign/core': patch
+---
+
+[feat] Selector, MultiSelector, and ComplexSelector gain a `secondary` variant: a borderless, neutral-filled trigger matching secondary buttons in navigation and toolbar compositions. Inside an `InputGroup`, a secondary Selector or MultiSelector keeps its fill and takes the group's row height and connected edges. Existing `input` (default) and `ghost` behavior is unchanged.
+
+@barm
+@ernestt
diff --git a/.github/scripts/story-play-guard.js b/.github/scripts/story-play-guard.js
index 2b5eb53c39..50c8f12e2c 100644
--- a/.github/scripts/story-play-guard.js
+++ b/.github/scripts/story-play-guard.js
@@ -49,6 +49,18 @@ const TARGETS = [
story: 'core-multiselector--sizes',
guards: 'compact trigger variants match their size tokens',
},
+ {
+ component: 'MultiSelector',
+ story: 'core-multiselector--secondary-variant',
+ guards:
+ 'the secondary trigger keeps its explicit 180px inline size while selected labels change',
+ },
+ {
+ component: 'ComplexSelector',
+ story: 'core-complexselector--secondary-variant',
+ guards:
+ 'the secondary trigger keeps its explicit 190px inline size while the selected value changes',
+ },
{
component: 'Code',
story: 'core-code--colors',
diff --git a/apps/storybook/stories/ComplexSelector.stories.tsx b/apps/storybook/stories/ComplexSelector.stories.tsx
index 45dc0bcdc9..dfb8d7c696 100644
--- a/apps/storybook/stories/ComplexSelector.stories.tsx
+++ b/apps/storybook/stories/ComplexSelector.stories.tsx
@@ -13,6 +13,7 @@
*/
import type {Meta, StoryObj} from '@storybook/react';
+import {expect, userEvent, waitFor, within} from 'storybook/test';
import {useEffect, useMemo, useRef, useState} from 'react';
import * as stylex from '@stylexjs/stylex';
import {
@@ -53,6 +54,9 @@ const meta: Meta<typeof ComplexSelector> = {
},
},
},
+ argTypes: {
+ variant: {control: 'radio', options: ['input', 'secondary', 'ghost']},
+ },
};
export default meta;
@@ -398,6 +402,9 @@ const styles = stylex.create({
borderRadius: radiusVars['--radius-container'],
backgroundColor: colorVars['--color-background-muted'],
},
+ toolbarDemoIntrinsic: {
+ width: 'max-content',
+ },
toolbarContent: {
width: 280,
padding: spacingVars['--spacing-3'],
@@ -760,6 +767,94 @@ export const CategoryTreeSelector: Story = {
type ViewDensity = 'Comfortable' | 'Compact';
+export const SecondaryVariant: Story = {
+ name: 'Secondary toolbar trigger',
+ render: () => {
+ const [density, setDensity] = useState<ViewDensity>('Comfortable');
+
+ return (
+ <div {...stylex.props(styles.toolbarDemo, styles.toolbarDemoIntrinsic)}>
+ <Button
+ label="Reset view"
+ variant="secondary"
+ size="sm"
+ onClick={() => setDensity('Comfortable')}
+ />
+ <ComplexSelector<ViewDensity>
+ label="View density"
+ isLabelHidden
+ value={density}
+ onChange={setDensity}
+ triggerLabel={`Density: ${density}`}
+ variant="secondary"
+ size="sm"
+ width={190}
+ startIcon="viewColumns"
+ alignment="end"
+ contentXstyle={styles.toolbarContent}>
+ {(selectedDensity, onChange, close) => (
+ <VStack gap={3}>
+ <Text type="supporting" color="secondary">
+ Choose how densely rows are displayed.
+ </Text>
+ <HStack gap={2}>
+ {(['Comfortable', 'Compact'] as const).map(option => (
+ <Button
+ key={option}
+ label={option}
+ size="sm"
+ variant={
+ selectedDensity === option ? 'primary' : 'secondary'
+ }
+ onClick={() => {
+ onChange(option);
+ close();
+ }}
+ />
+ ))}
+ </HStack>
+ </VStack>
+ )}
+ </ComplexSelector>
+ <Button label="Share" variant="secondary" size="sm" />
+ </div>
+ );
+ },
+ play: async ({canvasElement}) => {
+ await document.fonts.ready;
+ const canvas = within(canvasElement);
+ const root = canvasElement.querySelector<HTMLElement>(
+ '.astryx-complex-selector[data-variant="secondary"]',
+ );
+ if (root == null) {
+ throw new Error('Secondary ComplexSelector root not found');
+ }
+ const widthBefore = root.getBoundingClientRect().width;
+ expect(widthBefore).toBeCloseTo(190, 0);
+
+ const trigger = canvas.getByRole('button', {name: 'View density'});
+ await userEvent.click(trigger);
+ const dialog = within(document.body).getByRole('dialog', {
+ name: 'View density',
+ });
+ await userEvent.click(
+ within(dialog).getByRole('button', {name: 'Compact'}),
+ );
+ await waitFor(() =>
+ expect(root.getBoundingClientRect().width).toBeCloseTo(widthBefore, 0),
+ );
+ trigger.blur();
+ },
+ parameters: {
+ docs: {
+ description: {
+ story:
+ 'A compact toolbar composition where ComplexSelector uses the same neutral-filled treatment as adjacent secondary buttons.',
+ },
+ },
+ },
+};
+
export const ControlledToolbarTrigger: Story = {
name: 'Controlled toolbar trigger',
render: () => {
diff --git a/apps/storybook/stories/MultiSelector.stories.tsx b/apps/storybook/stories/MultiSelector.stories.tsx
index 279af2df30..fbec29fe3a 100644
--- a/apps/storybook/stories/MultiSelector.stories.tsx
+++ b/apps/storybook/stories/MultiSelector.stories.tsx
@@ -1,10 +1,11 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
import type {Meta, StoryObj} from '@storybook/react';
-import {expect} from 'storybook/test';
+import {expect, userEvent, waitFor, within} from 'storybook/test';
import {useState} from 'react';
import {Button} from '@astryxdesign/core/Button';
import {IconButton} from '@astryxdesign/core/IconButton';
+import {InputGroup, InputGroupText} from '@astryxdesign/core/InputGroup';
import {MultiSelector} from '@astryxdesign/core/MultiSelector';
import {Theme, defineTheme} from '@astryxdesign/core/theme';
@@ -28,7 +29,7 @@ const meta: Meta<typeof MultiSelector> = {
description: {control: 'text'},
placeholder: {control: 'text'},
size: {control: 'radio', options: ['sm', 'md', 'lg']},
- variant: {control: 'radio', options: ['input', 'ghost']},
+ variant: {control: 'radio', options: ['input', 'secondary', 'ghost']},
presentation: {
control: 'radio',
options: ['popover', 'bottom-sheet', 'adaptive'],
@@ -397,6 +398,97 @@ export const GhostVariant: Story = {
decorators: [Story => <Story />],
};
+// Secondary variant for toolbar composition beside secondary buttons
+export const SecondaryVariant: Story = {
+ render: () => {
+ const [columns, setColumns] = useState<string[]>(['Name', 'Email']);
+ return (
+ <div
+ style={{
+ display: 'flex',
+ alignItems: 'center',
+ gap: 8,
+ width: 'max-content',
+ }}>
+ <Button label="Refresh" variant="secondary" />
+ <MultiSelector
+ label="Columns"
+ isLabelHidden
+ variant="secondary"
+ size="md"
+ width={180}
+ options={['Name', 'Email', 'Role', 'Status', 'Created']}
+ value={columns}
+ onChange={setColumns}
+ triggerDisplay="labels"
+ placeholder="Columns"
+ />
+ <Button label="Export" variant="secondary" />
+ </div>
+ );
+ },
+ decorators: [Story => <Story />],
+ play: async ({canvasElement}) => {
+ await document.fonts.ready;
+ const canvas = within(canvasElement);
+ const trigger = canvas.getByRole('combobox', {name: 'Columns'});
+ const root = canvasElement.querySelector<HTMLElement>(
+ '.astryx-multi-selector[data-variant="secondary"]',
+ );
+ if (root == null) {
+ throw new Error('Secondary MultiSelector root not found');
+ }
+ const widthBefore = root.getBoundingClientRect().width;
+ expect(widthBefore).toBeCloseTo(180, 0);
+
+ await userEvent.click(trigger);
+ const listbox = within(document.body).getByRole('listbox');
+ await userEvent.click(within(listbox).getByRole('option', {name: /Role/}));
+ await waitFor(() =>
+ expect(root.getBoundingClientRect().width).toBeCloseTo(widthBefore, 0),
+ );
+ await userEvent.keyboard('{Escape}');
+ trigger.blur();
+ },
+};
+
+// Secondary trigger as the first, middle, and last member of an InputGroup:
+// it keeps its neutral fill and takes the group's row height and seam edges.
+export const SecondaryInInputGroup: Story = {
+ render: () => {
+ const selector = (label: string) => (
+ <MultiSelector
+ label={label}
+ isLabelHidden
+ variant="secondary"
+ options={['Name', 'Email', 'Role']}
+ value={['Name']}
+ onChange={() => {}}
+ />
+ );
+ return (
+ <div
+ data-secondary-input-group-matrix
+ style={{display: 'grid', gap: 16, width: 320}}>
+ <InputGroup label="Secondary first" isLabelHidden>
+ {selector('Columns first')}
+ <InputGroupText>cols</InputGroupText>
+ </InputGroup>
+ <InputGroup label="Secondary middle" isLabelHidden>
+ <InputGroupText>#</InputGroupText>
+ {selector('Columns middle')}
+ <InputGroupText>cols</InputGroupText>
+ </InputGroup>
+ <InputGroup label="Secondary last" isLabelHidden>
+ <InputGroupText>#</InputGroupText>
+ {selector('Columns last')}
+ </InputGroup>
+ </div>
+ );
+ },
+ decorators: [Story => <Story />],
+};
+
// Status variants
export const Status: Story = {
render: () => {
diff --git a/apps/storybook/stories/Selector.stories.tsx b/apps/storybook/stories/Selector.stories.tsx
index 4632c5d1cf..2cd9916909 100644
--- a/apps/storybook/stories/Selector.stories.tsx
+++ b/apps/storybook/stories/Selector.stories.tsx
@@ -4,7 +4,7 @@ import type {Meta, StoryObj} from '@storybook/react';
import {expect, waitFor} from 'storybook/test';
import {useState} from 'react';
import {Button} from '@astryxdesign/core/Button';
-import {InputGroup} from '@astryxdesign/core/InputGroup';
+import {InputGroup, InputGroupText} from '@astryxdesign/core/InputGroup';
import {Selector, SelectorOption} from '@astryxdesign/core/Selector';
import {Theme, defineTheme} from '@astryxdesign/core/theme';
import {RadioIndicator} from '@astryxdesign/core/Indicator';
@@ -63,7 +63,7 @@ const meta: Meta<typeof Selector> = {
},
variant: {
control: 'radio',
- options: ['input', 'ghost'],
+ options: ['input', 'secondary', 'ghost'],
description: 'Visual trigger style',
},
placement: {
@@ -881,6 +881,81 @@ export const GhostVariant: Story = {
decorators: [Story => <Story />],
};
+// Secondary variant for nav composition beside secondary buttons
+export const SecondaryVariant: Story = {
+ render: () => {
+ const [platform, setPlatform] = useState<string | undefined>('all');
+ return (
+ <div
+ style={{
+ display: 'flex',
+ alignItems: 'center',
+ gap: 8,
+ width: 'max-content',
+ }}>
+ <Button label="Share" variant="secondary" />
+ <Selector
+ label="Platform"
+ isLabelHidden
+ variant="secondary"
+ size="md"
+ options={[
+ {value: 'all', label: 'All platforms'},
+ {value: 'ios', label: 'iOS'},
+ {value: 'android', label: 'Android'},
+ ]}
+ value={platform}
+ onChange={setPlatform}
+ />
+ <Button label="Export" variant="secondary" />
+ </div>
+ );
+ },
+ decorators: [Story => <Story />],
+};
+
+// Secondary trigger as the first, middle, and last member of an InputGroup:
+// it keeps its neutral fill and takes the group's row height and seam edges.
+export const SecondaryInInputGroup: Story = {
+ render: () => {
+ const options = [
+ {value: 'all', label: 'All platforms'},
+ {value: 'ios', label: 'iOS'},
+ {value: 'android', label: 'Android'},
+ ];
+ const selector = (label: string) => (
+ <Selector
+ label={label}
+ isLabelHidden
+ variant="secondary"
+ options={options}
+ value="all"
+ onChange={() => {}}
+ />
+ );
+ return (
+ <div
+ data-secondary-input-group-matrix
+ style={{display: 'grid', gap: 16, width: 320}}>
+ <InputGroup label="Secondary first" isLabelHidden>
+ {selector('Platform first')}
+ <InputGroupText>.app</InputGroupText>
+ </InputGroup>
+ <InputGroup label="Secondary middle" isLabelHidden>
+ <InputGroupText>@</InputGroupText>
+ {selector('Platform middle')}
+ <InputGroupText>.app</InputGroupText>
+ </InputGroup>
+ <InputGroup label="Secondary last" isLabelHidden>
+ <InputGroupText>@</InputGroupText>
+ {selector('Platform last')}
+ </InputGroup>
+ </div>
+ );
+ },
+ decorators: [Story => <Story />],
+};
+
// With status
export const WithStatus: Story = {
render: () => {
diff --git a/packages/core/src/ComplexSelector/ComplexSelector.doc.mjs b/packages/core/src/ComplexSelector/ComplexSelector.doc.mjs
index b8faf16a4a..f0d0406f53 100644
--- a/packages/core/src/ComplexSelector/ComplexSelector.doc.mjs
+++ b/packages/core/src/ComplexSelector/ComplexSelector.doc.mjs
@@ -146,8 +146,9 @@ export const docs = {
name: 'statusVariant',
type: "'attached' | 'detached' | 'tooltip'",
description:
- 'How the status message is placed relative to the input. attached overlaps directly below the input (bordered treatment; detached when variant is ghost); detached floats below as a separate element with spacing; tooltip reveals the message in an info-tip button.',
- default: "'attached'",
+ 'How the status message is placed relative to the input. attached overlaps directly below the input (bordered treatment; detached when variant is secondary or ghost); detached floats below as a separate element with spacing; tooltip reveals the message in an info-tip button.',
+ default:
+ "'attached' for input selectors; 'detached' for secondary and ghost selectors",
},
{
name: 'size',
@@ -157,9 +158,9 @@ export const docs = {
},
{
name: 'variant',
- type: "'input' | 'ghost'",
+ type: "'input' | 'secondary' | 'ghost'",
description:
- 'Visual trigger style. Input is the bordered form treatment; ghost matches toolbar buttons.',
+ '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.',
default: "'input'",
},
{
@@ -264,7 +265,7 @@ export const docs = {
{
guidance: true,
description:
- 'Use variant="ghost" with a startIcon when the selector is triggered from a toolbar. Use alignment="end" when a wide surface should align its end edge to the trigger.',
+ 'Use variant="secondary" beside secondary buttons, or variant="ghost" beside ghost buttons; add a startIcon when it helps identify the trigger. Use alignment="end" when a wide surface should align its end edge to the trigger.',
},
{
guidance: true,
@@ -316,7 +317,7 @@ export const docsDense = {
group: 'Selector',
category: 'Form Controls',
description:
- 'Input/ghost trigger + dialog-popover shell for rich custom selectors. Content gets value/onChange/close/state; content owns semantics. Use focus hooks and evaluate custom content against WCAG 2.2.',
+ 'Input/secondary/ghost trigger + dialog-popover shell for rich custom selectors. Content gets value/onChange/close/state; content owns semantics. Use focus hooks and evaluate custom content against WCAG 2.2.',
usage: {
anatomy,
description:
@@ -376,7 +377,8 @@ export const docsDense = {
changeAction: 'Async action after onChange; drives optimistic value/busy.',
children: 'Render custom dialog content from (value,onChange,close,state).',
triggerLabel: 'Closed trigger label/content.',
- variant: 'input for forms; ghost for toolbar triggers.',
+ variant:
+ 'input for forms; secondary beside secondary buttons; ghost beside ghost buttons.',
startIcon: 'Leading trigger icon.',
placement: 'Popup placement.',
alignment: 'Popup alignment.',
@@ -397,7 +399,7 @@ export const docsDense = {
controlClassName: 'Class name for the visual control box.',
controlStyle: 'Inline styles for the visual control box.',
statusVariant:
- 'How status message is placed: attached overlaps below input (detached for ghost); detached floats below w/ spacing; tooltip shows on status icon.',
+ 'How status message is placed: attached overlaps below input (detached for secondary and ghost); detached floats below w/ spacing; tooltip shows on status icon.',
accessibility:
'Custom content must provide its own accessible structure. Use focus hooks and evaluate against WCAG 2.2.',
},
diff --git a/packages/core/src/ComplexSelector/ComplexSelector.test.tsx b/packages/core/src/ComplexSelector/ComplexSelector.test.tsx
index eb03226553..0104a1f1aa 100644
--- a/packages/core/src/ComplexSelector/ComplexSelector.test.tsx
+++ b/packages/core/src/ComplexSelector/ComplexSelector.test.tsx
@@ -262,6 +262,51 @@ describe('ComplexSelector', () => {
).toHaveLength(2);
});
+ it('applies distinct trigger chrome to the secondary variant', () => {
+ // data-testid reaches the native control; the variant is on the trigger root.
+ const triggerRoot = () =>
+ screen
+ .getByTestId('view-options')
+ .closest('.astryx-complex-selector') as HTMLElement;
+ const {rerender} = render(
+ <ComplexSelector
+ label="View options"
+ value={['name']}
+ variant="input"
+ data-testid="view-options">
+ {() => <div>Columns</div>}
+ </ComplexSelector>,
+ );
+ const inputClasses = triggerRoot().className;
+
+ rerender(
+ <ComplexSelector
+ label="View options"
+ value={['name']}
+ variant="secondary"
+ data-testid="view-options">
+ {() => <div>Columns</div>}
+ </ComplexSelector>,
+ );
+ const secondary = triggerRoot();
+ const secondaryClasses = secondary.className;
+ expect(secondary).toHaveAttribute('data-variant', 'secondary');
+
+ rerender(
+ <ComplexSelector
+ label="View options"
+ value={['name']}
+ variant="ghost"
+ data-testid="view-options">
+ {() => <div>Columns</div>}
+ </ComplexSelector>,
+ );
+ const ghostClasses = triggerRoot().className;
+
+ expect(secondaryClasses).not.toBe(inputClasses);
+ expect(secondaryClasses).not.toBe(ghostClasses);
+ });
+
it('supports end-aligned popup positioning', () => {
render(
<ComplexSelector label="View options" value={[]} alignment="end">
@@ -721,22 +766,25 @@ describe('ComplexSelector onOpenChange', () => {
);
});
- it('forces detached when variant="ghost" even if statusVariant="attached"', () => {
- const {container} = render(
- <ComplexSelector
- label="Filter"
- value={[]}
- variant="ghost"
- status={{type: 'error', message: 'Required'}}
- statusVariant="attached">
- {() => <button type="button">Apply</button>}
- </ComplexSelector>,
- );
- expect(container.querySelector('.astryx-field-status')).toHaveAttribute(
- 'data-variant',
- 'detached',
- );
- });
+ it.each(['secondary', 'ghost'] as const)(
+ 'forces detached when variant="%s" even if statusVariant="attached"',
+ variant => {
+ const {container} = render(
+ <ComplexSelector
+ label="Filter"
+ value={[]}
+ variant={variant}
+ status={{type: 'error', message: 'Required'}}
+ statusVariant="attached">
+ {() => <button type="button">Apply</button>}
+ </ComplexSelector>,
+ );
+ expect(container.querySelector('.astryx-field-status')).toHaveAttribute(
+ 'data-variant',
+ 'detached',
+ );
+ },
+ );
it('renders no message box for statusVariant="tooltip"', () => {
const {container} = render(
diff --git a/packages/core/src/ComplexSelector/ComplexSelector.tsx b/packages/core/src/ComplexSelector/ComplexSelector.tsx
index abf4a9040c..1e8907fa16 100644
--- a/packages/core/src/ComplexSelector/ComplexSelector.tsx
+++ b/packages/core/src/ComplexSelector/ComplexSelector.tsx
@@ -5,7 +5,7 @@
/**
* @file ComplexSelector.tsx
* @input Uses React, StyleX, Field, Icon slots, Layer positioning, and usePopover
- * @output Exports a rich-selector shell with exact token-sized input and ghost triggers, plus an imperative open/close handle
+ * @output Exports a rich-selector shell with exact token-sized input, secondary, and ghost triggers, plus an imperative open/close handle
* @position Core implementation; consumed by index.ts
*
* SYNC: When modified, update:
@@ -151,6 +151,31 @@ const styles = stylex.create({
'[data-astryx-press="on"]': 'scale(0.98)',
},
},
+ // Keep the input-family width contract while reusing ghost's borderless paint
+ // and the neutral resting fill used by secondary buttons.
+ triggerSecondary: {
+ borderWidth: 0,
+ backgroundColor: colorVars['--color-neutral'],
+ boxShadow: {
+ default: 'none',
+ ':hover:not(:focus-within):where(:not(:disabled,[aria-disabled="true"]))':
+ {
+ '@media (hover: hover)': 'none',
+ },
+ ':focus-within': 'none',
+ },
+ fontWeight: fontWeightVars['--font-weight-medium'],
+ transitionProperty:
+ 'background-image, background-color, color, opacity, transform',
+ transform: {
+ default: 'scale(1)',
+ ':active': {
+ default: 'scale(0.98)',
+ '@media (pointer: coarse)': 'scale(1)',
+ },
+ '[data-astryx-press="on"]': 'scale(0.98)',
+ },
+ },
triggerGhostDisabled: {
backgroundImage: 'none',
transform: {
@@ -202,7 +227,7 @@ const styles = stylex.create({
},
});
-export type ComplexSelectorVariant = 'input' | 'ghost';
+export type ComplexSelectorVariant = 'input' | 'secondary' | 'ghost';
export type ComplexSelectorSize = 'sm' | 'md' | 'lg';
@@ -338,17 +363,20 @@ export interface ComplexSelectorProps<Value> extends Omit<
status?: ComplexSelectorStatus;
/**
* How the status message is placed relative to the input.
- * - 'attached': message overlaps directly below the input (bordered treatment; detached when variant is ghost)
+ * - 'attached': message overlaps directly below the input (bordered treatment; detached when variant is secondary or ghost)
* - 'detached': message floats below as a separate element with spacing
* - 'tooltip': no message box; the status icon becomes a focusable info-tip button that reveals the message on hover, keyboard focus, or tap
- * @default 'attached'
+ * @default 'attached' for input selectors; 'detached' for secondary and ghost selectors
*/
statusVariant?: FieldStatusVariant;
/** Tooltip text displayed next to the label. */
labelTooltip?: string;
/** Trigger and field size. */
size?: ComplexSelectorSize;
- /** Visual trigger style. Ghost matches toolbar buttons. */
+ /**
+ * Visual trigger style. Secondary matches secondary buttons; ghost matches
+ * ghost buttons.
+ */
variant?: ComplexSelectorVariant;
/** Icon displayed at the start of the trigger. */
startIcon?: ReactNode | IconType;
@@ -494,7 +522,7 @@ export function ComplexSelector<Value>({
const isEffectivelyRequired = useResolvedRequired({isRequired, isOptional});
const placeholder = placeholderFromProps ?? t('@astryx.selector.placeholder');
const effectiveStatusVariant =
- variant === 'ghost' && statusVariant === 'attached'
+ variant !== 'input' && statusVariant === 'attached'
? 'detached'
: statusVariant;
@@ -709,10 +737,11 @@ export function ComplexSelector<Value>({
// matched a mouse click on the trigger and drew the outline for
// pointer users too. `focusWithin` here is `:has(:focus-visible)`.
focusOutlineStyles.focusWithin,
+ variant === 'secondary' && styles.triggerSecondary,
variant === 'ghost' && styles.triggerGhost,
- variant === 'ghost' && interactionOverlayStyles.backgroundImage,
+ variant !== 'input' && interactionOverlayStyles.backgroundImage,
isDisabled && inputWrapperStyles.disabled,
- variant === 'ghost' && isDisabled && styles.triggerGhostDisabled,
+ variant !== 'input' && isDisabled && styles.triggerGhostDisabled,
isDisabled && styles.disabled,
triggerLabel == null && styles.placeholder,
controlXstyle,
diff --git a/packages/core/src/MultiSelector/MultiSelector.doc.mjs b/packages/core/src/MultiSelector/MultiSelector.doc.mjs
index aa6ce1d5d4..a9cc737fcd 100644
--- a/packages/core/src/MultiSelector/MultiSelector.doc.mjs
+++ b/packages/core/src/MultiSelector/MultiSelector.doc.mjs
@@ -214,9 +214,9 @@ export const docs = {
},
{
name: 'variant',
- type: "'input' | 'ghost'",
+ type: "'input' | 'secondary' | 'ghost'",
description:
- 'Visual trigger style. input is the bordered input treatment for forms; ghost is borderless and matches ghost buttons for toolbar usage.',
+ '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.',
default: "'input'",
},
{
@@ -340,9 +340,9 @@ export const docs = {
name: 'statusVariant',
type: "'attached' | 'detached' | 'tooltip'",
description:
- 'How the status message is placed relative to the input. attached overlaps directly below the bordered input and is only valid for the input variant; ghost selectors detach attached status messages by default. Use tooltip for compact toolbar controls.',
+ 'How the status message is placed relative to the input. attached overlaps directly below the bordered input and is only valid for the input variant; secondary and ghost selectors detach attached status messages by default. Use tooltip for compact toolbar controls.',
default:
- "'attached' for input selectors; 'detached' for ghost selectors",
+ "'attached' for input selectors; 'detached' for secondary and ghost selectors",
},
{
name: 'renderOption',
@@ -493,7 +493,7 @@ export const docs = {
{
guidance: true,
description:
- 'Use variant="ghost" when a multi-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 multi-selector sits beside secondary buttons or segmented controls, and variant="ghost" when it sits beside ghost buttons. If validation status is needed there, prefer statusVariant="tooltip" so the toolbar height stays compact.',
},
{
guidance: true,
@@ -661,7 +661,7 @@ export const docsDense = {
{
guidance: true,
description:
- 'Use variant="ghost" in toolbars with ghost buttons; prefer statusVariant="tooltip" for compact validation status.',
+ 'Use variant="secondary" beside secondary buttons or segmented controls and variant="ghost" beside ghost buttons; prefer statusVariant="tooltip" for compact validation status.',
},
{
guidance: false,
@@ -693,7 +693,7 @@ export const docsDense = {
placeholder: 'text when nothing selected',
size: 'size variant',
variant:
- 'visual trigger style: input bordered control or ghost toolbar control',
+ 'visual trigger style: input bordered control, secondary neutral-filled control, or ghost transparent control',
triggerDisplay: 'how to show selected in trigger',
formatValue:
'formats count/labels trigger text; receives selected items',
@@ -719,7 +719,7 @@ export const docsDense = {
isLoading: 'spinner in trigger',
status: 'validation status w/ optional message',
statusVariant:
- 'status message placement; ghost detaches attached by default; use tooltip for compact toolbars.',
+ 'status message placement; secondary and ghost detach attached by default; use tooltip for compact toolbars.',
renderOption:
'custom render fn per selectable option; not dividers/sections/select-all',
renderTrigger:
diff --git a/packages/core/src/MultiSelector/MultiSelector.test.tsx b/packages/core/src/MultiSelector/MultiSelector.test.tsx
index 8d713dd644..d461bedee9 100644
--- a/packages/core/src/MultiSelector/MultiSelector.test.tsx
+++ b/packages/core/src/MultiSelector/MultiSelector.test.tsx
@@ -33,6 +33,8 @@ import {__resetInteractionModalityForTest} from '../utils/interactionModality';
import {defineTheme} from '../theme/defineTheme';
import {generateThemeCSS} from '../theme/generateThemeRules';
import {selectorPresentationStyles} from '../Selector/selectorPresentation.stylex';
+import {groupStyles} from '../InputGroup/groupStyles';
+import {InputGroup, InputGroupText} from '../InputGroup';
function generateThemeTestCSS(theme: Parameters<typeof generateThemeCSS>[0]) {
const {prose, component} = generateThemeCSS(theme);
@@ -219,6 +221,54 @@ describe('MultiSelector', () => {
expect(screen.getByLabelText('Fruit')).toBeInTheDocument();
});
+ it('applies distinct trigger chrome to the secondary variant', () => {
+ // data-testid reaches the native control; the variant is on the trigger root.
+ const triggerRoot = () =>
+ screen
+ .getByTestId('selector')
+ .closest('.astryx-multi-selector') as HTMLElement;
+ const {rerender} = render(
+ <MultiSelector
+ label="Fruit"
+ options={defaultOptions}
+ value={[]}
+ onChange={() => {}}
+ variant="input"
+ data-testid="selector"
+ />,
+ );
+ const inputClasses = triggerRoot().className;
+
+ rerender(
+ <MultiSelector
+ label="Fruit"
+ options={defaultOptions}
+ value={[]}
+ onChange={() => {}}
+ variant="secondary"
+ data-testid="selector"
+ />,
+ );
+ const secondary = triggerRoot();
+ const secondaryClasses = secondary.className;
+ expect(secondary).toHaveAttribute('data-variant', 'secondary');
+
+ rerender(
+ <MultiSelector
+ label="Fruit"
+ options={defaultOptions}
+ value={[]}
+ onChange={() => {}}
+ variant="ghost"
+ data-testid="selector"
+ />,
+ );
+ const ghostClasses = triggerRoot().className;
+
+ expect(secondaryClasses).not.toBe(inputClasses);
+ expect(secondaryClasses).not.toBe(ghostClasses);
+ });
+
it('renders custom option content with renderOption', async () => {
const user = userEvent.setup();
render(
@@ -2445,26 +2495,29 @@ describe('MultiSelector statusVariant forwarding', () => {
).not.toBeNull();
});
- it('detaches attached status by default for the ghost variant', () => {
- const {container} = render(
- <MultiSelector
- label="Fruit"
- options={['Apple', 'Banana']}
- value={[]}
- onChange={() => {}}
- variant="ghost"
- status={{type: 'error', message: 'Required'}}
- />,
- );
- expect(container.querySelector('.astryx-multi-selector')).toHaveAttribute(
- 'data-variant',
- 'ghost',
- );
- expect(container.querySelector('.astryx-field-status')).toHaveAttribute(
- 'data-variant',
- 'detached',
- );
- });
+ it.each(['secondary', 'ghost'] as const)(
+ 'detaches attached status by default for the %s variant',
+ variant => {
+ const {container} = render(
+ <MultiSelector
+ label="Fruit"
+ options={['Apple', 'Banana']}
+ value={[]}
+ onChange={() => {}}
+ variant={variant}
+ status={{type: 'error', message: 'Required'}}
+ />,
+ );
+ expect(container.querySelector('.astryx-multi-selector')).toHaveAttribute(
+ 'data-variant',
+ variant,
+ );
+ expect(container.querySelector('.astryx-field-status')).toHaveAttribute(
+ 'data-variant',
+ 'detached',
+ );
+ },
+ );
it('uses a status tooltip for ghost multi-selectors when requested', () => {
const {container} = render(
@@ -4255,3 +4308,68 @@ describe('MultiSelector create row inside a grid', () => {
});
});
});
+
+describe('MultiSelector in an InputGroup', () => {
+ const groupClasses = () =>
+ stylex.props(groupStyles.inGroup).className!.split(' ');
+ const triggerBox = (name: RegExp) =>
+ screen
+ .getByRole('combobox', {name})
+ .closest('.astryx-multi-selector') as HTMLElement;
+
+ it.each(['input', 'secondary'] as const)(
+ 'gives a grouped %s trigger the connected group geometry in every position',
+ variant => {
+ const selector = (label: string) => (
+ <MultiSelector
+ label={label}
+ isLabelHidden
+ variant={variant}
+ options={['Apple', 'Banana', 'Cherry']}
+ value={EMPTY_VALUE}
+ onChange={() => {}}
+ />
+ );
+ render(
+ <>
+ <InputGroup label="First">
+ {selector('Fruit first')}
+ <InputGroupText>kg</InputGroupText>
+ </InputGroup>
+ <InputGroup label="Middle">
+ <InputGroupText>#</InputGroupText>
+ {selector('Fruit middle')}
+ <InputGroupText>kg</InputGroupText>
+ </InputGroup>
+ <InputGroup label="Last">
+ <InputGroupText>#</InputGroupText>
+ {selector('Fruit last')}
+ </InputGroup>
+ </>,
+ );
+
+ // Row height, seam radii, and focus stacking come from these classes;
+ // a secondary trigger keeps its fill but not its standalone edges.
+ for (const position of ['first', 'middle', 'last']) {
+ const classes = new Set(
+ triggerBox(new RegExp(`Fruit ${position}`)).className.split(' '),
+ );
+ expect(groupClasses().every(c => classes.has(c))).toBe(true);
+ }
+ },
+ );
+
+ it('keeps a standalone secondary trigger out of the group geometry', () => {
+ render(
+ <MultiSelector
+ label="Fruit"
+ variant="secondary"
+ options={['Apple', 'Banana', 'Cherry']}
+ value={EMPTY_VALUE}
+ onChange={() => {}}
+ />,
+ );
+ const classes = new Set(triggerBox(/Fruit/).className.split(' '));
+ expect(groupClasses().some(c => classes.has(c))).toBe(false);
+ });
+});
diff --git a/packages/core/src/MultiSelector/MultiSelector.tsx b/packages/core/src/MultiSelector/MultiSelector.tsx
index 0d92344e7f..4df4938cc1 100644
--- a/packages/core/src/MultiSelector/MultiSelector.tsx
+++ b/packages/core/src/MultiSelector/MultiSelector.tsx
@@ -5,13 +5,14 @@
/**
* @file MultiSelector.tsx
* @input Uses React, StyleX, usePopover, useTooltip, CheckboxInput, Field, Badge, Icon, InputGroupContext
- * @output Exports MultiSelector component
+ * @output Exports MultiSelector with input, secondary, and ghost trigger variants
* @position Core implementation; consumed by index.ts
*
* SYNC: When modified, update:
* - /packages/core/src/MultiSelector/MultiSelector.doc.mjs
* - /packages/core/src/MultiSelector/MultiSelector.test.tsx
* - /packages/core/src/MultiSelector/index.ts
+ * - /apps/storybook/stories/MultiSelector.stories.tsx
* - /apps/storybook/stories/InputGroup.stories.tsx
* - /packages/cli/assets/templates/blocks/components/MultiSelector/ (showcase blocks)
*/
@@ -241,6 +242,31 @@ const styles = stylex.create({
'[data-astryx-press="on"]': 'scale(0.98)',
},
},
+ // Keep the input-family width contract while reusing ghost's borderless paint
+ // and the neutral resting fill used by secondary buttons.
+ triggerSecondary: {
+ borderWidth: 0,
+ backgroundColor: colorVars['--color-neutral'],
+ boxShadow: {
+ default: 'none',
+ ':hover:not(:focus-within):where(:not(:disabled,[aria-disabled="true"]))':
+ {
+ '@media (hover: hover)': 'none',
+ },
+ ':focus-within': 'none',
+ },
+ fontWeight: fontWeightVars['--font-weight-medium'],
+ transitionProperty:
+ 'background-image, background-color, color, opacity, transform',
+ transform: {
+ default: 'scale(1)',
+ ':active': {
+ default: 'scale(0.98)',
+ '@media (pointer: coarse)': 'scale(1)',
+ },
+ '[data-astryx-press="on"]': 'scale(0.98)',
+ },
+ },
triggerGhostDisabled: {
backgroundImage: 'none',
transform: {
@@ -494,7 +520,7 @@ const STATUS_BUTTON_LABEL_KEY: Record<MultiSelectorStatusType, string> = {
export type MultiSelectorSize = 'sm' | 'md' | 'lg';
-export type MultiSelectorVariant = 'input' | 'ghost';
+export type MultiSelectorVariant = 'input' | 'secondary' | 'ghost';
export type MultiSelectorPresentation = AdaptivePresentation;
@@ -736,7 +762,8 @@ export interface MultiSelectorProps<
/**
* Visual style of the selector trigger.
* - 'input': bordered input-style trigger for forms
- * - 'ghost': borderless trigger matching ghost buttons, for toolbars
+ * - 'secondary': borderless, neutral-filled trigger matching secondary buttons
+ * - 'ghost': borderless, transparent trigger matching ghost buttons
* @default 'input'
*/
variant?: MultiSelectorVariant;
@@ -750,7 +777,7 @@ export interface MultiSelectorProps<
* - 'attached': message overlaps directly below the bordered input (input variant only)
* - 'detached': message floats below as a separate element with spacing
* - 'tooltip': message is exposed from the on-field status icon
- * @default 'attached' for input selectors; 'detached' for ghost selectors
+ * @default 'attached' for input selectors; 'detached' for secondary and ghost selectors
*/
statusVariant?: FieldStatusVariant;
@@ -1114,7 +1141,7 @@ export function MultiSelector<T extends MultiSelectorOptionType>({
emptySearchTextFromProps ?? t('@astryx.multiSelector.emptySearchResults');
const size = useSize(sizeProp, 'md');
const effectiveStatusVariant =
- variant === 'ghost' && statusVariant === 'attached'
+ variant !== 'input' && statusVariant === 'attached'
? 'detached'
: statusVariant;
const isEffectivelyReadOnly = isReadOnly && !isDisabled;
@@ -2473,25 +2500,28 @@ export function MultiSelector<T extends MultiSelectorOptionType>({
inputWrapperStyles.base,
styles.triggerContainer,
sizeStyles[size],
+ variant === 'secondary' && styles.triggerSecondary,
variant === 'ghost' && styles.triggerGhost,
- variant === 'ghost' && interactionOverlayStyles.backgroundImage,
- variant === 'ghost' && focusOutlineStyles.focusWithin,
+ variant !== 'input' && interactionOverlayStyles.backgroundImage,
+ variant !== 'input' && focusOutlineStyles.focusWithin,
surface.isTriggerFocusRingSuppressed &&
selectorPresentationStyles.pointerRestoredFocus,
isDisabled && inputWrapperStyles.disabled,
isEffectivelyReadOnly && styles.triggerReadOnly,
- variant === 'ghost' && isDisabled && styles.triggerGhostDisabled,
- variant === 'ghost' &&
+ variant !== 'input' && isDisabled && styles.triggerGhostDisabled,
+ variant !== 'input' &&
isEffectivelyReadOnly &&
styles.triggerGhostReadOnly,
optimisticValue.length === 0 && styles.triggerPlaceholder,
- variant !== 'ghost' &&
+ variant === 'input' &&
status &&
inputStatusBorderStyles[status.type],
- variant !== 'ghost' &&
+ variant === 'input' &&
status &&
!isDisabled &&
inputStatusHoverShadowStyles[status.type],
+ // Grouped secondary triggers keep their neutral fill but take the
+ // group's row height, connected edge radii, and focus stacking.
variant !== 'ghost' && inputGroup && groupStyles.inGroup,
controlXstyle,
),
diff --git a/packages/core/src/Selector/Selector.doc.mjs b/packages/core/src/Selector/Selector.doc.mjs
index b437d950d5..7ba8a431fb 100644
--- a/packages/core/src/Selector/Selector.doc.mjs
+++ b/packages/core/src/Selector/Selector.doc.mjs
@@ -245,9 +245,9 @@ export const docs = {
},
{
name: 'variant',
- type: "'input' | 'ghost'",
+ type: "'input' | 'secondary' | 'ghost'",
description:
- 'Visual trigger style. input is the bordered input treatment for forms; ghost is borderless and matches ghost buttons for toolbar usage.',
+ '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.',
default: "'input'",
},
{
@@ -307,8 +307,9 @@ export const docs = {
name: 'statusVariant',
type: "'attached' | 'detached' | 'tooltip'",
description:
- 'How the status message is placed relative to the input. attached overlaps directly below the bordered input and is only valid for the input variant; ghost selectors detach attached status messages by default. Use tooltip for compact toolbar controls.',
- default: "'attached' for input selectors; 'detached' for ghost selectors",
+ 'How the status message is placed relative to the input. attached overlaps directly below the bordered input and is only valid for the input variant; secondary and ghost selectors detach attached status messages by default. Use tooltip for compact toolbar controls.',
+ default:
+ "'attached' for input selectors; 'detached' for secondary and ghost selectors",
},
{
name: 'renderOption',
@@ -439,7 +440,7 @@ export const docs = {
{
guidance: true,
description:
- '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 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.',
},
{
guidance: true,
@@ -576,7 +577,7 @@ export const docsDense = {
{
guidance: true,
description:
- 'Use variant="ghost" in toolbars with ghost buttons; prefer statusVariant="tooltip" for compact validation status.',
+ 'Use variant="secondary" in navs/toolbars beside secondary buttons; use variant="ghost" in toolbars with ghost buttons; prefer statusVariant="tooltip" for compact validation status.',
},
{
guidance: false,
diff --git a/packages/core/src/Selector/Selector.test.tsx b/packages/core/src/Selector/Selector.test.tsx
index 592a512f9e..5b9b78bb7b 100644
--- a/packages/core/src/Selector/Selector.test.tsx
+++ b/packages/core/src/Selector/Selector.test.tsx
@@ -38,6 +38,7 @@ import {Theme} from '../theme/Theme';
import {generateThemeCSS} from '../theme/generateThemeRules';
import {spacingVars} from '../theme/tokens.stylex';
import {selectorPresentationStyles} from './selectorPresentation.stylex';
+import {groupStyles} from '../InputGroup/groupStyles';
function generateThemeTestCSS(theme: Parameters<typeof generateThemeCSS>[0]) {
const {prose, component} = generateThemeCSS(theme);
@@ -605,7 +606,7 @@ describe('Selector', () => {
const inputDropdownClass = screen.getByRole('listbox', h).className;
unmount();
- render(
+ const ghostRender = render(
<Selector
label="Ghost fruit"
options={OPTIONS}
@@ -616,10 +617,24 @@ describe('Selector', () => {
);
await user.click(screen.getByRole('combobox'));
const ghostDropdownClass = screen.getByRole('listbox', h).className;
+ ghostRender.unmount();
+
+ render(
+ <Selector
+ label="Secondary fruit"
+ options={OPTIONS}
+ value="Banana"
+ variant="secondary"
+ onChange={() => {}}
+ />,
+ );
+ await user.click(screen.getByRole('combobox'));
+ const secondaryDropdownClass = screen.getByRole('listbox', h).className;
// The bordered input gets one extra StyleX rule for its border-width
- // correction; the borderless ghost keeps the base menu inset.
+ // correction; the borderless secondary/ghost keep the base menu inset.
expect(inputDropdownClass).not.toBe(ghostDropdownClass);
+ expect(secondaryDropdownClass).toBe(ghostDropdownClass);
});
it('does not apply selected-item overlay offset when placement is explicit', async () => {
@@ -2500,6 +2515,67 @@ describe('Selector', () => {
expect(screen.getByText('#')).toBeInTheDocument();
});
+ it.each(['input', 'secondary'] as const)(
+ 'gives a grouped %s trigger the connected group geometry in every position',
+ variant => {
+ const groupClasses = stylex
+ .props(groupStyles.inGroup)
+ .className!.split(' ');
+ const selector = (label: string) => (
+ <Selector
+ label={label}
+ isLabelHidden
+ variant={variant}
+ options={OPTIONS}
+ />
+ );
+ render(
+ <>
+ <InputGroup label="First">
+ {selector('Channel first')}
+ <InputGroupText>#</InputGroupText>
+ </InputGroup>
+ <InputGroup label="Middle">
+ <InputGroupText>#</InputGroupText>
+ {selector('Channel middle')}
+ <InputGroupText>@</InputGroupText>
+ </InputGroup>
+ <InputGroup label="Last">
+ <InputGroupText>#</InputGroupText>
+ {selector('Channel last')}
+ </InputGroup>
+ </>,
+ );
+
+ // The group's row height, seam radii, and focus stacking all come from
+ // these classes; their :first-child and last-item selectors resolve the
+ // position. A secondary trigger keeps its fill but must not keep its
+ // own standalone edges or width.
+ for (const position of ['first', 'middle', 'last']) {
+ const trigger = screen.getByRole('combobox', {
+ name: new RegExp(`Channel ${position}`),
+ });
+ const box = trigger.closest('.astryx-selector') as HTMLElement;
+ const classes = new Set(box.className.split(' '));
+ expect(groupClasses.every(c => classes.has(c))).toBe(true);
+ }
+ },
+ );
+
+ it('keeps a standalone secondary trigger out of the group geometry', () => {
+ const groupClasses = stylex
+ .props(groupStyles.inGroup)
+ .className!.split(' ');
+ render(
+ <Selector label="Channel" variant="secondary" options={OPTIONS} />,
+ );
+ const box = screen
+ .getByRole('combobox')
+ .closest('.astryx-selector') as HTMLElement;
+ const classes = new Set(box.className.split(' '));
+ expect(groupClasses.some(c => classes.has(c))).toBe(false);
+ });
+
it('keeps disabled reasons described when grouped', () => {
render(
<InputGroup label="Destination">
@@ -3135,6 +3211,48 @@ describe('Selector statusVariant forwarding', () => {
);
});
+ it('detaches attached status by default for the secondary variant', () => {
+ const {container} = render(
+ <Selector
+ label="Fruit"
+ options={['Apple', 'Banana']}
+ variant="secondary"
+ status={{type: 'error', message: 'Required'}}
+ />,
+ );
+ expect(container.querySelector('.astryx-selector')).toHaveAttribute(
+ 'data-variant',
+ 'secondary',
+ );
+ expect(container.querySelector('.astryx-field-status')).toHaveAttribute(
+ 'data-variant',
+ 'detached',
+ );
+ });
+
+ it('paints the secondary trigger with its own trigger style', () => {
+ const inputRender = render(
+ <Selector label="Fruit" options={['Apple', 'Banana']} value="Banana" />,
+ );
+ const inputTriggerClass =
+ inputRender.container.querySelector('.astryx-selector')!.className;
+ inputRender.unmount();
+
+ const secondaryRender = render(
+ <Selector
+ label="Fruit"
+ options={['Apple', 'Banana']}
+ value="Banana"
+ variant="secondary"
+ />,
+ );
+ // The neutral-filled secondary trigger must not reuse the bordered
+ // input trigger's classes; it carries the secondary trigger style.
+ expect(
+ secondaryRender.container.querySelector('.astryx-selector')!.className,
+ ).not.toBe(inputTriggerClass);
+ });
+
it('uses a status tooltip for ghost selectors when requested', () => {
const {container} = render(
<Selector
diff --git a/packages/core/src/Selector/Selector.tsx b/packages/core/src/Selector/Selector.tsx
index 5e12ce9f10..cbce9ea6e8 100644
--- a/packages/core/src/Selector/Selector.tsx
+++ b/packages/core/src/Selector/Selector.tsx
@@ -6,7 +6,7 @@
* @file Selector.tsx
* @input Uses React, StyleX, adaptive selection surfaces, theme-resolved
* indicators, Field, and InputGroup context
- * @output Exports Selector with content-derived option-mark layout and token-sized single-line triggers
+ * @output Exports Selector with input, secondary, and ghost trigger treatments, content-derived option-mark layout, and token-sized single-line triggers
* @position Core implementation; consumed by index.ts
*
* SYNC: When modified, update:
@@ -260,6 +260,37 @@ const styles = stylex.create({
'[data-astryx-press="on"]': 'scale(0.98)',
},
},
+ // Secondary is ghost's chrome with the resting fill of a secondary
+ // button (`--color-neutral`): no border, no shadow, content width, so a
+ // selector in a nav reads as the sibling of the secondary buttons and
+ // segmented controls beside it instead of as a form field. The hover and
+ // pressed answers still come from the shared interaction overlay, layered
+ // over the fill via backgroundImage.
+ triggerSecondary: {
+ width: 'auto',
+ borderWidth: 0,
+ lineHeight: `max(${spacingVars['--spacing-5']}, 20px, 1rem)`,
+ backgroundColor: colorVars['--color-neutral'],
+ boxShadow: {
+ default: 'none',
+ ':hover:not(:focus-within):where(:not(:disabled,[aria-disabled="true"]))':
+ {
+ '@media (hover: hover)': 'none',
+ },
+ ':focus-within': 'none',
+ },
+ fontWeight: fontWeightVars['--font-weight-medium'],
+ transitionProperty:
+ 'background-image, background-color, color, opacity, transform',
+ transform: {
+ default: 'scale(1)',
+ ':active': {
+ default: 'scale(0.98)',
+ '@media (pointer: coarse)': 'scale(1)',
+ },
+ '[data-astryx-press="on"]': 'scale(0.98)',
+ },
+ },
triggerGhostDisabled: {
backgroundImage: 'none',
transform: {
@@ -311,7 +342,7 @@ const styles = stylex.create({
},
dropdownInput: {
// The input trigger's text inset includes its border. Mirror that extra
- // pixel in the menu; the borderless ghost variant needs no correction.
+ // pixel in the menu; the borderless secondary/ghost variants need no correction.
paddingInline: `calc(${spacingVars['--spacing-1']} + ${borderVars['--border-width']})`,
},
// Scroll ownership by the browser's own signal, as the menus declare it: a
@@ -512,7 +543,7 @@ const STATUS_BUTTON_LABEL_KEY: Record<SelectorStatusType, string> = {
export type SelectorSize = 'sm' | 'md' | 'lg';
-export type SelectorVariant = 'input' | 'ghost';
+export type SelectorVariant = 'input' | 'secondary' | 'ghost';
export type SelectorPresentation = AdaptivePresentation;
@@ -655,6 +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
* - 'ghost': borderless trigger matching ghost buttons, for toolbars
* @default 'input'
*/
@@ -671,7 +705,7 @@ interface SelectorPropsBase<
* - 'attached': message overlaps directly below the bordered input (input variant only)
* - 'detached': message floats below as a separate element with spacing
* - 'tooltip': message is exposed from the on-field status icon
- * @default 'attached' for input selectors; 'detached' for ghost selectors
+ * @default 'attached' for input selectors; 'detached' for secondary/ghost selectors
*/
statusVariant?: FieldStatusVariant;
@@ -957,7 +991,7 @@ export function Selector<T extends SelectorOptionType>(
const hasClear = hasClearProp === true;
const size = useSize(sizeProp, 'md');
const effectiveStatusVariant =
- variant === 'ghost' && statusVariant === 'attached'
+ variant !== 'input' && statusVariant === 'attached'
? 'detached'
: statusVariant;
const isEffectivelyReadOnly = isReadOnly && !isDisabled;
@@ -1416,7 +1450,7 @@ export function Selector<T extends SelectorOptionType>(
{...themeProps('selector-search')}
xstyle={
surface.activePresentation === 'popover' &&
- variant !== 'ghost' &&
+ variant === 'input' &&
styles.searchRowInput
}
// When hasSearch is set, focus moves into this input on open, so it —
@@ -1761,7 +1795,7 @@ export function Selector<T extends SelectorOptionType>(
? styles.touchPanYPinchZoom
: styles.touchPinchZoom,
surface.activePresentation === 'popover' &&
- variant !== 'ghost' &&
+ variant === 'input' &&
styles.dropdownInput,
)}>
{renderOptions()}
@@ -1799,7 +1833,7 @@ export function Selector<T extends SelectorOptionType>(
styles.dropdown,
listboxHasOverflow ? styles.touchPanYPinchZoom : styles.touchPinchZoom,
surface.activePresentation === 'popover' &&
- variant !== 'ghost' &&
+ variant === 'input' &&
styles.dropdownInput,
surface.activePresentation === 'popover' &&
!isPositioned &&
@@ -1892,24 +1926,27 @@ export function Selector<T extends SelectorOptionType>(
styles.triggerContainer,
sizeStyles[size],
variant === 'ghost' && styles.triggerGhost,
- variant === 'ghost' && interactionOverlayStyles.backgroundImage,
- variant === 'ghost' && focusOutlineStyles.focusWithin,
+ variant === 'secondary' && styles.triggerSecondary,
+ variant !== 'input' && interactionOverlayStyles.backgroundImage,
+ variant !== 'input' && focusOutlineStyles.focusWithin,
surface.isTriggerFocusRingSuppressed &&
selectorPresentationStyles.pointerRestoredFocus,
isDisabled && inputWrapperStyles.disabled,
isEffectivelyReadOnly && styles.triggerReadOnly,
- variant === 'ghost' && isDisabled && styles.triggerGhostDisabled,
- variant === 'ghost' &&
+ variant !== 'input' && isDisabled && styles.triggerGhostDisabled,
+ variant !== 'input' &&
isEffectivelyReadOnly &&
styles.triggerGhostReadOnly,
!selectedItem && styles.triggerPlaceholder,
- variant !== 'ghost' &&
+ variant === 'input' &&
status &&
inputStatusBorderStyles[status.type],
- variant !== 'ghost' &&
+ variant === 'input' &&
status &&
!isDisabled &&
inputStatusHoverShadowStyles[status.type],
+ // Grouped secondary triggers keep their neutral fill but take the
+ // group's row height, connected edge radii, and focus stacking.
variant !== 'ghost' && inputGroup && groupStyles.inGroup,
inputGroup && styles.triggerInGroup,
controlXstyle,