search results:

    • Standard
    • React
    Pricing Learn Community
    • + D
    • Light
    • Dark
    • System
    logo TW Elements
    • Getting started
      • Quick start
      • Tutorials
      • Design system
      • Local installation
      • Optimization
      • Dark mode
      • Theming
      • Changelog
      • Migrating to v2
      • Internationalization guide
      • Class customization
      • Icons Integration
    • CommercialNew
      • Pricing
      • License
      • Installation
      • Git & repository
      • Premium Support
    • Integrations
      • Angular
      • ASP.NET
      • Django
      • Express
      • Laravel
      • Next
      • Nuxt
      • Qwik
      • React
      • Remix
      • Solid
      • Svelte
      • SvelteKit
      • Vue
    • Content & styles
      • Animations
      • Animations Extended
      • Colors
      • Dividers
      • Figures
      • Headings
      • Hover effects
      • Icons
      • Images
      • Mask
      • Shadows
      • Typography
    • Navigation
      • Breadcrumbs
      • Footer
      • Headers
      • Mega menu
      • Navbar
      • Offcanvas
      • Pagination
      • Pills
      • Scrollspy
      • Sidenav
      • Tabs
    • Components
      • Accordion
      • Alerts
      • Avatar
      • Badges
      • Button group
      • Buttons
      • Cards
      • Carousel
      • Chips
      • Collapse
      • Dropdown
      • Gallery
      • Jumbotron
      • Lightbox
      • Link
      • List group
      • Modal
      • Notifications
      • Paragraphs
      • Placeholders
      • Popconfirm
      • Popover
      • Progress
      • Rating
      • Scroll back to top button
      • Social buttons
      • Spinners
      • Stepper
      • Testimonials
      • Timeline
      • Toast
      • Tooltip
      • Video
      • Video carousel
    • Forms
      • Autocomplete
      • Checkbox
      • Datepicker
      • Datetimepicker
      • File input
      • Form templates
      • Input Group
      • Inputs
      • Login form
      • Multi range slider
      • Radio
      • Range
      • Registration form
      • Search
      • Select
      • Switch
      • Textarea
      • Timepicker
      • Validation
    • Data
      • Charts
      • Charts advanced
      • Datatables
      • Tables
    • Methods
      • Clipboard
      • Infinite scroll
      • Lazy loading
      • Loading management
      • Ripple
      • Scrollbar
      • Smooth scroll
      • Sticky
      • Touch
    • Design Blocks
      • Admin Charts
      • Admin Complex
      • Admin Forms
      • Admin Maps
      • Admin Navigation
      • Admin tables
      • Banners
      • Contact
      • Content
      • CTA
      • FAQ
      • Features
      • Headers
      • Hero / Intro sections
      • Logo clouds
      • Mega menu
      • News
      • Newsletter
      • Pricing
      • Projects
      • Stats
      • Stats admin
      • Team
      • Testimonials
    • Tools
      • Button generator
      • Card generator
      • Flexbox generator
      • Footer generator
      • Form builder
      • Grid generator
      • Icon generator
      • Instagram Filters generator
      • Logo generator
      • Table generator
      • Typography generator
    • Coming Soon
      • Angular
      • Builder
      • Templates
      • Vue
    • Resources
      • Playground
      • YouTube Channel
      • Private FB Group
      • Newsletter
      • UI Design course New
      • UI / UX tips

    Mask

    Tailwind CSS Mask

    Responsive mask built with Tailwind CSS. Masks are used to make content more visible by providing a proper contrast. Download for free without registration.


    Basic example

    Use code below to add mask on top of image to provide contrast a proper contrast.

    • HTML
            
                
          <div
            class="relative max-w-xs overflow-hidden bg-cover bg-[50%] bg-no-repeat">
            <img
              src="https://tecdn.b-cdn.net/img/Photos/Others/mewa.jpg"
              class="max-w-xs" />
            <div
              class="absolute bottom-0 left-0 right-0 top-0 h-full w-full overflow-hidden bg-black bg-fixed opacity-50"></div>
          </div>
          
            
        

    Hey there 👋 we're excited about TW elements and want to see it grow! If you enjoy it, help the project grow by sharing it with your peers. Every share counts, thank you!

    Color

    By manipulating classes you can change the color and opacity of the mask.

    • HTML
            
                
          <div class="grid grid-cols-3 gap-4">
            <div class="mb-4">
              <div
                class="relative w-full overflow-hidden bg-cover bg-[50%] bg-no-repeat">
                <img
                  src="https://tecdn.b-cdn.net/img/Photos/Others/mewa.jpg"
                  class="w-full" />
                <div
                  class="absolute bottom-0 left-0 right-0 top-0 h-full w-full overflow-hidden bg-indigo-700 bg-fixed opacity-50"></div>
              </div>
            </div>
            <div class="mb-4">
              <div
                class="relative w-full overflow-hidden bg-cover bg-[50%] bg-no-repeat">
                <img
                  src="https://tecdn.b-cdn.net/img/Photos/Others/mewa.jpg"
                  class="w-full" />
                <div
                  class="absolute bottom-0 left-0 right-0 top-0 h-full w-full overflow-hidden bg-purple-700 bg-fixed opacity-50"></div>
              </div>
            </div>
            <div class="mb-4">
              <div
                class="relative w-full overflow-hidden bg-cover bg-[50%] bg-no-repeat">
                <img
                  src="https://tecdn.b-cdn.net/img/Photos/Others/mewa.jpg"
                  class="w-full" />
                <div
                  class="absolute bottom-0 left-0 right-0 top-0 h-full w-full overflow-hidden bg-green-700 bg-fixed opacity-50"></div>
              </div>
            </div>
          </div>
          <div class="grid grid-cols-3 gap-4">
            <div class="mb-4 md:mb-0">
              <div
                class="relative w-full overflow-hidden bg-cover bg-[50%] bg-no-repeat">
                <img
                  src="https://tecdn.b-cdn.net/img/Photos/Others/mewa.jpg"
                  class="w-full" />
                <div
                  class="absolute bottom-0 left-0 right-0 top-0 h-full w-full overflow-hidden bg-red-700 bg-fixed opacity-50"></div>
              </div>
            </div>
            <div class="mb-4 md:mb-0">
              <div
                class="relative w-full overflow-hidden bg-cover bg-[50%] bg-no-repeat">
                <img
                  src="https://tecdn.b-cdn.net/img/Photos/Others/mewa.jpg"
                  class="w-full" />
                <div
                  class="absolute bottom-0 left-0 right-0 top-0 h-full w-full overflow-hidden bg-white bg-fixed opacity-50"></div>
              </div>
            </div>
            <div class="mb-4 md:mb-0">
              <div
                class="relative w-full overflow-hidden bg-cover bg-[50%] bg-no-repeat">
                <img
                  src="https://tecdn.b-cdn.net/img/Photos/Others/mewa.jpg"
                  class="w-full" />
                <div
                  class="absolute bottom-0 left-0 right-0 top-0 h-full w-full overflow-hidden bg-blue-300 bg-fixed opacity-50"></div>
              </div>
            </div>
          </div>
          
            
        

    Gradient

    You can even use a fancy gradient as a mask.

    • HTML
            
                
          <div
            class="relative max-w-xs overflow-hidden bg-cover bg-[50%] bg-no-repeat">
            <img
              src="https://tecdn.b-cdn.net/img/Photos/Others/mewa.jpg"
              class="max-w-xs" />
            <div
              class="absolute bottom-0 left-0 right-0 top-0 h-full w-full overflow-hidden bg-gradient-to-r from-indigo-500 via-purple-500 to-pink-500 opacity-70"></div>
          </div>
          
            
        

    Opacity

    By changing the class you can manipulate the opacity of the mask.

    • HTML
            
                
          <div class="grid grid-cols-3 gap-4">
            <div class="mb-4">
              <div
                class="relative w-full overflow-hidden bg-cover bg-[50%] bg-no-repeat">
                <img
                  src="https://tecdn.b-cdn.net/img/Photos/Others/mewa.jpg"
                  class="w-full" />
                <div
                  class="absolute bottom-0 left-0 right-0 top-0 h-full w-full overflow-hidden bg-black bg-fixed opacity-10"></div>
              </div>
            </div>
            <div class="mb-4">
              <div
                class="relative w-full overflow-hidden bg-cover bg-[50%] bg-no-repeat">
                <img
                  src="https://tecdn.b-cdn.net/img/Photos/Others/mewa.jpg"
                  class="w-full" />
                <div
                  class="absolute bottom-0 left-0 right-0 top-0 h-full w-full overflow-hidden bg-black bg-fixed opacity-30"></div>
              </div>
            </div>
            <div class="mb-4">
              <div
                class="relative w-full overflow-hidden bg-cover bg-[50%] bg-no-repeat">
                <img
                  src="https://tecdn.b-cdn.net/img/Photos/Others/mewa.jpg"
                  class="w-full" />
                <div
                  class="absolute bottom-0 left-0 right-0 top-0 h-full w-full overflow-hidden bg-black bg-fixed opacity-50"></div>
              </div>
            </div>
          </div>
          <div class="grid grid-cols-3 gap-4">
            <div class="mb-4 md:mb-0">
              <div
                class="relative w-full overflow-hidden bg-cover bg-[50%] bg-no-repeat">
                <img
                  src="https://tecdn.b-cdn.net/img/Photos/Others/mewa.jpg"
                  class="w-full" />
                <div
                  class="absolute bottom-0 left-0 right-0 top-0 h-full w-full overflow-hidden bg-black bg-fixed opacity-70"></div>
              </div>
            </div>
            <div class="mb-4 md:mb-0">
              <div
                class="relative w-full overflow-hidden bg-cover bg-[50%] bg-no-repeat">
                <img
                  src="https://tecdn.b-cdn.net/img/Photos/Others/mewa.jpg"
                  class="w-full" />
                <div
                  class="absolute bottom-0 left-0 right-0 top-0 h-full w-full overflow-hidden bg-black bg-fixed opacity-80"></div>
              </div>
            </div>
            <div class="mb-4 md:mb-0">
              <div
                class="relative w-full overflow-hidden bg-cover bg-[50%] bg-no-repeat">
                <img
                  src="https://tecdn.b-cdn.net/img/Photos/Others/mewa.jpg"
                  class="w-full" />
                <div
                  class="absolute bottom-0 left-0 right-0 top-0 h-full w-full overflow-hidden bg-black bg-fixed opacity-90"></div>
              </div>
            </div>
          </div>
          
            
        

    Content

    The main purpose of the mask is to provide an appropriate contrast between the image and its content. The most common use of masks is to put text on an image.

    Can you see me?

    • HTML
            
                
          <div
            class="relative max-w-xs overflow-hidden bg-cover bg-[50%] bg-no-repeat">
            <img
              src="https://tecdn.b-cdn.net/img/Photos/Others/mewa.jpg"
              class="max-w-xs" />
            <div
              class="absolute bottom-0 left-0 right-0 top-0 h-full w-full overflow-hidden bg-fixed"
              style="background-color: hsla(0, 0%, 0%, 0.6)">
              <div class="flex h-full items-center justify-center">
                <p class="text-white opacity-100">Can you see me?</p>
              </div>
            </div>
          </div>
          
            
        

    Ripple

    You can easily add a ripple effect to the image with a mask.

    • HTML
            
                
          <div class="grid grid-cols-2 gap-4">
            <div>
              <div
                class="relative w-full overflow-hidden bg-cover bg-no-repeat"
                data-twe-ripple-init
                data-twe-ripple-color="light">
                <img
                  src="https://tecdn.b-cdn.net/img/Photos/Others/mewa.jpg"
                  class="w-full" />
                <div
                  class="absolute bottom-0 left-0 right-0 top-0 h-full w-full overflow-hidden bg-fixed"
                  style="background-color: hsla(0, 0%, 98%, 0.6)"></div>
              </div>
            </div>
            <div>
              <div
                class="relative w-full overflow-hidden bg-cover bg-no-repeat"
                data-twe-ripple-init>
                <img
                  src="https://tecdn.b-cdn.net/img/Photos/Others/mewa.jpg"
                  class="w-full" />
                <div
                  class="absolute bottom-0 left-0 right-0 top-0 h-full w-full overflow-hidden bg-fixed"
                  style="background-color: hsla(0, 0%, 0%, 0.6)"></div>
              </div>
            </div>
          </div>
          
            
        

    Link regular

    Wrap a mask to change the image into a clickable link.

    Use regular link to get image with ripple without additional effect.

    • HTML
            
                
          <div class="relative max-w-xs overflow-hidden bg-cover bg-no-repeat">
            <img
              src="https://tecdn.b-cdn.net/img/Photos/Others/mewa.jpg"
              class="max-w-xs" />
            <a href="#!">
              <div
                class="absolute bottom-0 left-0 right-0 top-0 h-full w-full overflow-hidden bg-neutral-900 bg-fixed opacity-60"></div>
            </a>
          </div>
          
            
        

    Link with ripple

    Add data-twe-ripple-init utility with image to achieve an additional ripple effect.

    • HTML
    • javascript
            
                
          <div
            class="relative max-w-xs overflow-hidden bg-cover bg-no-repeat"
            data-twe-ripple-init
            data-twe-ripple-color="light">
            <img
              src="https://tecdn.b-cdn.net/img/Photos/Others/mewa.jpg"
              class="max-w-xs" />
            <a href="#!">
              <div
                class="absolute bottom-0 left-0 right-0 top-0 h-full w-full overflow-hidden bg-neutral-200 bg-fixed opacity-60"></div>
            </a>
          </div>
          
            
        
            
                
          // Initialization for ES Users
          import {
            Ripple,
            initTWE,
          } from "tw-elements";
          
          initTWE({ Ripple });
          
            
        

    Related resources

    Tutorials:

    colors hover state fullscreen background image masks hsla colors ripple effect carousel rounded corners shadows sizing

    Extended Docs:

    colors hover effects images shadows headers carousel gallery jumbotron video video carousel ripple background image background position colors gradient text opacity parallax

    Generators and builders:

    Form drag & drop Typography SVG icon Instagram Filters button card table flexbox logo grid footer

    Design System (Figma):

    introduction content should be the star lowering the contrast user experience do not start with the roof project personality design system plan the process principles tips and tricks
    • Basic example
    • Color
    • Gradient
    • Opacity
    • Content
    • Ripple
    • Link regular
    • Link with ripple
    • Related resources
    Get useful tips & free resources directly to your inbox along with exclusive subscriber-only content.
    Join our mailing list now
    © 2024 Copyright: MDBootstrap.com

    Access restricted

    To view this section you must have an active PRO account

    Log in to your account or purchase an TWE subscription if you don't have one.

    Buy TWE PRO