> ## Documentation Index
> Fetch the complete documentation index at: https://glassen.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Glass components in React

> Render React children inside a glass lens, share one surface across lenses and keep animated sources outside DOM snapshots with explicit cleanup.

Glassen's React entry point mounts and releases the renderer with your component. Import the layout stylesheet once and initialize the WASM asset before rendering the application.

```jsx theme={null}
import { initGlass } from 'glassen'
import wasmUrl from 'glassen/wasm/goo_core_bg.wasm?url'
import { Glass } from 'glassen/react'
import 'glassen/style.css'

// Run in your browser entry point before mounting React.
await initGlass(wasmUrl)

export function Example() {
  return (
    <Glass size={320} appearance="light" label="Elastic glass. Use arrow keys to stretch.">
      <span style={{ fontSize: 48 }}>hello</span>
    </Glass>
  )
}
```

Children are captured with `modern-screenshot`. DOM mutations, size changes and font loads invalidate the snapshot. This does not capture arbitrary content behind the component. Use an explicit [source](https://glassen.mintlify.site/sources.md) for canvas animation or GPU content; `liveChildren` requests repeated DOM captures and can be expensive.

## Stationary content, moving glass

```jsx theme={null}
import { Glass, GlassSurface, GlassContent } from 'glassen/react'

export function Scene() {
  return (
    <GlassSurface style={{ height: 480 }}>
      <GlassContent size={480} style={{ position: 'absolute', inset: 0 }}>
        <span style={{ fontSize: 80 }}>GLASS</span>
      </GlassContent>
      <Glass size={240} appearance="light" style={{ position: 'absolute', left: 120, top: 100 }} />
      <Glass size={120} appearance="dark" style={{ position: 'absolute', left: 300, top: 220 }} />
    </GlassSurface>
  )
}
```

`GlassContent` requires `GlassSurface`. Lenses without their own `source` sample the shared scene. A `source` prop takes precedence over children. Shared surfaces own one WebGL context and animation clock; individual lenses keep independent spring state.

`Glass` accepts the [lens options](https://glassen.mintlify.site/api.md), plus `size`, `style`, `label`, `children` and `liveChildren`. The default size is 480 CSS pixels. `GlassSurface` accepts `style`, `className` and `onReady(surface)` for reading statistics. Keep React state updates out of the frame loop; use DOM transforms in `onMove`, or position the lens through your application's existing motion layer.

The component responds to arrow keys as well as pointer drags. `interactive={false}` disables these handlers. Keep important text and controls accessible in DOM; a rendered texture does not provide semantics.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.