Performance: Box shadow utilities
Box shadow utilities affect the paint and composite stages of page rendering, impacting how quickly shadows appear and how smoothly the page scrolls or animates.
Jump into concepts and practice - no test required
class="shadow-sm" applied selectively to key elements onlyclass="shadow-[0_0_20px_10px_rgba(0,0,0,0.5)]" applied to 100+ elements
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Heavy custom shadows on many elements | Low | 0 | High (many pixels to paint) | [X] Bad |
| Simple Tailwind shadow utilities on few elements | Low | 0 | Low (small shadow area) | [OK] Good |
shadow-lg do to an element?shadow-lgshadow-lg class in Tailwind adds a large box shadow around an element, making it appear elevated.shadow-none which removes shadows, or shadow-inner which adds inner shadows, shadow-lg adds a bigger outer shadow.shadow-lg means large shadow [OK]shadow-lg with shadow-innershadow-none to remove all box shadows from an element.shadow-remove, no-shadow, and shadow-clear do not exist in Tailwind's box shadow utilities.shadow-none removes shadows [OK]shadow-none to clear shadows [OK]shadow-removeno-shadow is valid<div class="shadow-inner shadow-md p-4">Content</div>
shadow-inner and shadow-mdshadow-inner adds an inner shadow inside the element. shadow-md adds a medium outer shadow. Since shadow-md comes after shadow-inner in the class attribute, Tailwind applies it later and it overrides the box-shadow property, resulting in a medium outer shadow.p-4 adds padding inside the element around the content.shadow-md overrides as last shadow class [OK]shadow-inner instead of shadow-sm. What is the main visual difference?shadow-inner vs shadow-smshadow-inner adds a shadow inside the element edges, creating an inset effect. shadow-sm adds a small outer shadow around the element.shadow-innershadow-inner instead of shadow-sm means the shadow appears inside the button edges, not outside, changing the intended look.shadow-inner = inside shadow, not outside [OK]shadow-inner means inside shadow, not outside [OK]shadow-inner adds outer shadowmd: apply at medium screen sizes and above. Without prefix, classes apply to all screen sizes.shadow-none md:shadow-sm means no shadow on small screens, and a small shadow starting at medium screens. This matches the requirement.shadow-sm md:shadow-none reverses the logic, showing shadow on small screens and none on medium. shadow-md sm:shadow-none uses sm: which applies at small screens, not medium. shadow-inner md:shadow-lg uses shadow-inner and large shadow which is not subtle.shadow-none md:shadow-sm -> Option Dshadow-none then md:shadow-sm for responsive shadows [OK]shadow-none then md:shadow-sm for responsive shadows [OK]sm: and md: