This browser is not supported. The glass needs a Chromium browser or Electron. Why

Getting started

One package, ESM with types. Every component is a client component and unused ones are tree-shaken. React 19 or newer; no bundler plugins.

Install

terminal
npm i @adamexu/glass

Wrap your app in a GlassProvider. Each component imports its own stylesheet, so there is nothing else to import. Glass outside a provider still works with the defaults: the light scheme at iOS's default tint amount of 50%.

Next.js

The provider is a client component, so it can sit straight in a server layout.

// app/layout.tsx
import { GlassProvider } from "@adamexu/glass";

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <body>
        <GlassProvider>{children}</GlassProvider>
      </body>
    </html>
  );
}
// app/page.tsx
import { Button, GlassEffect } from "@adamexu/glass";

export default function Page() {
  return (
    <main>
      <GlassEffect width={260} height={80}>Hello</GlassEffect>
      <Button buttonStyle="glassProminent">Continue</Button>
    </main>
  );
}

The server render draws no glass, only its box and content: the glass's maps are built in the browser after it mounts, so markup always matches. Turbopack and webpack both work as is.

Vite

// main.tsx
import { GlassProvider } from "@adamexu/glass";
import { createRoot } from "react-dom/client";
import { App } from "./App";

createRoot(document.getElementById("root")!).render(
  <GlassProvider>
    <App />
  </GlassProvider>,
);

Workers are started with new URL("./x.worker.js", import.meta.url), which Vite, webpack and Turbopack all emit as files of your own origin. In vite dev, keep the package out of pre-bundling so those URLs resolve:

// vite.config.ts
export default defineConfig({
  plugins: [react()],
  optimizeDeps: { exclude: ["@adamexu/glass"] },
});

Appearance

The provider does not read the system appearance. Pass the scheme your app uses, and the tint amount if you offer the setting (0 is most clear, 1 most tinted):

<GlassProvider scheme={dark ? "dark" : "light"} tintAmount={0.5}>

Electron

Electron ships Chromium, so every user gets the real glass, which makes it a great fit for desktop apps. A renderer with a CSP meta needs data images and same-origin workers:

<meta
  http-equiv="Content-Security-Policy"
  content="default-src 'self'; img-src 'self' data:; worker-src 'self'"
/>

The repository has a working Electron example.

Content Security Policy

  • Maps are drawn as data: images inside SVG filters: allow img-src data:.
  • Maps are built in module workers that your bundler emits next to your scripts: allow worker-src 'self'.
  • When no worker can start, maps are built on the main thread. The glass is identical; first paints are slower.

shadcn/ui

The registry has thin wrappers that take your theme tokens: a glass base item (a provider that follows the .dark class, and the font and focus ring mapped to your theme) and one item per component.

terminal
npx shadcn@latest add https://glass.axu.dev/r/glass-button.json

Items: glass-button, glass-switch, glass-slider, glass-segmented-control, glass-progress, glass-alert-dialog, glass-dropdown-menu, glass-popover, glass-sheet, glass-tab-view, glass-card.

Fonts

Inter ships with the package. The components' stylesheets load the weights they use from the package itself, so the text in controls, bars and lists matches iOS's metrics without any setup. Inter is under the SIL Open Font License 1.1, which ships beside the fonts.

Browser support

The glass is made of SVG filters in backdrop-filter, which only Chromium renders: Chrome, Edge, Arc, Brave, Opera, Android Chrome, and Electron. It is built and checked against Chrome. Other browsers, including Safari, Firefox and every browser on iOS, are not supported, and there is no fallback.

Rules that keep it fast

  • Never put opacity, filter, mask, clip-path or backdrop-filter on an ancestor of glass. It cuts the glass off from the page. Fade glass with --glass-alpha on the glass itself instead.
  • Move glass with transforms, and keep the backdrop static behind glass that does not move.
  • A live glass costs about 65 of the roughly 110 render passes Chrome fits in a 120 Hz frame. Glass that scrolls with the page can share filters inside a GlassGroup.