Skip to content

Star Button

A star toggle whose star arcs into the counter, which ticks up with a floating +1.

3 variantsNew

Preview

Installation

Copies the component into components/ui and installs its dependencies and theme tokens.

pnpm dlx shadcn@latest https://floret.shippedui.com/r/star-button.json

Usage

Pass your own data and wire the callbacks to your app.

import { StarButton } from "@/components/ui/star-button";

export function RepoActions({ stars, starred }: { stars: number; starred: boolean }) {
  return (
    <StarButton
      defaultCount={stars}
      defaultStarred={starred}
      onStarredChange={(next) => toggleStar(next)}
    />
  );
}

Props

PropTypeDefaultDescription
defaultCountnumber0Count shown before any interaction.
defaultStarredbooleanfalseStart starred. The count is expected to already include the viewer's star.
onStarredChange(starred: boolean, count: number) => void—Called once the animation settles. Persist the star here.
labelstring"Star"Idle label.
starredLabelstring"Starred"Label while starred.
classNamestring—Merged onto the button; size it with h-* and w-*.

Credits

This component is built on top of Number Flow.