Updated
Bookmark Button
Customize
Icon + label
Drop
Soft
Medium
Radius12px
Installation
npx shadcn@latest add https://uibrik.com/r/bookmark-button.jsonInstall the packages
npm install motion react-use-measureAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/bookmark-button/bookmark-button.tsx"use client"; import { AnimatePresence, motion } from "motion/react"; import { useId, useState } from "react"; import useMeasure from "react-use-measure"; import { cn } from "@/lib/utils"; const EASE_OUT: [number, number, number, number] = [0.23, 1, 0.32, 1]; const BOOKMARK = "M18 7v14l-6 -4l-6 4v-14a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4z"; const STAR = "M12 0C12.6 6.6 17.4 11.4 24 12C17.4 12.6 12.6 17.4 12 24C11.4 17.4 6.6 12.6 0 12C6.6 11.4 11.4 6.6 12 0Z"; const SIZES = { sm: { height: 32, padX: 10, font: 13, icon: 16 }, md: { height: 40, padX: 13, font: 14, icon: 18 }, lg: { height: 48, padX: 16, font: 15, icon: 20 }, } as const; // Neutral looks shared by the library's quiet buttons. const VARIANTS = { soft: "bg-muted hover:bg-neutral-200/70 dark:hover:bg-neutral-800", ghost: "bg-transparent hover:bg-muted", outline: "bg-background shadow-[inset_0_0_0_1px_var(--border)] hover:bg-muted",
Adds the files to
components/uibrik/bookmark-button and installs motion and react-use-measure. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/bookmark-button.Usage
import { BookmarkButton } from "@/components/uibrik/bookmark-button/bookmark-button";<BookmarkButton label="Save" savedLabel="Saved" display="label" fill="drop" sparkles tint={false} variant="soft" size="md" radius={12} defaultSaved={false} onChange={(saved) => {}}/>Where to use Bookmark Button
Saving articles and recipes
The ribbon fills from the top while the label rolls to Saved, so users know the item is kept.
E-commerce wishlists
A clear saved state on product cards encourages shoppers to come back to what they liked.
Pairs with Stepper Button
Favourites in apps
One reusable save button keeps saved searches, posts and places consistent across an app.
Props
BookmarkButton- label
- Type string
- "Save"
- Button text.
- savedLabel
- Type string
- "Saved"
- Shown once saved.
- display
- Type "label" | "icon"
- "label"
- Icon and label, or the icon alone (the label stays as its accessible name).
- fill
- Type "drop" | "rise" | "pop"
- "drop"
- How the bookmark fills: from the top, from the bottom, or out from the centre.
- sparkles
- Type boolean
- true
- Three sparkles pop around the icon on save.
- tint
- Type boolean
- false
- Colour the saved bookmark and its sparkles instead of keeping them neutral.
- color
- Type string
- "#f59e0b"
- Colour of the saved bookmark when tinted.
- variant
- Type "soft" | "ghost" | "outline"
- "soft"
- Filled, transparent until hovered, or outlined.
- size
- Type "sm" | "md" | "lg"
- "md"
- Height, padding and text size.
- radius
- Type number
- 12
- Corner radius.
- defaultSaved
- Type boolean
- false
- Whether it starts saved.
- onChange
- Type (saved: boolean) => void
- –
- Called with the new state after each toggle.
- className
- Type string
- –
- Classes for the button.