Create an image overlay, which comes in different styles.
Add the .uk-overlay class to an element following an image to create the overlay panel. To create a position context, add the .uk-inline class from the Utility component to a container element around both. Finally, add one of the .uk-position-* classes from the Position component to align the overlay.
<div class="uk-inline">
<img src="" width="" height="" alt="" />
<div class="uk-overlay uk-position-bottom"></div>
</div>
<div class="uk-inline">
<img src="/images/photo.jpg" width="1800" height="1200" alt="" />
<div class="uk-overlay uk-position-bottom">
<p>Default Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
</div> By default, the overlay has padding, but no additional styling. Add one of these modifier classes to add a background color to the overlay.
For a simple background color, add the .uk-overlay-default class. Or, you can use Tailwind CSS bg-* classes. You can even add backdrop-blur-* for blur effect.
<div class="uk-child-width-1-2@m" uk-grid>
<div>
<div class="uk-inline">
<img src="/images/photo.jpg" width="1800" height="1200" alt="" />
<div class="uk-overlay uk-overlay-default uk-position-bottom">
<p>Default Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
</div>
</div>
<div>
<div class="uk-inline">
<img src="/images/photo.jpg" width="1800" height="1200" alt="" />
<div class="uk-overlay-default uk-position-cover"></div>
<div class="uk-dark uk-overlay uk-position-bottom">
<p>Default Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
</div>
</div>
</div> For a prominent background color, add the .uk-overlay-primary class. Or, you can use Tailwind CSS bg-* classes. You can even add backdrop-blur-* for blur effect.
<div class="uk-child-width-1-2@m" uk-grid>
<div>
<div class="uk-inline">
<img src="/images/photo.jpg" width="1800" height="1200" alt="" />
<div class="uk-overlay uk-overlay-primary uk-position-bottom">
<p>Default Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
</div>
</div>
<div>
<div class="uk-inline">
<img src="/images/photo.jpg" width="1800" height="1200" alt="" />
<div class="uk-overlay-primary uk-position-cover"></div>
<div class="uk-overlay uk-position-bottom">
<p>Default Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
</div>
</div>
</div> To display an overlay icon, add the uk-overlay-icon attribute to a <span> element inside the overlay.
<div class="uk-position-center">
<span uk-overlay-icon></span>
</div>
<div class="uk-child-width-1-2@m" uk-grid>
<div>
<div class="uk-inline uk-light">
<img src="/images/dark.jpg" width="1800" height="1200" alt="" />
<div class="uk-position-center">
<span uk-overlay-icon></span>
</div>
</div>
</div>
<div>
<div class="uk-inline uk-dark">
<img src="/images/photo.jpg" width="1800" height="1200" alt="" />
<div class="uk-overlay-default uk-position-cover">
<div class="uk-position-center">
<span uk-overlay-icon></span>
</div>
</div>
</div>
</div>
</div> Add one of the .uk-position-* classes from the Position component to align the overlay.
<div class="uk-overlay uk-position-top"></div>
<div class="uk-child-width-1-2@m" uk-grid>
<div>
<div class="uk-inline">
<img src="/images/photo.jpg" width="1800" height="1200" alt="" />
<div class="uk-overlay uk-overlay-default uk-position-top">
<p>Top</p>
</div>
</div>
</div>
<div>
<div class="uk-inline">
<img src="/images/photo.jpg" width="1800" height="1200" alt="" />
<div class="uk-overlay uk-overlay-default uk-position-center">
<p>Center</p>
</div>
</div>
</div>
</div> On your tailwind.config.js file, add the
Overlay component within the ui() plugin.
import ui from "franken-ui";
ui({
components: {
overlay: {
hooks: {}
}
}
}),
Note If you are developing theme from scratch, you can use all these hooks. If you’re using the shadcn/ui theme, some hooks might not work as they were already in use or removed. Learn more about using hooks.
| Hook Name | Affected Classes |
|---|---|
hook-overlay | .uk-overlay |
hook-icon | .uk-overlay-icon |
hook-default | .uk-overlay-default |
hook-primary | .uk-overlay-primary |
hook-misc | * |