Overlay

Default


Overlays help shift focus by dimming or masking background content. This kit supports gradient and solid color modes, with adjustable opacity to suit the context.

Gradient & Opacity


By default, the overlay is rendered as a gradient. Setting the gradient prop to false renders the overlay as a solid color. You can adjust the transparency of the solid overlay by using the opacity prop.

Color


The color prop is used to change the color of the solid or gradient mask. Gradient overlays always start opaque and fade to transparent.

NOTE: Images are set to display: block to remove the default inline spacing caused by line height. This ensures the image fully fills the container without unexpected gaps.

Layout


The optional layout prop accepts the position and size of the overlay as a key:value pair.

The position key accepts bottom (default), top, y (for both top and bottom) right, left, or x (for both left and right), which sets the side(s) where the color overlay starts. The direction of the overlay is always toward the opposite side of the position. For example, the default position of bottom starts the overlay on the bottom edge of your container and extends it toward the opposite side: the top.

The size value is full (100%) by default, but accepts our spacing tokens or a percentage value as a string, and literally translates to how much of the container is covered by the overlay(s).

Multi-directional


Optionally, you can pass multi-directional options (x or y) to the position key, which creates multiple overlays.

Your color is still applied as the starting edge to both overlays, and each mask will fade to transparent moving toward its opposite edge, ending at the size value you set.

NOTE: Multi-directional overlays share the available container space, so passing full or a percentage string greater than 50% to a multi-directional overlay will cause your masks to overlap at the midline of your container. As a best practice, we do not recommend exceeding a percentage size of 25% when using multi-directional overlays.

Vertical Dynamic Multi-directional


Pass the dynamic prop to make the overlay render while the scrollbar isn't at either end on the scrollbar.

Toggle


To toggle an overlay, add a button with an event handler. Remove the overlay container to reveal the underlying content. Re-wrap the overlay container to add the overlay back.

Hide Scroll Bar


Pass the scrollBarNone prop to hide the scrollbar from view. This is particularly helpful for small containers where the scrollbar may occupy too much space.

Full Page Opacity


To enable the overlay to cover the full size of your screen, you can pass the fullScreen prop. You can also pass an opacity along with it.

Full Page Using Background Color Tokens


The fullScreen prop also allows you to use color along with it.


Available Props