Skip to content

refactor: replace as prop with render prop in Text and Headline#740

Open
rohanchkrabrty wants to merge 2 commits intomainfrom
644-text-headline-render-prop
Open

refactor: replace as prop with render prop in Text and Headline#740
rohanchkrabrty wants to merge 2 commits intomainfrom
644-text-headline-render-prop

Conversation

@rohanchkrabrty
Copy link
Copy Markdown
Contributor

Summary

  • Replace the as polymorphic prop with Base UI's render prop + useRender hook in the Text and Headline components, matching the existing pattern used by the Flex component.
  • Remove brittle per-element type unions (TextSpanProps, TextDivProps, etc.) and the @ts-expect-error suppression, using useRender.ComponentProps<'span'> / useRender.ComponentProps<'h2'> instead.
  • Update the Link component (which used as='a' on Text) to use render={<a />}.
  • Update all tests, docs, playground controls, and example files to use the render prop.

Test plan

  • All Text tests pass (89 tests including 7 new render prop tests)
  • All Headline tests pass (33 tests including 7 new render prop tests)
  • All Link tests pass (12 tests)
  • TypeScript compiles cleanly for text, headline, and link components (npx tsc --noEmit)
  • Verify default tag rendering (<span> for Text, <h2> for Headline)
  • Verify render prop with JSX element (e.g., <Text render={<h1 />}>)
  • Verify render function (e.g., <Text render={(props) => <section {...props} />}>)

🤖 Generated with Claude Code

Migrate Text and Headline components from the brittle `as` polymorphic
prop pattern to Base UI's `render` prop + `useRender` hook, matching
the pattern already used by the Flex component. This eliminates manual
type unions, removes a `@ts-expect-error` suppression, and enables
rendering as any element via JSX or render functions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 14, 2026

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

Project Deployment Actions Updated (UTC)
apsara Ready Ready Preview, Comment Apr 15, 2026 9:10pm

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 14, 2026

Warning

Rate limit exceeded

@rohanchkrabrty has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 59 minutes and 3 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 59 minutes and 3 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c25c066a-6815-40e6-aa86-c76899c60307

📥 Commits

Reviewing files that changed from the base of the PR and between 26e02f6 and 440e60e.

📒 Files selected for processing (12)
  • apps/www/src/components/playground/headline-examples.tsx
  • apps/www/src/content/docs/components/headline/demo.ts
  • apps/www/src/content/docs/components/headline/index.mdx
  • apps/www/src/content/docs/components/headline/props.ts
  • apps/www/src/content/docs/components/text/demo.ts
  • apps/www/src/content/docs/components/text/index.mdx
  • apps/www/src/content/docs/components/text/props.ts
  • packages/raystack/components/headline/__tests__/headline.test.tsx
  • packages/raystack/components/headline/headline.tsx
  • packages/raystack/components/link/link.tsx
  • packages/raystack/components/text/__tests__/text.test.tsx
  • packages/raystack/components/text/text.tsx

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

The render prop accepts ReactElement values, not strings. Update
playground select options to use JSX element strings (e.g. '<h2 />')
so getPropsString generates correct `render={<h2 />}` syntax.
Also document the render prop in Headline's API Reference section.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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