glasscn
ShowcaseDocsComponentsStudioThemingNative
5Get started
Guides
IntroductionInstallationThemingFonts & typeStudioReact Native
Surfaces
AuroraBackdropGlassLiquid glassCardTheme scopeBackground extensionScroll areaAccordionCollapsibleAlertItemEmpty
Typography
TypographyProse
Controls
ButtonBadgeInputTextareaLabelSwitchCheckboxSegmented controlTabsGlass groupGlass clusterGlass morphSliderProgressKbdSeparatorAvatarGlass preferencesComboboxCalendarDate pickerSpinnerSkeletonSelectRadio groupFieldInput groupButton groupToggleToggle groupStepper
Overlays
DialogAlert dialogSheetAction sheetPopoverTooltipDropdown menuToasterCommandDrawerContext menuConfirmation popover
Navigation
DockToolbarScroll edgeNavigation barSidebarSearch fieldGrouped list
Data
Activity ringsProgress ringSparklineStatKPIWidgetRange chartBar listGaugeTrackerCategory barHeatmapChartArea chartBar chartLine chartDonut chartTableData table
Chat
ChatChat markdownChat parts
Blocks
More Apple glass examplesLiquid Glass examplesDashboardAnalyticsSettingsSign inChat
glasscn — a shadcn registry. Copy it, own it, change it.DocsThemingregistry.json
Surfaces

Background extension

Mirrored, softened imagery continues beneath leading and trailing chrome. Foreground content renders once.

Installation

pnpm dlx shadcn@latest add https://glasscn.app/r/background-extension.json

React Native (iOS, Android and web through react-native-web) — same parts and props:

pnpm dlx shadcn@latest add https://glasscn.app/r/native-background-extension.json

Or with the namespace set up: shadcn add @glasscn-app/background-extension

Props

PropTypeDefault
src / altstring

The image and its accessible description. Foreground children remain separate and render once.

—
start / endnumber

Mirrored, softened image strips beneath leading/trailing chrome, in pixels. Logical directions follow RTL.

0

Apply readable overlays after the image. This image-only browser/RN composition approximates backgroundExtensionEffect; it is not a claim that Expo exposes Apple's modifier.

Source

components/glass/background-extension.tsx
"use client"

import * as React from "react"
import { cn } from "@/lib/glass-cn"

export type BackgroundExtensionProps = React.ComponentProps<"div"> & {
  src: string
  alt?: string
  /** Image-only extensions beneath leading/trailing chrome, in pixels. */
  start?: number
  end?: number
}

/** Mirror imagery beneath surrounding chrome. Foreground children render once. */
export function BackgroundExtension({ src, alt = "", start = 0, end = 0, className, style, children, ref: forwardedRef, ...props }: BackgroundExtensionProps) {
  const root = React.useRef<HTMLDivElement>(null)
  React.useImperativeHandle(forwardedRef, () => root.current as HTMLDivElement)
  React.useLayoutEffect(() => {
    const el = root.current
    if (!el) return
    const update = () => el.style.setProperty("--glass-extension-width", `${el.getBoundingClientRect().width}px`)
    update()
    const observer = new ResizeObserver(update)
    observer.observe(el)
    return () => observer.disconnect()
  }, [])
  const extent = (value: number) => Number.isFinite(value) ? Math.max(0, value) : 0
  const mirror = (side: "start" | "end", width: number) => width > 0 ? <div key={side} data-slot="background-extension-mirror" data-side={side} aria-hidden inert className="pointer-events-none absolute inset-y-0 -z-10 overflow-hidden" style={{ width, [side === "start" ? "insetInlineEnd" : "insetInlineStart"]: "100%" }}>
    {/* a light blur: the chrome above is glass and diffuses it again, so a full blur here washes it out */}
    {/* eslint-disable-next-line @next/next/no-img-element */}
    <img src={src} alt="" className="absolute inset-y-0 h-full max-w-none -scale-x-100 object-cover blur-[calc(var(--glass-blur)/3)]" style={{ width: "var(--glass-extension-width)", [side === "start" ? "insetInlineEnd" : "insetInlineStart"]: 0 }} />
  </div> : null
  return <div ref={root} data-slot="background-extension" className={cn("relative isolate w-full", className)} style={{ aspectRatio: "16 / 9", ...style }} {...props}>
    {mirror("start", extent(start))}{mirror("end", extent(end))}
    {/* eslint-disable-next-line @next/next/no-img-element */}
    <img data-slot="background-extension-image" src={src} alt={alt} className="absolute inset-0 -z-10 size-full object-cover" />
    {children}
  </div>
}
Glass clusterGlass morph
Mountain peaks above a lake

A quieter place