Back to Buttons
Components / Buttons
Follow Button
Free Buttons React component — FollowButton. MIT licensed, copy-paste ready for Next.js and Tailwind CSS.
Social follow toggle — dark Follow pill becomes a quiet Following state with a user-check icon. Tap again to unfollow.
Preview
Setup
How to use
Free for personal and commercial use. No UI attribution required. Include the MIT copyright notice when copying component source into your project. Read the MIT license.
- 1
Run in your terminal:
$npm install clsx tailwind-merge lucide-react - 2
Copy
lib/cn.tsbelow. Skip if you already havecn(). - 3
Copy the code below and create
components/buttons/follow-button.tsxin your project. - 4
Import and render:
Exampleimport { FollowButton } from "@/components/buttons/follow-button";
lib/cn.ts
import { type ClassValue, clsx } from "clsx";import { twMerge } from "tailwind-merge";export function cn(...inputs: ClassValue[]) {return twMerge(clsx(inputs));}
components/buttons/follow-button.tsx
"use client";import { forwardRef, useState, type ComponentPropsWithoutRef } from "react";import { cn } from "@/lib/cn";import { UserCheck, UserPlus } from "lucide-react";export type FollowButtonProps = Readonly<{label?: string;followingLabel?: string;defaultFollowing?: boolean;} & ComponentPropsWithoutRef<"button">>;// Follow toggle — outline invite becomes a quiet filled following state.export const FollowButton = forwardRef<HTMLButtonElement, FollowButtonProps>(({className,label = "Follow",followingLabel = "Following",defaultFollowing = false,onClick,...props},ref,) => {const [following, setFollowing] = useState(defaultFollowing);return (<buttonref={ref}type="button"aria-pressed={following}data-slot="follow-button"onClick={(event) => {setFollowing((prev) => !prev);onClick?.(event);}}className={cn("inline-flex h-10 cursor-pointer items-center gap-2 rounded-full px-4 font-sans text-sm font-semibold transition-all duration-200 active:scale-[0.98] select-none",following? "bg-neutral-100 text-neutral-600 ring-1 ring-neutral-200": "bg-neutral-900 text-white",className,)}{...props}>{following ? (<><UserCheck size={15} strokeWidth={2} />{followingLabel}</>) : (<><UserPlus size={15} strokeWidth={2} />{label}</>)}</button>);},);FollowButton.displayName = "FollowButton";