Backdrop

The dimmed, blurred layer behind an overlay, in the look of the app's style. The Dialog, Alert Dialog, Sheet and Drawer render it in theirs; use it on its own for an overlay of yours.

OverlayExperimental

Usage

import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScBackdrop, ScButton, ScFrame } from '@semantic-components/ui';
/** * Over a card here (absolute, in a positioned box); in an overlay it covers * the window. It fades in when shown and out when it goes. */@Component({  selector: 'app-backdrop-usage-demo',  imports: [ScBackdrop, ScButton, ScFrame],  template: `    <div class="flex flex-col items-center gap-4">      <div        scFrame        class="relative grid h-40 w-72 place-items-center overflow-hidden"      >        <p class="text-sm">The page behind</p>        @if (open()) {          <div scBackdrop class="absolute z-0"></div>        }      </div>      <button        scButton        variant="outline"        [attr.aria-pressed]="open()"        (click)="open.set(!open())"      >        Backdrop      </button>    </div>  `,  host: { class: 'flex w-full justify-center' },  encapsulation: ViewEncapsulation.None,})export class BackdropUsageDemo {  private readonly open = signal(false);}

Anatomy

One directive, on an empty div, shown with @if or inside an overlay.

import { ScBackdrop } from '@semantic-components/ui';
@if (open()) {  <div scBackdrop></div>}

Notes

  • It fades in when shown and out when it goes (animate.enter / animate.leave): Angular removes it once it has faded out.
  • It covers the window (fixed inset-0) behind the overlay's content; absolute puts it over a positioned box instead.
  • It takes no clicks and no focus, and is not read by screen readers: closing on a click outside, trapping focus and hiding the page are the overlay's.
  • Its shade and blur are the style's — shadcn's overlay, the same behind every overlay of a style: bg-black/10 with a light blur in nova, vega and lyra, /80 in maia and mira, /30 with more blur in luma and rhea, /20 in sera.

Examples

Custom Shade

The page behind

import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScBackdrop, ScButton, ScFrame } from '@semantic-components/ui';
/** * Your own shade: classes over the style's (cn: a later class wins) — here * a tint of the primary color, no blur. */@Component({  selector: 'app-custom-backdrop-demo',  imports: [ScBackdrop, ScButton, ScFrame],

API reference

ScBackdrop — div[scBackdrop]

InputTypeDefaultDescription
classstring'' Classes merged over the style (cn: a later class wins) — your own shade, its place.