FollowButton

Follow becomes Following and the pill resizes to fit. Point at Following and it offers Unfollow in red. Buttons.

Open playground

About

FollowButton is a React component in the Buttons category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { FollowButton } from "@ashutoshswamy/smoui" and set following, defaultFollowing, onChange.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { FollowButton } from "@ashutoshswamy/smoui";

<FollowButton onChange={(following) => save(following)} />

Props 3

following

Controlled state. Leave out and it keeps its own.

boolean
defaultFollowing

Starting state when uncontrolled.

boolean
onChange

Called on every flip.

(following: boolean) => void