# Floating Action Button

> A Material-style floating action button pinned to the corner, with a plus icon that turns on hover.

- Category: [CSS Buttons](https://copy-css.com/category/buttons)
- Tags: fab, material, plus, fixed, mobile
- Live preview: https://copy-css.com/snippets/floating-action-button
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```html
<button class="btn-fab" aria-label="Create new">
  <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg>
</button>
```

## CSS

```css
.btn-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: #7c3aed;
  color: #fff;
  box-shadow:
    0 4px 8px -2px #4c1d9566,
    0 10px 24px -6px #7c3aed99;
  cursor: pointer;
  transition: box-shadow 0.2s ease, background-color 0.2s ease;
}

.btn-fab svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  transition: transform 0.3s ease;
}

.btn-fab:hover {
  background: #6d28d9;
  box-shadow:
    0 6px 12px -2px #4c1d9566,
    0 16px 32px -8px #7c3aed99;
}

.btn-fab:hover svg {
  transform: rotate(90deg);
}

.btn-fab:focus-visible {
  outline: 3px solid #c4b5fd;
  outline-offset: 3px;
}
```

## Notes

- This CSS Floating Action Button is 46 lines of pure CSS (0.8 KB) with no JavaScript and no dependencies. It uses transitions, transforms, box shadows and CSS Grid.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
