# Save button

A bookmark action that fills, settles, and confirms the new state.

## Usage

Use for a reversible save action. This local demo does not persist between visits. Add your own request handling and rollback behavior if a save can fail.

Save the JSX and CSS Module in the same folder in a React project with CSS Modules support. Controlled components need parent state and change handlers.

## JSX

```jsx
"use client";
import styles from "./SaveButton.module.css";
import { useState } from "react";
export default function SaveButton({ defaultSaved = false, onChange }) {
  const [saved, setSaved] = useState(defaultSaved);
  return (
    <div className={styles.root}>
      <button
        type="button"
        aria-pressed={saved}
        onClick={() => {
          const next = !saved;
          setSaved(next);
          onChange?.(next);
        }}
      >
        <span className={styles.icon} data-saved={saved} aria-hidden="true">
          <svg
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            strokeWidth="1.5"
          >
            <path d="M6 4h12v16l-6-4-6 4Z" />
          </svg>
          <i />
          <i />
          <i />
        </span>
        <span>{saved ? "Saved" : "Save for later"}</span>
      </button>
      <p role="status">
        {saved
          ? "Added to your collection."
          : "Keep something worth coming back to."}
      </p>
    </div>
  );
}

```

## CSS

```css
.root {
  text-align: center;
}
.root button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: var(--tdp-control-height, 48px);
  padding: 12px 20px;
  border: 1px solid var(--tdp-border, #d9d1c9);
  border-radius: var(--tdp-radius, 8px);
  background: var(--tdp-surface, #fffdfa);
  color: var(--tdp-text, #302e2b);
  font-size: 14px;
  transition:
    background 0.25s,
    transform 0.25s;
}
.root button:hover {
  transform: translateY(-2px);
}
.root button[aria-pressed="true"] {
  background: var(--tdp-primary, #1f3934);
  color: var(--tdp-on-primary, #fff);
}
.icon {
  position: relative;
  width: 20px;
  height: 22px;
  display: block;
}
.icon svg {
  width: 100%;
  height: 100%;
  transition: fill 0.25s;
}
.icon[data-saved="true"] svg {
  fill: currentColor;
  animation: settle 0.45s ease;
}
.icon i {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #b3c996;
  opacity: 0;
  pointer-events: none;
}
.icon[data-saved="true"] i {
  animation: spark 0.5s ease-out both;
  --dx: -18px;
  --dy: -18px;
}
.icon[data-saved="true"] i:nth-of-type(2) {
  --dx: 19px;
  --dy: -13px;
}
.icon[data-saved="true"] i:nth-of-type(3) {
  --dx: 15px;
  --dy: 19px;
}
.root p {
  font-size: 11px;
  color: var(--tdp-muted, #6b625b);
  margin: 18px 0 0;
}
@keyframes settle {
  50% {
    transform: scale(1.25);
  }
  100% {
    transform: scale(1);
  }
}
@keyframes spark {
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) scale(0.4);
  }
}
.root {
  font-family: var(--tdp-font, "DM Sans", system-ui, sans-serif);
  color: var(--tdp-text, #302e2b);
  max-width: 100%;
  box-sizing: border-box;
}
.root * {
  box-sizing: border-box;
}
.root :is(button, input, a):focus-visible,
.root:focus-visible {
  outline: 3px solid var(--tdp-focus, #7851a9);
  outline-offset: 4px;
}
.root button {
  font: inherit;
  cursor: pointer;
}
.root button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}
.root button,
.root a {
  touch-action: manipulation;
}
@media (prefers-reduced-motion: reduce) {
  .root,
  .root *,
  .root::before,
  .root::after {
    animation: none !important;
    transition: none !important;
    transform: none !important;
    translate: none !important;
    rotate: none !important;
    scale: none !important;
    scroll-behavior: auto !important;
  }
}

```

## Props

- defaultSaved (boolean): Initial saved state.
- onChange (function): Receives the new state; connect persistence here.

## Accessibility

The native button exposes aria-pressed and a live confirmation. Decorative particles are aria-hidden. Reduced-motion preferences disable the burst.

Check accessibility again after customizing the component.

[Browse all components](/resources/components/)

Canonical: https://designproject.io/resources/components/save-button/

## Keep learning

- [How to create a UI color palette, step by step](https://designproject.io/resources/guides/create-ui-color-palette/)
- [Product design glossary: 44 terms explained](https://designproject.io/resources/glossary/)
- [How to choose font pairings for a product interface](https://designproject.io/resources/guides/choose-font-pairings/)
