This page as markdown: /like-button.md · Index for agents: /llms.txt · Everything in one file: /llms-full.txt

LikeButton

Status: stable

A pressed-or-not toggle for a like, a star or a save, with its count. Pressing it on fills the glyph, which blooms while a ring and a spray of dots burst from it and the count rolls up; pressing it off is quiet.

Keywords: like, heart, favorite, favourite, love, star, bookmark, save, upvote, reaction, count, toggle

Usage

Use LikeButton for a personal, reversible endorsement that other people can see the tally of: liking a post, starring a repository, saving a recipe. It is the one place in Sable that celebrates, because the person chose it and it costs nothing to undo.

Best practices

Props

Name Type Default Description
count number — The total, rolled when it changes. Pressing adds or removes the viewer's like at once; the button shows count exactly again whenever count changes. Omit it for a bare glyph (an icon-size button).
pressed boolean — Controlled pressed state.
defaultPressed boolean false Initial pressed state when uncontrolled.
onPressedChange (pressed: boolean, event) => void — Called when the user presses it, with the new state.
icon string "heart" The glyph, by icon name. Its solid variant is shown while pressed.
tone PaletteColor "red" The palette family the glyph fills with while pressed, and the burst blooms from. A family, so it follows the theme.
label string "Like" The accessible name, read before the count.
format Intl.NumberFormatOptions — How to write the count, e.g. { notation: "compact" }.
variant "ghost" | "outline" | "secondary" "ghost" The Button surface.
size "xs" | "sm" | "md" "sm" A Button size; without a count, the matching icon size.
disabled boolean false Disables it.
motion "full" | "subtle" | "off" "full" How much motion this component uses: full (default) inherits the app's policy, subtle keeps feedback and drops the flourish, off stills it. It can only turn motion down — it never overrides a reader's reduce-motion setting. The bloom and the burst are the flourish; the fill and the count changing stay.

Variants

Tokens used

palette-dot, accent, ring

Motion

Accessibility

Related

Examples

A post's likes

import { LikeButton } from "@sableui/react"

<LikeButton count={post.likes} defaultPressed={post.liked} onPressedChange={(on) => api.like(post.id, on)} />

Star a repository

import { LikeButton } from "@sableui/react"

<LikeButton icon="star" tone="yellow" label="Star" variant="outline" count={repo.stars} format={{ notation: "compact" }} />

Bare glyph

import { LikeButton } from "@sableui/react"

<LikeButton label="Save recipe" />