3 Topics
Chapter•55 Minutes

Borders, Shadows, Transforms, and Effects

Polish interfaces with border utilities, rings, shadows, transforms, gradients, filters, and intentional motion.

Borders, rings, and rounded corners

Border utilities include border, directional borders such as border-b, color utilities such as border-slate-200, and radius utilities such as rounded-lg or rounded-full. Rings are useful for emphasis and focus indicators because they draw an outline-like effect without changing the element's layout in the same way a border can.

Use a consistent radius scale. A large radius on every nested element can make a UI look overly soft; choose radii based on hierarchy, such as a larger page card and a smaller control inside it.

Layered card and focus ring
<div class="rounded-2xl border border-slate-200 bg-white p-5">
  <div class="flex items-center justify-between">
    <h2 class="font-semibold">Notifications</h2>
    <button class="rounded-md px-2 py-1 text-sm text-slate-600 hover:bg-slate-100 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600">Manage</button>
  </div>
  <p class="mt-2 text-sm text-slate-600">You are all caught up.</p>
</div>
💡 The outer card uses a larger radius and subtle border. The button has its own smaller radius and a visible focus outline. The hierarchy comes from surface, spacing, and shape together.
Key Takeaways
  • Use a consistent radius and border scale.
  • Focus rings must remain visible against surrounding surfaces.
  • Do not rely on shadows alone to define component boundaries.

Shadows, gradients, and opacity

Shadows can communicate elevation, but too many strong shadows create visual noise. Use subtle shadows for cards and stronger elevation for overlays when it fits the design. Gradients use background utilities and can create emphasis, but text placed on a gradient still needs sufficient contrast across every part of the gradient.

Opacity modifies how an element or color is rendered. Applying opacity to a parent affects its descendants too; a translucent background color is often better when only the surface should be transparent.

Gradient hero panel
<section class="overflow-hidden rounded-2xl bg-gradient-to-br from-blue-700 via-indigo-700 to-violet-800 p-8 text-white shadow-lg sm:p-12">
  <p class="text-sm font-semibold text-blue-100">WEEKLY INSIGHT</p>
  <h2 class="mt-3 max-w-xl text-3xl font-bold tracking-tight">Your team is building momentum.</h2>
  <p class="mt-4 max-w-xl leading-7 text-indigo-100">Completion is up this week. Keep the next milestone visible and actionable.</p>
</section>
💡 The gradient creates visual focus while light text colors preserve hierarchy. overflow-hidden clips the background to the rounded corners; use it only if clipping descendant content is acceptable.
Knowledge Check

Why can `opacity-50` on a parent be a poor choice for a translucent card background?

Transforms, transitions, and reduced motion

Transforms such as scale-*, translate-*, and rotate-* can add subtle interaction feedback. Transforms generally do not change the normal document flow, so large movements may overlap neighboring content. Transition only the properties that need animation and keep durations short enough to feel responsive.

Respect reduced-motion preferences. Avoid making important information available only through animation, and provide a reduced-motion alternative for nonessential movement. For complex animations, CSS keyframes or an animation library may be more appropriate than stacking many utility classes.

Motion should explain state

Use animation to signal a change or affordance—not as decoration that competes with reading or makes the interface slower.

Subtle card interaction
<a href="#details" class="block rounded-xl border bg-white p-5 transition duration-200 hover:-translate-y-0.5 hover:shadow-md motion-reduce:transform-none motion-reduce:transition-none">
  <h3 class="font-semibold">Read the release notes</h3>
  <p class="mt-2 text-sm text-slate-600">Review what changed in the latest version.</p>
</a>
💡 The card lifts slightly and gains shadow on hover. motion-reduce: removes movement and transition for users who request reduced motion. The link remains functional without animation.