Information about cookies on this page

Our website uses cookies to ensure the functionality of the website, to collect and analyze information about the performance and usage of the website. Privacy Policy

  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in
  
  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in

Shadows

A soft shadow makes a card look as if it were floating a little above the page. In CSS, a shadow is made with the box-shadow property, which the CSS course didn't cover. Its value describes the shadow:

box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  • 0: how far the shadow moves to the right (a negative value moves it to the left);
  • 10px: how far it moves down (negative: up). A shadow below an element looks as if the light came from above;
  • 15px: the blur: the larger the value, the softer the edge of the shadow;
  • -3px: the spread: a positive value makes the shadow larger than the element, a negative one smaller;
  • rgb(0 0 0 / 0.1): the color, here black with an alpha of 0.1, so 90% transparent. It's the newer notation with a slash that you saw in the CSS course.

You can write several shadows separated by commas, and most of Tailwind's shadows use two at once to look more natural. You don't have to remember the values: you just choose a size. This is what they look like:

shadow-xs
shadow-sm
shadow-md
shadow-lg
shadow-xl
shadow-2xl

So, for example, shadow-lg means this (Tailwind writes it with variables, so that it can be combined with other classes, but the result is the same):

.shadow-lg {
	box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

As with rounded corners, the names changed in Tailwind 4: in older examples, shadow-sm is today's shadow-xs, and shadow is today's shadow-sm. shadow-none removes a shadow.

A shadow is black by default, but you can give it a color from the palette: shadow-lg shadow-orange-200 makes a light orange glow. On a light page, choose gentle shadows: big, dark ones look heavy. Our card already has a light border, and together with a shadow, it stands out from the page nicely.

Instructions

  1. 1

    Add the class shadow-lg to Oscar's card.

Back

4/10

  1. 1. Borders
  2. 2. Border on One Side
  3. 3. Rounded Corners
  4. 4. Shadows
  5. 5. Images
  6. 6. Aspect Ratio
  7. 7. Rounded Corners on Pictures
  8. 8. Opacity
  9. 9. A Card from Scratch
  10. 10. Summary
Next

Try it yourself

Do this exercise right here in your browser. No account needed.