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.jsonUsage
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
| Prop | Type | Default | Description |
|---|---|---|---|
| defaultCount | number | 0 | Count shown before any interaction. |
| defaultStarred | boolean | false | Start 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. |
| label | string | "Star" | Idle label. |
| starredLabel | string | "Starred" | Label while starred. |
| className | string | — | Merged onto the button; size it with h-* and w-*. |
Credits
This component is built on top of Number Flow.