search results:

  • Standard
  • React
Pricing Learn Community
  • + D
  • Light
  • Dark
  • System
logo TW Elements
  • Getting started
    • Quick start
    • Dark mode
    • Theming
    • Changelog
  • CommercialNew
    • Pricing
    • License
    • Installation
    • Git & repository
    • Premium Support
  • Integrations
    • Next
  • Content & styles
    • Animations
    • Animations extended
    • Colors
    • Dividers
    • Figures
    • Headings
    • Hover effects
    • Icons
    • Images
    • Mask
    • Shadows
    • Typography
  • Navigation
    • Breadcrumbs
    • Footer
    • Pagination
    • Pills
    • Tabs
  • Components
    • Accordion
    • Alerts
    • Avatar
    • Badges
    • Button group
    • Buttons
    • Cards
    • Carousel
    • Collapse
    • Dropdown
    • Link
    • List group
    • Modal
    • Paragraphs
    • Placeholders
    • Popover
    • Progress
    • Rating
    • Scroll back to top button
    • Social buttons
    • Spinners
    • Timeline
    • Toasts
    • Tooltip
    • Video carousel
  • Forms
    • Checkbox
    • File input
    • Form templates
    • Inputs
    • Login form
    • Radio
    • Range
    • Registration form
    • Search
    • Select
    • Switch
    • Textarea
  • Data
    • Charts
    • Tables
  • Methods
    • Ripple
  • ResourcesNew
    • Playground
    • YouTube Channel
    • Private FB Group
    • Newsletter
    • UI Design course New

Placeholders

Tailwind CSS React Placeholders

Use responsive placeholders component with helper examples for width, color, sizing, placeholder animations & more.


Basic example

In the example below, we take a typical card component and recreate it with placeholders applied to create a "loading card". Size and proportions are the same between the two.

Loading...
  • JSX
import React from 'react';
import { TERipple } from 'tw-elements-react';

export default function PlaceholderBasicExample(): JSX.Element {
  return (
    <div>
      <div
        className="max-w-xs rounded-lg bg-white shadow-[0_2px_15px_-3px_rgba(0,0,0,0.07),0_10px_20px_-2px_rgba(0,0,0,0.04)] dark:bg-neutral-700">
        <img
          src="https://tecdn.b-cdn.net/img/new/standard/nature/184.jpg"
          className="rounded-t-lg"
          alt="..." />
        <div className="p-6">
          <h5
            className="mb-2 text-xl font-medium leading-tight text-neutral-800 dark:text-neutral-50">
            Card title
          </h5>
          <p className="mb-4 text-base text-neutral-600 dark:text-neutral-200">
            Some quick example text to build on the card title and make up the
            bulk of the card's content.
          </p>
          <TERipple>
            <button
              type="button"
              className="inline-block rounded bg-primary px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-white shadow-[0_4px_9px_-4px_#3b71ca] transition duration-150 ease-in-out hover:bg-primary-600 hover:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] focus:bg-primary-600 focus:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] focus:outline-none focus:ring-0 active:bg-primary-700 active:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] dark:shadow-[0_4px_9px_-4px_rgba(59,113,202,0.5)] dark:hover:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.2),0_4px_18px_0_rgba(59,113,202,0.1)] dark:focus:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.2),0_4px_18px_0_rgba(59,113,202,0.1)] dark:active:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.2),0_4px_18px_0_rgba(59,113,202,0.1)]">
              Go somewhere
            </button>
          </TERipple>
        </div>
      </div>
      <div
        className="max-w-xs rounded-lg bg-white shadow-[0_2px_15px_-3px_rgba(0,0,0,0.07),0_10px_20px_-2px_rgba(0,0,0,0.04)] dark:bg-neutral-700"
        aria-hidden="true">
        <img
          src="https://tecdn.b-cdn.net/img/new/standard/nature/182.webp"
          className="rounded-t-lg"
          alt="..." />
        <div className="p-6">
          <h5
            className="mb-2 animate-pulse text-xl font-medium text-neutral-900 dark:text-white">
            <span
              className="inline-block min-h-[1em] w-6/12 flex-auto cursor-wait bg-current align-middle opacity-50"></span>
          </h5>
          <p
            className="mb-4 animate-pulse text-base text-neutral-700 dark:text-white">
            <span
              className="inline-block min-h-[1em] w-7/12 flex-auto cursor-wait bg-current align-middle opacity-50"></span>
            <span
              className="inline-block min-h-[1em] w-4/12 flex-auto cursor-wait bg-current align-middle opacity-50"></span>
            <span
              className="inline-block min-h-[1em] w-4/12 flex-auto cursor-wait bg-current align-middle opacity-50"></span>
            <span
              className="inline-block min-h-[1em] w-6/12 flex-auto cursor-wait bg-current align-middle opacity-50"></span>
            <span
              className="inline-block min-h-[1em] w-8/12 flex-auto cursor-wait bg-current align-middle opacity-50"></span>
          </p>
          <a
            href="#"
            tabIndex={-1}
            className="inline-block min-h-[1em] w-6/12 flex-auto cursor-wait rounded bg-primary px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-white opacity-50 shadow-[0_4px_9px_-4px_#3b71ca] transition duration-150 ease-in-out before:inline-block before:content-[''] hover:bg-primary-600 hover:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] focus:bg-primary-600 focus:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] focus:outline-none focus:ring-0 active:bg-primary-700 active:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)]"></a>
        </div>
      </div>
    </div>
  );
}

