Glass

Liquid Glass for the functional layer: regular, clear and prominent, as a capsule, rounded rectangle or circle.

foundation

Apple: Liquid Glass

· Base UI: element

Variants

Regular

Clear

Prominent

import { Home01Icon } from "@hugeicons/core-free-icons"

import { Glass } from "@applecn/ui/components/glass"
import { Icon } from "@applecn/ui/components/icon"
import { Text } from "@applecn/ui/components/text"

export default function GlassBasic() {
  return (
    <div className="flex flex-wrap items-center gap-4 rounded-4xl bg-[linear-gradient(135deg,var(--system-indigo),var(--system-cyan))] p-6">
      <Glass className="px-5 py-3">
        <Text variant="body" emphasized color="inherit">
          Regular
        </Text>
      </Glass>
      <Glass variant="clear" className="px-5 py-3 text-white">
        <Text variant="body" emphasized color="inherit">
          Clear
        </Text>
      </Glass>
      <Glass variant="prominent" className="px-5 py-3">
        <Text variant="body" emphasized color="inherit">
          Prominent
        </Text>
      </Glass>
      <Glass
        shape="circle"
        interactive
        className="flex size-11 items-center justify-center"
      >
        <Icon icon={Home01Icon} aria-label="Home" />
      </Glass>
    </div>
  )
}

Install

From the registry this site publishes, with dependencies resolved by the CLI.

npx shadcn@latest add https://applecn.vercel.app/r/glass.json

Source

packages/ui/src/components/glass.tsx

import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
import type { ComponentProps } from "react"

/**
 * Liquid Glass: the functional layer that floats above content (tab bars, toolbars, sheets,
 * menus). `regular` keeps text legible over anything; `clear` shows more of a rich background
 * and expects a dimming layer over bright content; `prominent` is the one tinted action. The
 * default shape is a capsule, as on iOS 26; `interactive` adds the press feedback.
 */
const glassVariants = cva("relative", {
  variants: {
    variant: {
      regular: "glass",
      clear: "glass-clear",
      prominent: "glass-prominent",
    },
    shape: {
      capsule: "rounded-full",
      rounded: "rounded-4xl",
      circle: "aspect-square rounded-full",
    },
    interactive: {
      true: "pressable",
      false: "",
    },
  },
  defaultVariants: {
    variant: "regular",
    shape: "capsule",
    interactive: false,
  },
})

type GlassProps = ComponentProps<"div"> & VariantProps<typeof glassVariants>

function Glass({
  className,
  variant = "regular",
  shape = "capsule",
  interactive = false,
  ...props
}: GlassProps) {
  return (
    <div
      data-slot="glass"
      data-variant={variant}
      data-shape={shape}
      className={cn(glassVariants({ variant, shape, interactive }), className)}
      {...props}
    />
  )
}

export { Glass, glassVariants }
export type { GlassProps }