Skip to content

Load More Button with Item Counter

Tailwind CSS load more button that reveals a grid in batches and shows a live "Showing X of Y" counter with a progress bar.

Also known as: load more button, show more items button, load more pagination, progressive item loading, items counter with progress bar

Load More Button with Item Counter live demo

Open in new tab

Tailwind CSS code (HTML, JS)

A load more button with an item counter, built with Tailwind CSS and a few lines of vanilla JavaScript. It reveals a grid of color palette cards in batches and keeps a "Showing 6 of 18 palettes" line and a thin progress bar in sync, so visitors always know how much is left. Use it for galleries, product listings or archives where numbered pagination feels too heavy.

How it works

The root is section.lmc-root. All cards are already in the markup as li.lmc-item elements inside #lmc-list, so the content is crawlable and fully visible when JavaScript is off. The .lmc-footer with the counter, the role="progressbar" track and the [data-lmc-button] starts with the hidden attribute and only appears once the script runs.

On DOMContentLoaded the script initializes every .lmc-root. It reads the batch size from data-lmc-step, hides every item beyond that number and fills [data-lmc-shown] and [data-lmc-total]. A click on the button sets aria-busy, shows the .lmc-spinner and changes the label to "Loading…". After the simulated LOAD_DELAY the next batch is unhidden, the counter, aria-valuenow and the width of [data-lmc-bar] are updated, and focus moves to the first newly revealed card. When nothing is left, the button is disabled and reads "All palettes loaded".

Customization

  • data-lmc-step="6" on .lmc-root: set how many items are shown at first and added per click; the button label follows automatically, e.g. "Load 4 more".
  • LOAD_DELAY at the top of script.js: shorten or remove the fake delay. To load from a server, replace the setTimeout in loadMore() with a fetch() call and append the returned items as new li.lmc-item elements before calling render().
  • bg-teal-700 on [data-lmc-bar] and hover:bg-teal-800 on the button: swap teal for your brand color.
  • bg-[#f6f1e9] on the root: change the warm paper background, or use bg-white for a neutral page.
  • sm:grid-cols-2 lg:grid-cols-3 on #lmc-list: switch to lg:grid-cols-4 and data-lmc-step="8" for a denser grid.
  • "All palettes loaded" and "palettes" in script.js and [data-lmc-counter]: rename to products, posts or photos.
  • Each palette is an article with five bg-[#hex] swatches; replace the article contents with your own card markup and keep the lmc-item class on the li.

Use cases

  • Product listings: a grid reveals more items in batches instead of using page numbers
  • Blog archives: a Showing X of Y counter tells readers how much is left
  • Portfolios and galleries: a progress bar shows how much of the collection is visible
  • Search results: visitors keep control by loading only when they want more

Accessibility

The counter paragraph is an aria-live="polite" region, so screen readers announce the new total after each batch. The progress track uses role="progressbar" with aria-valuemin, aria-valuemax and aria-valuenow, and the button points to the list with aria-controls and reports aria-busy while loading. Moving focus to the first new card (each card is an article with tabindex="-1" and an aria-label) lets keyboard users continue reading without tabbing through old items. Each swatch strip is a single role="img" with the hex codes as its label, the heart icons are aria-hidden with a sr-only "likes" suffix, focus rings are visible, and the spinner and transitions stop under prefers-reduced-motion.

Usage notes

For several lists on one page, give each copy unique id values for #lmc-list and #lmc-title; the script scopes all queries to its own .lmc-root.

Load More Button with Item Counter at a glance

Framework
Tailwind CSS
Code
HTML, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
Tailwind CSS
Layout
Responsive, works on mobile
Category
Pagination
License
Free for personal and commercial use

Questions about this template

Can I use the Load More Button with Item Counter 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 Tailwind CSS from a CDN (the links are under Requirements). Paste the HTML where the component should appear 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):

  • <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>

The Tailwind browser build is for prototyping. In production, compile Tailwind with its CLI or your bundler.

Load More Button with Item Counter – free Tailwind CSS pagination template
Load More Button with Item Counter · free Tailwind CSS pagination template

More Pagination

Pagination with Page Jump – free Bootstrap 5 pagination template

Pagination with Page Jump

Bootstrap 5 pagination with smart ellipses, previous and next arrows, a page counter and a validated 'go to page' input.

Rounded Pagination – free Pure CSS pagination template

Rounded Pagination

Pill-shaped pagination with ellipsis, previous/next buttons and a gradient active page, made interactive with a few lines of vanilla JS.

Pagination with Items Per Page Selector – free Bootstrap 5 pagination template

Pagination with Items Per Page Selector

Dark Bootstrap 5 orders table with a rows-per-page select, live range text and windowed pagination with ellipsis and prev/next buttons.

Pagination with Results Info – free Tailwind CSS pagination template

Pagination with Results Info

Tailwind CSS pagination bar with Previous/Next, numbered pages with ellipsis, a per-page select and a live 'Showing 1 to 10 of 97 results' summary.