shadcn.io is not affiliated with official shadcn/ui
Popover examples · Standard
Share Popover for React
A Share popover with Facebook and Twitter buttons and a link to copy.
A Share button that opens Facebook and Twitter buttons, a separator, and a read-only link with a copy button that confirms with a check. Keep sharing one click away from the content. In React, Base UI handles opening, dismissing and focus.
Preview
Installation
FAQ
How does copy link work?
The copy button writes shareUrl, https://example.com/share, to the clipboard with navigator.clipboard.writeText, then shows a check and the label Copied for two seconds before going back to Copy link. Both icons are aria-hidden, so the aria-label names the button.
How is the link field set up?
The Input has type="url", readOnly, and aria-label="Link", and its value is shareUrl. It sits in a flex gap-2 row with the icon button, which is size="icon-md" variant="outline". The line above the field says Or copy link in text-muted-foreground text-xs.
What do the Facebook and Twitter buttons do in this file?
They are Buttons with variant="outline" and flex-1, in a flex gap-2 row. Each has an svg with aria-hidden="true" and data-icon="inline-start". This demo gives them no handler or link yet.
How does the Share button become the trigger?
The trigger is a Button with variant="outline". Share2Icon has aria-hidden="true" and data-icon="inline-start", and the label is Share. PopoverTitle reads Share this page. PopoverContent is w-80 max-w-full.
Pass the button to render on PopoverTrigger, and use PopoverContent as the panel.
What is the separator between?
A Separator sits between the Facebook and Twitter row and the copy block. The copy block is the Or copy link line plus the read-only input. The title Share this page is above both.
Related
- Popover with FooterA popover with a title, a line of text
- Popover with DividerA popover whose two sections are split by
- Popover with FormA Settings popover with a text input and
- Simple Dropdown with Icons Dropdown MenuA short menu behind a dots button with an
- Button with Text (Standard)The one filled action
- Standard DialogA share dialog with a read-only link, a