Skip to content

Like, Share and Bookmark Icon Buttons

Bootstrap 5 like, share and bookmark toggle buttons with active states, animated icons and live counters in pill and compact round styles.

Also known as: like button with counter, social action buttons, bookmark toggle button, post reaction buttons, share and save buttons

Like, Share and Bookmark Icon Buttons live demo

Open in new tab

Bootstrap 5 code (HTML, CSS, JS)

A set of Bootstrap 5 like, share and bookmark icon buttons with toggleable active states and live counters, shown in two styles: outlined pills under a post card and a compact dark bar of round buttons. Use them on blog posts, social feeds, recipe pages or any content that people can react to and save.

How it works

The root section.lsb-demo holds an article.lsb-post and a second .lsb-actions--round bar. Each .lsb-actions element is a role="group" containing three button.lsb-btn elements. Every button carries its state in aria-pressed, its raw number in data-lsb-count, the outline and filled Bootstrap Icons in data-lsb-icon and data-lsb-icon-active, and two short messages in data-lsb-on and data-lsb-off.

The script runs on DOMContentLoaded and loops over every .lsb-actions group. On click it flips aria-pressed, adds or subtracts one from the count, writes the formatted number into .lsb-count (values from 1000 are shortened by formatCount(), so 1194 becomes "1.2k") and swaps the icon class, for example bi-heart to bi-heart-fill. Activating a button adds .lsb-pop, which scales the icon with the lsb-pop keyframes. Each click also dispatches a bubbling lsb:change event with { active, count } in detail, the place to connect your own API.

The CSS gives every button a --lsb-tone color. When aria-pressed="true" the pill takes that color and a 12% tinted background through color-mix(). In the round variant the icon circle fills with the tone instead.

Customization

  • --lsb-like, --lsb-share and --lsb-save in .lsb-demo: change the active color of each button type.
  • --lsb-bg, --lsb-card and --lsb-ink in .lsb-demo: recolor the page background, the post card and the dark compact bar.
  • --lsb-radius in .lsb-demo: make the post card corners rounder or square.
  • data-lsb-count on a .lsb-btn: set the starting number; keep the visible .lsb-count text in sync.
  • aria-pressed="true" on a button plus the filled icon class: show it as already liked, shared or saved on load.
  • data-lsb-icon and data-lsb-icon-active: use other Bootstrap Icons, such as bi-hand-thumbs-up and bi-hand-thumbs-up-fill.
  • Remove ms-auto from .lsb-btn--save to keep the bookmark button next to the others instead of pushing it right.
  • Listen for lsb:change on the root and call fetch() to store the state on your server.

Use cases

  • Blog posts: like, share and bookmark pills sit under the article with live counters
  • Social feeds: each post gets its own independent group of toggle buttons
  • Recipe sites: visitors save favorites with a bookmark button that fills when active
  • Content platforms: a lsb:change event reports every toggle so you can store it through your API

Accessibility

All controls are native button elements with aria-pressed, so screen readers announce them as toggle buttons. Each has a visually-hidden label (Like, Share, Bookmark) followed by the count, and the icons are aria-hidden. A visually hidden .lsb-status element with role="status" in each group announces messages such as "Saved to bookmarks". Buttons have a 44px touch target and a 3px :focus-visible outline in the button's tone. Text colors pass WCAG AA on the light card. The pop animation and color transitions are turned off with prefers-reduced-motion: reduce.

Usage notes

Requires Bootstrap 5 and Bootstrap Icons. Copy one .lsb-actions group per post; groups work independently, so a feed can contain any number of them.

Like, Share and Bookmark Icon Buttons at a glance

Framework
Bootstrap 5
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
Bootstrap 5, Bootstrap Icons
Layout
Responsive, works on mobile
Category
Icon Buttons
License
Free for personal and commercial use

Questions about this template

Can I use the Like, Share and Bookmark Icon Buttons code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

Load Bootstrap 5 and Bootstrap Icons from a CDN (the links are under Requirements). Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

Add these to your page (already included in the download):

  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
  • <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
Like, Share and Bookmark Icon Buttons – free Bootstrap 5 icon button template
Like, Share and Bookmark Icon Buttons · free Bootstrap 5 icon button template

More Icon Buttons

Icon Buttons with Ripple – free Pure CSS icon button template

Icon Buttons with Ripple

Round icon buttons with a Material-style ripple, toggle states and tooltips: standard, filled, tonal and outlined variants in three sizes.

Icon Buttons with Tooltips – free Tailwind CSS icon button template

Icon Buttons with Tooltips

Accessible Tailwind CSS icon buttons with tooltips as labels, toggle states, a keyboard-friendly toolbar, a navigation rail and Escape to dismiss.