Skip to content

Button and Inline Loaders

Tailwind CSS loading states for buttons, inputs and inline text: ring and arc spinners, bouncing dots, a progress line and a deploy status pill.

Also known as: button loading spinner, inline loading indicator, input loading state, loading dots animation, save button spinner

Button and Inline Loaders live demo

Open in new tab

Tailwind CSS code (HTML, CSS, JS)

A dark collection of small loading indicators built with Tailwind CSS and a little vanilla JavaScript: spinners inside buttons, trailing spinners in text fields, an indeterminate progress line, and loaders that sit inside a sentence or a table row. Use it for save buttons, live searches, username checks, sync messages and deploy statuses.

How it works

The root is section.tbl-root with three cards: Buttons, Inputs and Inline text. Every demo element is a .tbl-item with a data-busy attribute and contains two sets of children: .tbl-idle parts and .tbl-busy parts. style.css hides .tbl-idle while data-busy="true" and hides .tbl-busy otherwise, so each state is plain markup you can copy.

The spinners use Tailwind's animate-spin on a bordered circle (border-r-transparent or border-t-lime-400) or on an SVG arc. style.css adds the bouncing .tbl-dot animation and the .tbl-bar-fill progress line. The "Save changes" button keeps its label in .tbl-keep with visibility: hidden while the spinner is centered on top, so the button never changes width.

The script initializes each .tbl-root on DOMContentLoaded. Clicking a .tbl-btn sets it busy with aria-disabled="true" for BUTTON_MS milliseconds and then announces its data-tbl-done text. Typing in a .tbl-field shows its spinner until the user stops for data-tbl-delay milliseconds; the username field then checks the value against the TAKEN list. The .tbl-switch in the header flips every item between the busy and the idle state at once.

Customization

  • BUTTON_MS in script.js: change the simulated request time; replace the timeout in the .tbl-btn click handler with your fetch() call and set the item idle when it settles.
  • data-tbl-delay on each .tbl-field: tune the debounce, for example 300 for a snappier search.
  • TAKEN in script.js: replace the demo list with a request to your username availability endpoint.
  • data-busy="false" on any .tbl-item: start that element in its idle state.
  • border-t-lime-400 and text-lime-400 on the spinners: swap lime for your accent color.
  • animation: tbl-dot 1s and animation: tbl-slide 1.2s in style.css: speed up or slow down the dots and the progress line.
  • Remove .tbl-keep and the absolute inset-0 wrapper to let a button grow with its loading text instead.

Use cases

  • Save and submit forms: the button shows a spinner without changing width while a request runs
  • Live search fields: a trailing spinner appears while the user types until they pause
  • Sign-up pages: the username field shows a spinner while checking whether the name is taken
  • Deploy and sync dashboards: loaders inside a sentence or table row show a deploy status pill
  • Invite and email flows: bouncing dots and a progress line show a sending state

Accessibility

Busy buttons get aria-disabled="true" instead of disabled, so they keep focus while the request runs. Icon and dot loaders are aria-hidden="true" and paired with readable or sr-only text such as "Sending invite". Non-button items receive aria-busy, field hints are aria-live="polite", and a role="status" region announces completed actions. The header switch uses role="switch" with aria-checked. Under prefers-reduced-motion, spinners slow to 2 seconds per turn, the dots stop bouncing and the ping effect is removed.

Usage notes

Copy only the loader you need: each .tbl-item works on its own as long as style.css is included.

Button and Inline Loaders at a glance

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

Questions about this template

Can I use the Button and Inline Loaders 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, 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):

  • <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.

Button and Inline Loaders – free Tailwind CSS loader & spinner template
Button and Inline Loaders · free Tailwind CSS loader & spinner template

More Loaders & Spinners

Pulse Ring Loader – free Pure CSS loader & spinner template

Pulse Ring Loader

Pure CSS loading animation with concentric rings expanding from a beating dot, in default, large and inline sizes with custom properties and reduced motion.

Bouncing Dots Loader – free Pure CSS loader & spinner template

Bouncing Dots Loader

Pure CSS three-dot loaders: bounce, pulse with rings, chat typing indicator and a button loading state, all driven by custom properties.

CSS Spinner Collection – free Pure CSS loader & spinner template

CSS Spinner Collection

Eight lightweight pure CSS loading spinners in a labelled grid, each with role="status" and screen reader text, no JavaScript.

Full-Page Loader – free Tailwind CSS loader & spinner template

Full-Page Loader

Tailwind CSS full-page loader overlay with a spinning gradient ring, progress bar and status messages that fades out once the page has loaded.