Box Shadow

    Utilities for controlling the box shadow of an element.

    Use the , shadow, shadow-md, shadow-lg, shadow-xl, or shadow-2xl utilities to apply different sized outer box shadows to an element.

    Adding an inner shadow

    Use the shadow-inner utility to apply a subtle inset box shadow to an element. This can be useful for things like form controls or wells.

    Box Shadow - 图2

    1. <div class="shadow-inner ..."></div>


    Hover, focus, and other states

    Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:shadow-lg to only apply the shadow-lg utility on hover.

    1. <!-- ... -->
    2. </div>

    For a complete list of all available state modifiers, check out the documentation.

    You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:shadow-lg to apply the shadow-lg utility at only medium screen sizes and above.

    To learn more, check out the documentation on , Dark Mode and .


    Customizing your theme

    If a DEFAULT shadow is provided, it will be used for the non-suffixed shadow utility. Any other keys will be used as suffixes, for example the key '2' will create a corresponding utility.

    tailwind.config.js

    1. theme: {
    2. extend: {
    3. boxShadow: {
    4. '3xl': '0 35px 60px -15px rgba(0, 0, 0, 0.3)',
    5. }
    6. }
    7. }

    Learn more about customizing the default theme in the theme customization documentation.

    If you need to use a one-off box-shadow value that doesn’t make sense to include in your theme, use square brackets to generate a property on the fly using any arbitrary value.

    Learn more about arbitrary value support in the arbitrary values documentation.