Hey there 👋 we're excited about TW Elements for React and want to see it grow! If you enjoy it, help the project grow by sharing it with your peers. Every share counts, thank you!

How it works

  • JSX
import React from 'react';

export default function App() {
  return (
      <div>
          <p
            aria-hidden="true"
            className="mb-4 text-base text-neutral-700 dark:text-white">
            <span
              className="inline-block min-h-[1em] w-6/12 flex-auto cursor-wait bg-current align-middle opacity-50"></span>
          </p>
          <a
            href="#"
            tabIndex={-1}
            className="inline-block min-h-[1em] w-4/12 flex-auto cursor-wait rounded bg-primary px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-white opacity-50 shadow-[0_4px_9px_-4px_#3b71ca] transition duration-150 ease-in-out before:inline-block before:content-[''] hover:bg-primary-600 hover:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] focus:bg-primary-600 focus:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] focus:outline-none focus:ring-0 active:bg-primary-700 active:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)]"
            aria-hidden="true"></a>
        </div>
  );
}

Width

You can change the width through grid column classes, width utilities, or inline styles.

  • JSX
import React from 'react';

export default function App() {
  return (
      <div>

          <span
            className="inline-block min-h-[1em] w-6/12 flex-auto cursor-wait bg-current align-middle text-base text-neutral-700 opacity-50 dark:text-neutral-50"></span>
          <span
            className="inline-block min-h-[1em] w-9/12 cursor-wait bg-current align-middle text-base text-neutral-700 opacity-50 dark:text-neutral-50"></span>
          <span
            className="inline-block min-h-[1em] cursor-wait bg-current align-middle text-base text-neutral-700 opacity-50 dark:text-neutral-50"></span>
        </div>
  );
}

Colors

By default, the placeholder uses currentColor. This can be overridden with a custom color or utility class.

  • JSX
import React from 'react';

export default function App() {
  return (
      <div>
          <span
            className="inline-block min-h-[1em] w-full flex-auto cursor-wait bg-current align-middle text-base text-neutral-700 opacity-50 dark:text-white"></span>
          <span
            className="inline-block min-h-[1em] w-full flex-auto cursor-wait bg-primary align-middle opacity-50"></span>
          <span
            className="inline-block min-h-[1em] w-full flex-auto cursor-wait bg-secondary align-middle opacity-50"></span>
          <span
            className="inline-block min-h-[1em] w-full flex-auto cursor-wait bg-success align-middle opacity-50"></span>
          <span
            className="inline-block min-h-[1em] w-full flex-auto cursor-wait bg-danger align-middle opacity-50"></span>
          <span
            className="inline-block min-h-[1em] w-full flex-auto cursor-wait bg-warning align-middle opacity-50"></span>
          <span
            className="inline-block min-h-[1em] w-full flex-auto cursor-wait bg-info align-middle opacity-50"></span>
          <span
            className="inline-block min-h-[1em] w-full flex-auto cursor-wait bg-neutral-200 align-middle opacity-50"></span>
          <span
            className="inline-block min-h-[1em] w-full flex-auto cursor-wait bg-neutral-800 align-middle opacity-50 dark:bg-neutral-900 dark:opacity-50"></span>
        </div>
  );
}

Sizing

  • JSX
import React from 'react';

export default function App() {
  return (
      <div>
          <span
            className="inline-block min-h-[1.2em] w-full flex-auto cursor-wait bg-current align-middle text-base text-neutral-700 opacity-50 dark:text-neutral-50"></span>
          <span
            className="inline-block min-h-[1em] w-full flex-auto cursor-wait bg-current align-middle text-base text-neutral-700 opacity-50 dark:text-neutral-50"></span>
          <span
            className="inline-block min-h-[0.8em] w-full flex-auto cursor-wait bg-current align-middle text-base text-neutral-700 opacity-50 dark:text-neutral-50"></span>
          <span
            className="inline-block min-h-[0.6em] w-full flex-auto cursor-wait bg-current align-middle text-base text-neutral-700 opacity-50 dark:text-neutral-50"></span>
        </div>
  );
}

Animation

  • JSX
import React from 'react';

export default function App() {
  return (
      <div>
          <p className="mb-4 animate-pulse">
            <span
              className="inline-block min-h-[1em] w-full flex-auto cursor-wait bg-current align-middle text-base text-neutral-700 opacity-50 dark:text-neutral-50"></span>
          </p>
          <p
            className="mb-4 animate-[placeholder-wave_2s_linear_infinite] [mask-size:200%_100%]">
            <span
              className="inline-block min-h-[1em] w-full flex-auto cursor-wait bg-current align-middle text-base text-neutral-700 opacity-50 dark:text-neutral-50"></span>
          </p>
        </div>
  );
}

Related resources

How to add padding in Bootstrap? How to use flexbox in Bootstrap? Cards Colors animations Gutters Spinners Loading Management Lazy Loading Progress

If you are looking for more advanced options, try Bootstrap Placeholders from MDBootstrap.

  • Basic example
  • How it works
  • Width
  • Colors
  • Sizing
  • Animation
Get useful tips & free resources directly to your inbox along with exclusive subscriber-only content.
Join our mailing list now
© 2023 Copyright: MDBootstrap.com