Glass
A glass pane — material (content) or liquid (control layer, regular or clear). Intensity, tint and elevation variants; asChild.
Installation
pnpm dlx shadcn@latest add https://glasscn.app/r/glass.jsonReact Native (iOS, Android and web through react-native-web) — same parts and props:
pnpm dlx shadcn@latest add https://glasscn.app/r/native-glass.jsonOr with the namespace set up: shadcn add @glasscn-app/glass
Props
| Prop | Type | Default |
|---|---|---|
| variant | "material" | "liquid" | "liquid-clear"material: the content layer (cards, panes), frosted by intensity. liquid: the control layer floating over content (toolbars, floating buttons). liquid-clear: over photos and video only. Never liquid inside liquid — use fills inside it. | "material" |
| intensity | "ultraThin" | "thin" | "regular" | "thick" | "default" | "strong" | "subtle"Four named standard materials; existing subtle/default/strong names map to ultraThin/thin/regular. Web values approximate native system materials. | "default" |
| tint | "none" | "primary" | "destructive"Mixes a colour into the frost via --glass-bg. | "none" |
| elevation | "raised" | "flat"Drop shadow on or off (--glass-elevation). | "raised" |
| asChild | booleanRender the child element as the pane. | false |
Source
import * as React from "react"
import { cn } from "@/lib/glass-cn"
import { Slot } from "radix-ui"
import { glassVariants, type GlassVariantProps } from "@/lib/glass-variants"
/**
* A frosted pane: the base every glasscn surface is made from.
* Blurs and saturates whatever is behind it, rimmed with a light edge.
*
* `variant="material"` (default) is the content layer — cards and panes, frosted by
* `intensity`. `variant="liquid"` is the control layer — things floating over content
* (toolbars, floating buttons). `variant="liquid-clear"` is for over photos and video only.
* Never put liquid inside liquid: inside a liquid pane use fills (`bg-fill`).
*/
function Glass({
className,
variant,
intensity,
tint,
elevation,
asChild = false,
...props
}: React.ComponentProps<"div"> & GlassVariantProps & { asChild?: boolean }) {
const Comp = asChild ? Slot.Root : "div"
return (
<Comp
data-slot="glass"
data-variant={variant ?? "material"}
data-intensity={intensity ?? "default"}
className={cn(glassVariants({ variant, intensity, tint, elevation }), "rounded-surface", className)}
{...props}
/>
)
}
export { Glass, glassVariants }