Skip to content

[RFC] ComplexSelector's popup can't be styled without StyleX #4804

Closed

Description

@nynexman4464

Problem Statement

There seems to be no escape hatch for styling ComplexSelector's popup if you're not using StyleX.

The trigger is fine — className takes ordinary utility classes and works cleanly, no !important, no fighting the library. The popup has no equivalent: contentXstyle is StyleXStyles-typed, and the popup surface (the element painting background, border, radius, width) isn't reachable at all.

The surface is the one that matters, because it decides whether a popup looks like the rest of the app. In an app whose own menus are a 288px panel with a 1px border, the same menu built on ComplexSelector comes out 24px wider with no border — on a dark theme that reads as edgeless against the page.

What I tried:

Route Lands on Worked without StyleX?
className / style trigger container yes
xstyle trigger container no (StyleX)
contentXstyle content wrapper inside the surface no (StyleX)
defineTheme({components: {...}}) elements with a stable astryx-* class couldn't target it — see below
— popup surface couldn't reach it

Evidence of Demand

This hits any non-StyleX consumer styling this component, not just my app.

astryx docs styling presents StyleX, Tailwind, className, and styling-library aliases as four options, and points at className where StyleX isn't in play. The repo ships example-vite, example-nextjs, and example-nextjs-tailwind next to example-nextjs-stylex. So I expected className to be available wherever xstyle is, and the popup has neither.

Peer systems expose the popup surface directly: Radix passes className to Popover.Content, MUI has slotProps.paper, Chakra has PopoverContent as a styled slot, Ant has overlayClassName.

Why Existing Components Don't Cover This

  1. className — merges cleanly, but onto the trigger container. Checked the rendered DOM: the class lands on the trigger, and the popup surface's classes are StyleX-generated only.
  2. defineTheme({components: {'complex-selector': ...}}) — the route I most wanted, since it keeps styling in the theme. It scopes to elements carrying the component's stable class, but the popup surface's rendered attributes are just role, aria-modal, aria-label, class — no astryx-* entry to scope to. The Theming table in astryx component ComplexSelector lists astryx-complex-selector and astryx-complex-selector-indicator-icon, with no entry for the popup. The data-attribute selector approach in the styling docs needs a stable class to hang off too, so it's out for the same reason.
  3. contentXstyle — StyleX-typed, so closed to this project. It also reaches the wrapper inside the surface rather than the surface itself, so it couldn't add a border to the surface's own box even with StyleX.
  4. Swizzling — copies the component out of the library, which trades the upgrade path for a border.

What I ended up doing: the content pulls itself back out to the surface's edge with a negative margin and paints the border there. It works, but it depends on the surface's internal padding staying what it is today, so I'd rather not keep it.

Rough Approaches Considered

A — a stable class on the popup surface, e.g. astryx-complex-selector-popup, so defineTheme and the documented data-attribute selectors can reach it:

components: {
  'complex-selector-popup': {
    base: { borderWidth: '1px', borderColor: 'var(--color-border)' },
  },
}

B — a popupClassName prop, the direct analogue of the className that already covers the trigger:

<ComplexSelector popupClassName="my-panel" ...>

C — make the surface fully token-driven, so its border/radius/shadow resolve from theme tokens the host app already sets. Probably closest to "themes control what things look like," though it wouldn't help someone who needs one surface to differ from the rest.

A or C look most consistent with the system's direction. Happy to prototype whichever you prefer — or to close this if there's a route I missed.

Activity

  1. added
    enhancement
    on Aug 7, 2026
  2. changed the title [-][RFC] No styling hook reaches ComplexSelector's popup surface[/-] [+][RFC] No non-StyleX escape hatch for ComplexSelector's popup (className covers only the trigger)[/+] on Aug 7, 2026
  3. changed the title [-][RFC] No non-StyleX escape hatch for ComplexSelector's popup (className covers only the trigger)[/-] [+][RFC] No non-StyleX styling hook for ComplexSelector's popup[/+] on Aug 7, 2026
  4. changed the title [-][RFC] No non-StyleX styling hook for ComplexSelector's popup[/-] [+][RFC] ComplexSelector's popup can't be styled without StyleX[/+] on Aug 7, 2026
  5. HelloOjasMutreja commented on Aug 12, 2026

    @HelloOjasMutreja
    Contributor

    Confirming the gap and a proposed direction

    Checked this against the current source (usePopover's render in packages/core/src/Popover/usePopover.tsx) before proposing anything.

    Confirming the finding

    The popup surface is this element:

    const render = useCallback(
      (children: ReactNode, props?: ContextRenderProps): ReactNode => {
        return layer.render(
          <div
            ref={contentRef}
            role={role === 'dialog' ? 'dialog' : undefined}
            aria-modal={role === 'dialog' && isModal ? true : undefined}
            aria-label={role === 'dialog' ? dialogLabel : undefined}
            {...stylex.props(
              styles.contentWrapper,
              hasSurface && styles.surface,
              xstyle,
            )}>
            {children}
            ...

    It's correct that there's no route in: no className spread, no themeProps() call giving it a stable astryx-* class the way the trigger and indicator icon get one. ComplexSelector's own contentXstyle only reaches the content div nested inside this surface (confirmed at ComplexSelector.tsx:324), not the surface div itself, which is entirely internal to usePopover. So every popup built on usePopover (not just ComplexSelector) has this gap. It's a usePopover fix, not a ComplexSelector-local one.

    Proposed direction

    A combination of A and B, since they're cheap together and match the trigger's own precedent:

    1. Give the surface div a stable class via themeProps('popover-surface', {...}) (or similarly scoped per-component name), so defineTheme and the documented data-attribute selectors can reach it the same way astryx-complex-selector already works for the trigger.
    2. Thread an optional className through usePopover's render(children, props) (ContextRenderProps) onto that same div, mirroring how className already reaches the trigger container, so non-StyleX consumers get the same escape hatch StyleX consumers get via xstyle.

    This fixes it once for every usePopover consumer (ComplexSelector, and anything else built on the same popover surface) rather than adding a one-off prop per component. Option C (fully token-driven surface) is a good longer-term direction too, but doesn't help the "this one surface needs to differ" case the report describes, so I'd treat it as complementary rather than a substitute.

    Happy to open a draft PR for this once the direction's confirmed. This touches a shared primitive (usePopover) that other components build on, so wanted to check before sending code.

  6. nynexman4464 commented on Aug 27, 2026

    @nynexman4464
    ContributorAuthor

    Resolved by #4991 and corrected by #5009. ComplexSelector now exposes astryx-complex-selector-popup on the painted popup surface; every popover surface also carries astryx-popover-surface, so defineTheme can style the background, border, radius, elevation, and padding without StyleX or structural selectors. The corrected target shipped in @astryxdesign/core 0.4.1.

    Closing as completed. Making the layer clearance configurable is a separate API request and does not keep this popup-surface styling gap open.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions