Quick Start with Liquid Glass JS
mainTo use Liquid Glass JS, include the required CSS files, the html2canvas library (used for page sampling), and the library's core scripts (container.js and button.js).
Basic Button Usage
Create a glass button using the Button class and append its .element property to the DOM.
Nested Glass Usage
You can create a Container and add Button instances (or other containers) as children using .addChild(). This enables the nested glass system where child elements sample the parent container's output.
<!DOCTYPE html>
<html
<head>
<link rel="stylesheet" href="styles.css" />
<link rel="stylesheet" href="glass.css" />
</head>
<body
<script src="https://cdn.jsdelivr.net/npm/html2canvas@1.4.1/dist/html2canvas.min.js"></script>
<script src="container.js"></script>
<script src="button.js"></script>
<script>
// Create a glass button
const button = new Button({
text: 'Click Me!',
size: 32,
type: 'rounded',
onClick: () => alert('Hello Glass!')
})
document.body.appendChild(button.element)
</script>
</body>
</html>