To use a Lottie animation with Tailwind CSS, add a Lottie player to your application and use Tailwind utilities to size and position the element that contains it. The player loads and renders the animation; Tailwind handles the surrounding layout and responsive dimensions. Give the player a deliberate box, confirm it resizes to fit that box, and check the result at your project’s breakpoints.
What you need: an animation, a player, and a layout box
These are three separate parts of the integration:
- Animation: a Lottie JSON file or a
.lottiefile. The format and features used must be supported by your chosen player. - Player: the JavaScript runtime that loads the asset and renders its frames. Tailwind does not play the animation.
- Layout box: the element whose width, height, alignment, and responsive behavior you control with Tailwind.
The official dotLottie JavaScript player renders both JSON and .lottie assets. Its ecosystem includes a React wrapper and a framework-agnostic web player. The dotLottie web player documentation describes its rendering and configuration options.
As an Amazon Associate I earn from qualifying purchases.
Choose a player for your application
React: use the React wrapper
For a React app, install @lottiefiles/dotlottie-react and render its DotLottieReact component. The package documentation demonstrates supplying a src and options such as loop and autoplay. A ref can expose the player instance for playback controls and event handling. Follow the package’s current installation and API instructions, since runtime props can change. See the official React documentation.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchimport { DotLottieReact } from '@lottiefiles/dotlottie-react';
export function Animation() {
return (
<div className="mx-auto h-64 w-full max-w-lg md:h-80">
<DotLottieReact
src="/animations/intro.lottie"
autoplay
loop
style={{ width: '100%', height: '100%' }}
/>
</div>
);
}
This is illustrative JSX, not a universal recipe. Confirm that the installed package accepts the props shown and that its player fills the wrapper as intended. Replace the example path with an asset URL reachable by your app.
#1 Best Overall
Framework-agnostic browser code: use the web player
For integration without React, use @lottiefiles/dotlottie-web and follow its current setup instructions. The web player uses a canvas and accepts a source URL and playback options; its documentation also describes controlling the canvas size with CSS. Check the web player API and sizing guidance. Framework wrappers for other environments are also listed in the official player documentation.
Choose JSON or .lottie based on the asset and features
The player supports both Lottie JSON and .lottie files, but that does not mean every asset or advanced feature works with every player version. Check the asset’s export format and the target runtime’s compatibility before relying on features such as themes or state machines.
The dotLottie specification calls version 2.0 its latest recommended version and version 1.0 widely supported. Version 2 changes the archive structure and supports features including themes and state machines; the specification also describes v1 capabilities such as compression, multiple animations, and image assets. Verify the precise file and runtime combination you intend to use. Read the dotLottie specification.
Give the animation a predictable size
Put sizing utilities on the wrapper or player element that the runtime actually uses. For a fluid-width animation with a capped desktop width, a wrapper could use mx-auto w-full max-w-lg h-64 md:h-80. These values are design examples, not required dimensions. Tailwind’s width and height utilities apply to the element carrying the classes; they do not automatically size every internal canvas. Tailwind width utilities and height utilities define the available sizing options.
Rank #3
- Fluid width:
w-fullmakes the box use the available width, while a maximum-width utility can prevent it from growing indefinitely. - Defined height: choose a height or aspect ratio that suits the composition. A percentage height such as
h-fulldepends on the containing layout providing a meaningful height. - Player fit: set the component or canvas to fill the box when appropriate, then check for stretching, cropping, or blank space. Preserve the animation’s intended proportions rather than assuming the canvas will infer them from the wrapper.
The React player exposes render configuration that includes automatic resize behavior; consult its current docs to understand how it interacts with your CSS. React player configuration and web player configuration describe the respective APIs.
Make the layout responsive with Tailwind breakpoints
Tailwind’s responsive variants are mobile-first: unprefixed utilities apply at all sizes, and a prefixed utility takes effect at its breakpoint and above. For example, h-64 md:h-80 uses the base height until the configured md breakpoint, then applies the larger height. md: is not a mobile-only rule.
Rank #4
- DOLL WITH BOOK Lottie loves to curl up by the fire with her favorite book
- DOLL WITH GLASSES Red storybook & fluffy cream cushion
- DOLL CLOTHES include a long-sleeved striped outfit with adorable pink bows and navy Mary-Jane shoes
- PACKABLE & PORTABLE Perfect for little hands Lottie is ready to gift
- MINI DOLL BOOKS Lottie is ready for adventures in her imagination
Tailwind’s default minimum breakpoints are 40rem for sm, 48rem for md, 64rem for lg, 80rem for xl, and 96rem for 2xl. A project can customize these values, so check its theme rather than assuming the defaults. Tailwind’s responsive design documentation explains breakpoint variants and customization.
Recommended Free Tools
<div className="mx-auto h-64 w-full max-w-lg md:h-80">
{/* Lottie player sized to fill this box */}
</div>
Adapt the dimensions to the animation’s aspect ratio and surrounding design. Test the actual page at narrow and wide viewport sizes; a responsive wrapper only helps if the player tracks the wrapper correctly.
Best Value
- Funny personalized name design perfect to wear for all people who have a great sense of humor and are proud of their forename.
- Funny vintage style artwork with a personalized quote - "I'm Lottie Doing Lottie Things"
- Hardcover journal with 240 line-ruled pages (120 sheets)
- Built-in elastic closure and ribbon bookmark
- Includes an expandable inner storage pocket and a pen holder
Add controls and account for motion
The React player’s ref provides access to playback methods and events, which can support custom play, pause, stop, and seek controls. Use controls when users need to manage playback, and make their purpose clear in the interface. The React package documentation shows ref access and player events.
If an animation communicates information, provide an equivalent text explanation so that information is not available only through motion. If it is decorative, avoid letting it distract from content or create unnecessary announcements for assistive technology. The player documentation cited here does not prescribe a complete accessibility or reduced-motion implementation; consult authoritative accessibility guidance for the requirements applicable to your product.
Troubleshoot a missing, tiny, or distorted animation
- Check the integration: confirm the installed package matches the framework and that your import and component or API match its current documentation.
- Check the asset request: make sure the source URL resolves in the browser and points to the intended file.
- Check format support: confirm the player supports the asset format and any advanced features it uses, especially if the file uses a particular dotLottie version.
- Inspect the layout box: use browser developer tools to check the computed width and height of the element carrying the Tailwind classes. Inspect the canvas separately; styling its wrapper does not guarantee the canvas fills it.
- Check resizing and proportions: verify whether the player follows container changes, whether the layout needs an explicit height or aspect ratio, and whether the result is cropped or stretched.
- Check Tailwind output: if a utility appears to do nothing, confirm the project is configured to generate it and that its theme has not changed the expected breakpoint or utility.
- Retest across viewports: inspect the narrow layout and a wider layout at the breakpoints configured in your project.
Tailwind’s theme configuration affects responsive breakpoints and which utilities are available. The theme documentation explains the role of theme variables.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




