shadcn.io is not affiliated with official shadcn/ui
Stacked Referral Invite Banner Block for React
A referral card for a savings app: a heading, two reward cells (You get, A friend gets) joined by an arrow, and the invite link in a field with a Copy link button.
Installation
Overview
A referral card for React with Base UI, for a programme where both sides win. A framed card with + marks on its corners opens with a heading and one sentence. Under them, two reward cells on a shared hairline read "You get" and "A friend gets", ten dollars each, with an arrow in a circle between them that turns around in right-to-left layouts. At the foot, the visitor's invite link sits in a field with the catalog's Copy Button: pressing it copies the link, swaps the copy icon for a check, and tells screen readers "Invite link copied". There's no primary colour: the link and its button are the action. It's built from Guides and Copy Button with a Lucide icon and your theme's tokens for every colour. For savings, banking and subscription apps, and any growth surface where the offer is symmetrical.
FAQ
How do I change the reward?
Edit REWARD at the top of the file: both cells and the heading read it, so they can never disagree. For different amounts on the two sides, give each entry of SIDES its own amount and show it in RewardCell; keep the price in a dir="ltr" span so the currency sign stays beside its digits in right-to-left layouts.
Where does the invite link come from?
Your server makes one per visitor and passes it in, so the card stays presentational: replace INVITE_URL with it. The field shows it in a mono face on one line, cut with an ellipsis when it's too long for a phone, and the button copies the whole string. The link text is always read left to right, even on a right-to-left page.
What happens when the clipboard is blocked?
The Copy Button catches the refusal (a page not served over HTTPS has no clipboard, and a browser may deny permission), shows a cross for three seconds and tells screen readers "Couldn't copy". The link stays selectable in the field, so the visitor can copy it by hand. Pass onCopyError to the button to offer another way, such as the system share sheet.
Can it open the share sheet instead?
Yes: call navigator.share({ url: INVITE_URL }) where the browser has it (check typeof navigator.share === "function" after the first render, so the server and the browser agree) and keep the copy button as the fallback. The block keeps to one button so the choice is clear.
Related
- Pro
Copy Link Share CTA
Forms and captureA band call to action for a referral programme that follows your theme: the pitch beside a read-only invite field with a Shine Button that copies it, real email and system share links, and a closing band counting invites.
- Pro
Centered Stacked Banner
Stacked cardsA centred bonus offer for a music-learning app: a gift tile, a Limited time badge, a heading, a strip of fifteen month cells with the last three outlined as free, and a Shine Button.
- Pro
Stacked Download Card Banner
Stacked cardsA centred download card for a desktop sketching app: a version badge, a heading and a sentence over a tinted band with a three-platform segment control and a download button that runs idle, downloading and done.
- a1f9c2Pro
A staging pill for a deploy platform: a status dot and the environment's name, the branch and the commit hash in mono, and a copy button for the hash.
- Pro
Activity Proof Stacked Banner
Stacked cardsA centred social-proof card for a team workspace: a line saying who and how many teams upgraded this week, with the count rolling up, a sentence, a ringed avatar stack and a Shine Button.
- Pro
Achievement Ribbon Banner
Stacked cardsA centred milestone card for a running app: a corner ribbon reading Unlocked, a trophy, a heading, one sentence, a track of five pips with three earned, the next milestone named, and a Shine Button.