Follow Button
Follow becomes Following with a width-morph and tick; hovering a followed state previews Unfollow.
$
View as Markdownnpx shadcn@latest add https://sundaeui.dev/r/follow-button.jsonOverview
The button morphs its width between labels instead of snapping, and the plus turns into a tick. When followed, hovering or focusing swaps the label to Unfollow so the next click is never a surprise.
An optional follower count rolls by one in step with the state.
When to use
- Profiles, creators, channels, topics.
When not to use
- Actions with side effects beyond a subscription.
Installation
$
pnpm dlx shadcn@latest add https://sundaeui.dev/r/follow-button.json$
npx shadcn@latest add https://sundaeui.dev/r/follow-button.json$
yarn dlx shadcn@latest add https://sundaeui.dev/r/follow-button.json$
bunx --bun shadcn@latest add https://sundaeui.dev/r/follow-button.jsonWorks in any React project. Files are written to components/sundae/. Read the source in the stage’s Code view.
- No dependencies beyond React 18 or later.
- Copy follow-button.tsx and follow-button.css into components/sundae/.
- The CSS file is imported by the component, so no extra configuration is needed.
- Import the component and use it as shown below.
Usage
import { FollowButton } from '@/components/sundae/follow-button'
<FollowButton />Props
| Prop | Type | Default |
|---|---|---|
following / defaultFollowingState. | boolean | false |
countOptional follower count shown beside it. | number | — |
onFollowChangeCalled on change. | (on: boolean) => void | — |
fillSurface: dark or light. | 'dark' | 'light' | 'dark' |
Accessibility
- A toggle button with aria-pressed; the label always describes the current state.
- The hover-to-unfollow label also appears on keyboard focus.
- Reduced motion removes the movement and keeps every state change.
Customization
- Colours are CSS custom properties on .sd-fw; override them in your own stylesheet.
- fill="light" switches the built-in light palette.
FAQ
- Is Follow Button free?
- Yes. Follow Button is free for personal and commercial projects, with full source on this page.
- How do I install Follow Button?
- Run npx shadcn@latest add https://sundaeui.dev/r/follow-button.json. The files are written to components/sundae/. It has no dependencies beyond React 18 or later.
- Does Follow Button support keyboard and screen readers?
- A toggle button with aria-pressed; the label always describes the current state. The hover-to-unfollow label also appears on keyboard focus.
- Does Follow Button respect reduced motion?
- Reduced motion removes the movement and keeps every state change.
More like this
All components →Bookmark Button
Components · RefinedHold to Confirm
Components · RefinedDownload Button
Components · RefinedVote Arrows
Components · RefinedTheme Toggle
Components · RefinedPoll Card
Components · Refined