Skip to content

feat(shared, combobox): accept a render element alongside asChild - #406

Closed
sadmann7 wants to merge 1 commit into
mainfrom
sadman/primitive-render-prop
Closed

sadmann7 wants to merge 1 commit into
mainfrom
sadman/primitive-render-prop

Conversation

@sadmann7

Copy link
Copy Markdown
Owner

When the shadcn CLI installs a component into a Base UI project, it rewrites every literal asChild into render={<Child />}. diceui's primitives only took asChild, so the Base UI registry items broke: they failed to typecheck and rendered the wrong element. Examples are the check icon going missing in ui/checkbox-group, the mention demos rendering an input instead of the textarea, and TagsInputClear losing its Button.

  • Every Primitive part in @diceui/shared accepts a render element, like Base UI's render in its element form. Props, refs, handlers, className and style merge through the same Slot that asChild uses. When the part has children, they replace the element's own; when it has none, the element keeps its own. That covers both shapes the CLI produces.
  • ComboboxArrow keeps custom content with render, the way it already did with asChild.
  • A changeset adds a minor release for @diceui/shared, checkbox-group, combobox, mention and tags-input. @diceui/listbox has its own Slot, and nothing in the registry uses asChild on it, so it's left as is.
  • Tests for render on Primitive, and for ComboboxArrow content with both asChild and render.

I checked this against the CLI's own transform (transform-aschild from @shadcn/registry). I applied it to the 8 Base UI registry files that use asChild on these primitives, then reverted them.

  • Typecheck: 11 errors in those files against main's packages, 0 with this change.
  • Rendered DOM: compared with the original asChild version, 7 of 8 files differ against main's packages, and all 8 match with this change. tags-input-demo matches either way, because Clear isn't rendered with no tags.

Faceted has the same problem with cmdk's Command.Item. That's third-party, so tablecn fixes it on its side (sadmann7/tablecn#1337), and the fix reaches diceui with the next sync.

@vercel

vercel Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
diceui Ready Ready Preview Nov 29, 2026 12:57pm UTC

Request Review

This branch was successfully deployed

1 active deployment
Preview — 619cd8c7 Deployed Nov 29, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant