Follow Button

A follow button that morphs its width, fill, and label between states.

@spectrumui/follow-button

Arihant Jain

@arihantcodes

2,847followers

Installation

Login to view commandCreate a free account to access the install command

Usage

import { FollowButton } from "@/components/spectrumui/follow-button"
<FollowButton onFollowingChange={(following) => console.log(following)} />

API Reference

FollowButton

Renders a single button element with aria-pressed reflecting the following state. Pass following to control it from outside, or defaultFollowing to let it manage its own state.

PropTypeDefaultDescription
followingboolean-Controlled following state. Leave undefined for uncontrolled usage
defaultFollowingbooleanfalseInitial following state when uncontrolled
onFollowingChange(following: boolean) => void-Fires with the next following state on every toggle
followLabelstring"Follow"Label of the idle call-to-action pill
followingLabelstring"Following"Label shown while followed
unfollowLabelstring"Unfollow"Label revealed on hover or focus while followed
size"sm" | "md" | "lg""md"Visual size of the button
disabledbooleanfalseDisables pointer and keyboard interaction
classNamestring-Additional classes merged with the default button styles

Examples

Sizes and custom labels