Back to Buttons
Components / Buttons
Bookmark Save Button
Free Buttons React component — BookmarkSaveButton. MIT licensed, copy-paste ready for Next.js and Tailwind CSS.
Save for later — bookmark icon fills amber and label swaps to Saved. Square-ish control for articles and products.
Preview
Setup
How to use
Free for personal and commercial use. No UI attribution required. Include the MIT copyright notice when copying component source into your project. Read the MIT license.
- 1
Run in your terminal:
$npm install clsx tailwind-merge lucide-react - 2
Copy
lib/cn.tsbelow. Skip if you already havecn(). - 3
Copy the code below and create
components/buttons/bookmark-save-button.tsxin your project. - 4
Import and render:
Exampleimport { BookmarkSaveButton } from "@/components/buttons/bookmark-save-button";
lib/cn.ts
import { type ClassValue, clsx } from "clsx";import { twMerge } from "tailwind-merge";export function cn(...inputs: ClassValue[]) {return twMerge(clsx(inputs));}
components/buttons/bookmark-save-button.tsx
"use client";import { forwardRef, useState, type ComponentPropsWithoutRef } from "react";import { cn } from "@/lib/cn";import { Bookmark } from "lucide-react";export type BookmarkSaveButtonProps = Readonly<{label?: string;savedLabel?: string;defaultSaved?: boolean;} & ComponentPropsWithoutRef<"button">>;// Bookmark save — icon fills and label swaps when saved.export const BookmarkSaveButton = forwardRef<HTMLButtonElement,BookmarkSaveButtonProps>(({className,label = "Save",savedLabel = "Saved",defaultSaved = false,onClick,...props},ref,) => {const [saved, setSaved] = useState(defaultSaved);return (<buttonref={ref}type="button"aria-pressed={saved}data-slot="bookmark-save-button"onClick={(event) => {setSaved((prev) => !prev);onClick?.(event);}}className={cn("inline-flex h-10 cursor-pointer items-center gap-2 rounded-lg border px-3.5 font-sans text-sm font-medium transition-all duration-200 active:scale-[0.98] select-none",saved? "border-amber-200 bg-amber-50 text-amber-800": "border-neutral-200 bg-white text-neutral-700 hover:border-neutral-300",className,)}{...props}><Bookmarksize={16}strokeWidth={2}className={cn("transition-transform duration-200",saved ? "scale-110 fill-amber-500 text-amber-500" : "scale-100",)}/>{saved ? savedLabel : label}</button>);},);BookmarkSaveButton.displayName = "BookmarkSaveButton";