@zakisheriff/liquid-glass 0.1.3 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,627 +1,148 @@
1
1
  # <div align="center">@zakisheriff/liquid-glass</div>
2
2
 
3
3
  <div align="center">
4
- <strong>Apple-Inspired iOS 26 Liquid Glass UI Components for React</strong>
5
- </div>
6
-
4
+ <strong>Real, refracting Liquid Glass for React.</strong>
5
+ <br />
7
6
  <br />
8
-
9
- <div align="center">
10
7
 
11
8
  ![React](https://img.shields.io/badge/React-%3E%3D17-61dafb?style=for-the-badge&logo=react&logoColor=white)
12
- ![TypeScript](https://img.shields.io/badge/TypeScript-5.3-3178C6?style=for-the-badge&logo=typescript&logoColor=white)
13
- ![CSS](https://img.shields.io/badge/CSS-Backdrop%20Filter-1572B6?style=for-the-badge&logo=css3&logoColor=white)
9
+ ![TypeScript](https://img.shields.io/badge/TypeScript-5-3178C6?style=for-the-badge&logo=typescript&logoColor=white)
14
10
  ![License](https://img.shields.io/badge/License-MIT-green?style=for-the-badge)
15
11
 
16
- <br />
17
-
18
- <a href="https://www.npmjs.com/package/@zakisheriff/liquid-glass">
19
- <img src="https://img.shields.io/badge/View%20on%20npm-Install%20Package-CB3837?style=for-the-badge&logo=npm&logoColor=white" height="50" />
20
- </a>
21
-
22
- <br />
23
- <br />
24
-
25
- **[Website: https://liquidglass.theatom.lk](https://liquidglass.theatom.lk)**
26
-
27
- **[GitHub: https://github.com/zakisheriff/Liquid-Glass](https://github.com/zakisheriff/Liquid-Glass)**
28
-
29
- **[npm: https://www.npmjs.com/package/@zakisheriff/liquid-glass](https://www.npmjs.com/package/@zakisheriff/liquid-glass)**
12
+ **[liquidglass.theatom.lk](https://liquidglass.theatom.lk)** ·
13
+ **[npm](https://www.npmjs.com/package/@zakisheriff/liquid-glass)** ·
14
+ **[GitHub](https://github.com/zakisheriff/Liquid-Glass)**
30
15
 
31
16
  </div>
32
17
 
33
- <br />
34
-
35
- > **"Glass should feel physical, not painted on."**
36
- >
37
- > `@zakisheriff/liquid-glass` brings iOS-style liquid glass surfaces to React with layered shadows, prismatic borders, refraction filters, animated shine, and native CSS blur.
38
-
39
18
  ---
40
19
 
41
- ## Why Use It?
42
-
43
- - **Ready-made glass components** for buttons, cards, inputs, sheets, nav bars, and sliders
44
- - **Real depth and refraction** using layered CSS, `backdrop-filter`, masks, gradients, and SVG displacement filters
45
- - **TypeScript-first API** with exported prop types for every component
46
- - **No design framework required** because the package ships its own CSS
47
- - **Customizable surfaces** through intensity, tint, shimmer, thickness, radius, and layout props
48
-
49
- ---
20
+ Glass that bends light rather than just blurring it. Every surface ray-traces its own Snell's-law refraction map through a curved bevel. Lenses magnify and split colour at the rim. Every touch swells, stretches and settles with a jelly wobble, tuned frame by frame against iOS 26 screen recordings.
50
21
 
51
22
  ## Install
52
23
 
53
24
  ```bash
54
- npm install @zakisheriff/liquid-glass
55
- ```
56
-
57
- ```bash
58
- yarn add @zakisheriff/liquid-glass
59
- ```
60
-
61
- ```bash
62
- pnpm add @zakisheriff/liquid-glass
63
- ```
64
-
65
- ---
66
-
67
- ## Setup
68
-
69
- Import the stylesheet once in your app entry file.
70
-
71
- ```tsx
72
- import '@zakisheriff/liquid-glass/styles.css';
73
- ```
74
-
75
- Then import only the components you need.
76
-
77
- ```tsx
78
- import {
79
- GlassButton,
80
- GlassCard,
81
- GlassInput,
82
- GlassNav,
83
- GlassSheet,
84
- GlassSlider,
85
- LiquidGlassFilter,
86
- } from '@zakisheriff/liquid-glass';
87
- ```
88
-
89
- For the cleanest output, wrap the area using glass components with `LiquidGlassFilter`. Components still work without it, but the provider renders one shared SVG filter set instead of each component injecting its own local filter.
90
-
91
- ```tsx
92
- import { LiquidGlassFilter } from '@zakisheriff/liquid-glass';
93
- import '@zakisheriff/liquid-glass/styles.css';
94
-
95
- export default function App() {
96
- return (
97
- <LiquidGlassFilter>
98
- <YourApp />
99
- </LiquidGlassFilter>
100
- );
101
- }
25
+ npm i @zakisheriff/liquid-glass
102
26
  ```
103
27
 
104
- If you use Next.js App Router, use these components inside a client component because they rely on browser interaction APIs.
105
-
106
28
  ```tsx
107
- 'use client';
108
-
109
- import { GlassButton } from '@zakisheriff/liquid-glass';
29
+ import { GlassSwitch } from '@zakisheriff/liquid-glass';
110
30
  import '@zakisheriff/liquid-glass/styles.css';
111
- ```
112
-
113
- ---
114
31
 
115
- ## Quick Example
116
-
117
- ```tsx
118
- import { GlassButton, GlassCard, LiquidGlassFilter } from '@zakisheriff/liquid-glass';
119
- import '@zakisheriff/liquid-glass/styles.css';
120
-
121
- export default function App() {
122
- return (
123
- <LiquidGlassFilter>
124
- <main style={{ minHeight: '100vh', padding: 40, background: '#f3f4f6' }}>
125
- <GlassCard padding="32px" radius="28px" intensity={6} shimmer>
126
- <h2>Hello, Liquid Glass</h2>
127
- <p>Build tactile glass interfaces with React.</p>
128
-
129
- <GlassButton size="lg" onClick={() => alert('Clicked!')}>
130
- Get Started
131
- </GlassButton>
132
- </GlassCard>
133
- </main>
134
- </LiquidGlassFilter>
135
- );
32
+ export function Settings() {
33
+ const [on, setOn] = useState(true);
34
+ return <GlassSwitch checked={on} onChange={setOn} aria-label="Wi-Fi" />;
136
35
  }
137
36
  ```
138
37
 
139
- ---
140
-
141
- ## Shared Visual Props
38
+ Works with Next.js (the bundle is marked `"use client"`), Vite and CRA.
142
39
 
143
- Most visual components use the same glass controls:
40
+ ## Components
144
41
 
145
- | Prop | Type | Default | What it does |
146
- |------|------|---------|--------------|
147
- | `intensity` | `number` | `5` | Controls refraction and blur strength. Values are clamped from `1` to `10`. |
148
- | `tint` | `string` | `undefined` | Adds a CSS color overlay such as `rgba(0, 122, 255, 0.14)` or `#ffffff22`. |
149
- | `shimmer` | `boolean` | `true` | Enables animated shine/reflection effects where supported. |
150
- | `thickness` | `number` | `1` | Controls bevel/border thickness in pixels where supported. |
42
+ | Component | What it does |
43
+ | --- | --- |
44
+ | `GlassButton` | Pill or circle (`icon` with no children). Swells, leans toward a drag, wobbles on release. |
45
+ | `GlassSwitch` | The knob lifts into a clear lens that refracts the track. Tap, or drag with rubber-banding. |
46
+ | `GlassNav` | Floating tab bar. The selection inflates into a lens you can drag across tabs. |
47
+ | `GlassSegmented` | Segmented control. The whole control swells and the selection becomes a draggable lens. |
48
+ | `GlassSlider` | Thin track with a lens thumb that magnifies the rail, or `showThumb={false}` for a Control Center block. |
49
+ | `GlassInput` | Search / text field with icon, trailing accessory and clear button. |
50
+ | `GlassCard` | Refracting panel, `regular` or `clear`. |
51
+ | `GlassSheet` | Floating bottom sheet. Spring entrance, drag or flick to dismiss. |
151
52
 
152
- Use low intensity for subtle UI, mid intensity for standard panels, and high intensity for strong refraction demos.
53
+ ### Buttons
153
54
 
154
- ---
55
+ | Look | Code |
56
+ | --- | --- |
57
+ | Glass | `<GlassButton>Glass</GlassButton>` |
58
+ | Filled | `<GlassButton variant="filled">Filled</GlassButton>` |
59
+ | Tinted | `<GlassButton variant="tinted">Tinted</GlassButton>` |
60
+ | Tinted filled | `<GlassButton variant="filled" tint="#af52de">Tinted filled</GlassButton>` |
61
+ | Clear | `<GlassButton variant="clear">Clear</GlassButton>` |
62
+ | Destructive | `<GlassButton destructive>Delete</GlassButton>` |
63
+ | Destructive filled | `<GlassButton variant="filled" destructive>Delete</GlassButton>` |
64
+ | Icon circle | `<GlassButton icon={<PlusIcon />} aria-label="Add" />` |
155
65
 
156
- ## GlassButton
66
+ `tint` takes any CSS colour: it colours the label for `tinted` and the fill for `filled`. Sizes: `size="sm" | "md" | "lg"` (36 / 44 / 52 px).
157
67
 
158
- Use `GlassButton` for primary actions, secondary actions, destructive actions, icon buttons, and pill-shaped CTA buttons. It renders a real `<button>`, so native button props like `type`, `disabled`, `aria-label`, `onClick`, and `form` work.
68
+ ### Everything else
159
69
 
160
70
  ```tsx
161
- import { GlassButton } from '@zakisheriff/liquid-glass';
162
-
163
- function Actions() {
164
- return (
165
- <div style={{ display: 'flex', gap: 12 }}>
166
- <GlassButton size="lg" onClick={() => console.log('Save')}>
167
- Save Changes
168
- </GlassButton>
169
-
170
- <GlassButton variant="ghost" shimmer={false}>
171
- Cancel
172
- </GlassButton>
173
-
174
- <GlassButton variant="destructive">
175
- Delete
176
- </GlassButton>
177
- </div>
178
- );
179
- }
180
- ```
181
-
182
- Use the `size` prop for quick sizing, and use `style` when you need a fixed width.
183
-
184
- ```tsx
185
- <GlassButton
186
- size="md"
187
- style={{ width: '100%' }}
188
- >
189
- Continue
190
- </GlassButton>
191
- ```
192
-
193
- ### GlassButton Props
194
-
195
- | Prop | Type | Default | What it does |
196
- |------|------|---------|--------------|
197
- | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Changes height, font size, and minimum width. |
198
- | `variant` | `'default' \| 'ghost' \| 'destructive'` | `'default'` | Sets the visual treatment. |
199
- | `intensity` | `number` | `5` | Controls refraction strength. |
200
- | `tint` | `string` | `undefined` | Adds a glass tint color. |
201
- | `shimmer` | `boolean` | `true` | Enables the shine overlay. |
202
- | `thickness` | `number` | `1` | Controls bevel thickness. |
203
- | `children` | `React.ReactNode` | `undefined` | Button label or icon content. |
204
- | Native button props | `ButtonHTMLAttributes<HTMLButtonElement>` | `-` | Supports `onClick`, `disabled`, `type`, `aria-*`, and more. |
205
-
206
- ---
207
-
208
- ## GlassCard
209
-
210
- Use `GlassCard` as a glass surface for panels, forms, dashboards, settings groups, previews, and modal content. It renders a `<div>` and accepts normal div attributes.
211
-
212
- ```tsx
213
- import { GlassCard } from '@zakisheriff/liquid-glass';
214
-
215
- function ProfileCard() {
216
- return (
217
- <GlassCard
218
- intensity={6}
219
- tint="rgba(255,255,255,0.12)"
220
- padding="28px"
221
- radius="32px"
222
- >
223
- <h2>Account</h2>
224
- <p>Manage your profile and preferences.</p>
225
- </GlassCard>
226
- );
227
- }
228
- ```
229
-
230
- Use `padding` for inner spacing and `radius` for shape. Cards are best placed over a visible background, gradient, image, or soft color field so the blur/refraction is visible.
231
-
232
- ### GlassCard Props
233
-
234
- | Prop | Type | Default | What it does |
235
- |------|------|---------|--------------|
236
- | `intensity` | `number` | `5` | Controls refraction strength. |
237
- | `tint` | `string` | `undefined` | Adds a glass tint color. |
238
- | `shimmer` | `boolean` | `true` | Enables animated border shine. |
239
- | `thickness` | `number` | `1` | Controls bevel thickness. |
240
- | `padding` | `string` | `'24px'` | Sets inner content padding. |
241
- | `radius` | `string` | `'20px'` | Sets border radius, for example `'24px'` or `'36px'`. |
242
- | `children` | `React.ReactNode` | `undefined` | Card content. |
243
- | Native div props | `HTMLAttributes<HTMLDivElement>` | `-` | Supports `className`, `style`, `id`, `role`, and more. |
244
-
245
- ---
246
-
247
- ## GlassInput
248
-
249
- Use `GlassInput` for controlled text fields with a floating label and glass focus state.
250
-
251
- ```tsx
252
- import { useState } from 'react';
253
- import { GlassInput } from '@zakisheriff/liquid-glass';
254
-
255
- function LoginForm() {
256
- const [email, setEmail] = useState('');
257
-
258
- return (
259
- <GlassInput
260
- label="Email"
261
- placeholder="you@example.com"
262
- value={email}
263
- onChange={(event) => setEmail(event.target.value)}
264
- autoComplete="email"
265
- intensity={5}
266
- />
267
- );
268
- }
269
- ```
270
-
271
- The input is controlled through `value` and `onChange`. The `label` floats when the field is focused or has a value.
272
-
273
- ### GlassInput Props
274
-
275
- | Prop | Type | Default | What it does |
276
- |------|------|---------|--------------|
277
- | `label` | `string` | `undefined` | Floating label displayed inside the glass field. |
278
- | `placeholder` | `string` | `undefined` | Native input placeholder. |
279
- | `value` | `string` | `undefined` | Controlled input value. |
280
- | `onChange` | `(event: React.ChangeEvent<HTMLInputElement>) => void` | `undefined` | Change handler for controlled state. |
281
- | `intensity` | `number` | `5` | Controls refraction strength. |
282
- | `tint` | `string` | `undefined` | Adds a glass tint color. |
283
- | Native input props | `InputHTMLAttributes<HTMLInputElement>` | `-` | Supports `type`, `name`, `required`, `autoComplete`, `disabled`, and more. |
71
+ <GlassSwitch checked={on} onChange={setOn} aria-label="Wi-Fi" />
72
+ <GlassSwitch checked={on} onChange={setOn} tint="#ff9f0a" aria-label="Focus" />
284
73
 
285
- ---
286
-
287
- ## GlassSlider
288
-
289
- Use `GlassSlider` for range controls. It renders a native range input overlay for accessibility, while the visual layer uses liquid glass.
290
-
291
- There are two modes:
292
-
293
- - `showThumb={false}` creates an iOS Control Center style block slider
294
- - `showThumb={true}` creates a classic track slider with a circular knob
295
-
296
- ### Control Center Block Slider
297
-
298
- ```tsx
299
- import { useState } from 'react';
300
- import { GlassSlider } from '@zakisheriff/liquid-glass';
301
-
302
- function VolumeControl() {
303
- const [volume, setVolume] = useState(46);
304
-
305
- return (
306
- <GlassSlider
307
- min={0}
308
- max={100}
309
- value={volume}
310
- onChange={setVolume}
311
- showThumb={false}
312
- label="Volume"
313
- icon={<span aria-hidden>🔊</span>}
314
- intensity={6}
315
- />
316
- );
317
- }
318
- ```
319
-
320
- ### Classic Thumb Slider
321
-
322
- ```tsx
323
- function HueControl() {
324
- const [hue, setHue] = useState(180);
325
-
326
- return (
327
- <GlassSlider
328
- min={0}
329
- max={360}
330
- value={hue}
331
- onChange={setHue}
332
- showThumb
333
- label="Hue"
334
- />
335
- );
336
- }
337
- ```
338
-
339
- ### GlassSlider Props
340
-
341
- | Prop | Type | Default | What it does |
342
- |------|------|---------|--------------|
343
- | `value` | `number \| string \| readonly string[]` | `0` | Current range value. Use a number for best results. |
344
- | `min` | `number \| string` | `0` | Minimum range value. |
345
- | `max` | `number \| string` | `100` | Maximum range value. |
346
- | `onChange` | `(value: number) => void` | `undefined` | Receives the numeric slider value. |
347
- | `showThumb` | `boolean` | `true` | Shows the circular knob when `true`; uses block-fill style when `false`. |
348
- | `icon` | `React.ReactNode` | `undefined` | Optional icon shown on the left inside the track. |
349
- | `label` | `string` | `undefined` | Optional label shown inside the track. |
350
- | `intensity` | `number` | `5` | Controls refraction strength. |
351
- | `tint` | `string` | `undefined` | Adds a glass tint color. |
352
- | `shimmer` | `boolean` | `true` | Enables shine on the active fill. |
353
- | `thickness` | `number` | `1` | Controls bevel thickness. |
354
- | Native range props | `InputHTMLAttributes<HTMLInputElement>` | `-` | Supports `step`, `disabled`, `aria-label`, and more. |
355
-
356
- ---
357
-
358
- ## GlassNav
359
-
360
- Use `GlassNav` for segmented controls, tab bars, and compact navigation. It manages only visuals and click events; you own the active state.
361
-
362
- ```tsx
363
- import { useState } from 'react';
364
- import { GlassNav } from '@zakisheriff/liquid-glass';
365
-
366
- const tabs = [
367
- { label: 'Overview' },
368
- { label: 'Buttons' },
369
- { label: 'Inputs' },
370
- ];
371
-
372
- function Tabs() {
373
- const [activeTab, setActiveTab] = useState(0);
374
-
375
- return (
376
- <GlassNav
377
- items={tabs}
378
- activeIndex={activeTab}
379
- onChange={setActiveTab}
380
- intensity={5}
381
- />
382
- );
383
- }
384
- ```
385
-
386
- Each item can include an icon.
387
-
388
- ```tsx
389
74
  <GlassNav
75
+ activeIndex={tab}
76
+ onChange={setTab}
390
77
  items={[
391
78
  { label: 'Home', icon: <HomeIcon /> },
392
- { label: 'Settings', icon: <SettingsIcon /> },
79
+ { label: 'Library', icon: <LibraryIcon /> },
393
80
  ]}
394
- activeIndex={activeIndex}
395
- onChange={setActiveIndex}
396
81
  />
397
- ```
398
82
 
399
- ### GlassNav Props
83
+ <GlassSegmented options={['Chat', 'Work']} value={mode} onChange={setMode} />
84
+ <GlassSegmented size="sm" options={[{ label: 'Light', icon: <SunIcon /> }, 'Dark']} value={t} onChange={setT} />
400
85
 
401
- | Prop | Type | Default | What it does |
402
- |------|------|---------|--------------|
403
- | `items` | `{ label: string; icon?: React.ReactNode }[]` | Required | Items rendered as tabs. |
404
- | `activeIndex` | `number` | `0` | Zero-based active item index. |
405
- | `onChange` | `(index: number) => void` | `undefined` | Called when a nav item is clicked. |
406
- | `intensity` | `number` | `5` | Controls refraction strength. |
86
+ <GlassSlider value={volume} onChange={setVolume} />
87
+ <GlassSlider showThumb={false} value={brightness} onChange={setBrightness} icon={<SunIcon />} label="Display" />
407
88
 
408
- ---
409
-
410
- ## GlassSheet
89
+ <GlassInput type="search" placeholder="Search" value={q} onChange={(e) => setQ(e.target.value)} trailing={<MicIcon />} />
411
90
 
412
- Use `GlassSheet` for bottom sheets, action drawers, mobile menus, and lightweight modal panels. You control it with an `open` boolean.
91
+ <GlassCard padding="20px" radius="28px">…</GlassCard>
92
+ <GlassCard variant="clear">…</GlassCard>
413
93
 
414
- ```tsx
415
- import { useState } from 'react';
416
- import { GlassButton, GlassSheet } from '@zakisheriff/liquid-glass';
417
-
418
- function SettingsSheet() {
419
- const [open, setOpen] = useState(false);
420
-
421
- return (
422
- <>
423
- <GlassButton onClick={() => setOpen(true)}>
424
- Open Settings
425
- </GlassButton>
426
-
427
- <GlassSheet open={open} onClose={() => setOpen(false)} intensity={6}>
428
- <h2>Settings</h2>
429
- <p>Sheet content goes here.</p>
430
-
431
- <GlassButton onClick={() => setOpen(false)}>
432
- Done
433
- </GlassButton>
434
- </GlassSheet>
435
- </>
436
- );
437
- }
94
+ <GlassSheet open={open} onClose={() => setOpen(false)} aria-label="Details">…</GlassSheet>
438
95
  ```
439
96
 
440
- The sheet closes when the backdrop is clicked or when Escape is pressed. It also locks body scrolling while mounted.
97
+ ### Props reference
441
98
 
442
- ### GlassSheet Props
99
+ | Component | Props |
100
+ | --- | --- |
101
+ | `GlassButton` | `variant` (`glass` · `clear` · `tinted` · `filled`), `destructive`, `tint`, `size`, `icon`, `shimmer`, `intensity`, `thickness`, plus all `<button>` props |
102
+ | `GlassSwitch` | `checked`, `defaultChecked`, `onChange(checked)`, `tint`, `disabled`, `intensity` |
103
+ | `GlassNav` | `items: { label, icon? }[]`, `activeIndex`, `onChange(index)`, `intensity` |
104
+ | `GlassSegmented` | `options: (string \| { label, icon? })[]`, `value`, `onChange(index)`, `size` (`sm` · `md`), `intensity` |
105
+ | `GlassSlider` | `value`, `min`, `max`, `step`, `onChange(value)`, `showThumb`, `icon`, `label`, `tint`, `intensity` |
106
+ | `GlassInput` | `type`, `value`, `onChange(event)`, `placeholder`, `label`, `icon`, `trailing`, `onClear`, `tint`, `intensity` |
107
+ | `GlassCard` | `variant` (`regular` · `clear`), `padding`, `radius`, `tint`, `thickness`, `intensity` |
108
+ | `GlassSheet` | `open`, `onClose()`, `tint`, `aria-label`, `intensity` |
443
109
 
444
- | Prop | Type | Default | What it does |
445
- |------|------|---------|--------------|
446
- | `open` | `boolean` | Required | Controls whether the sheet is visible. |
447
- | `onClose` | `() => void` | `undefined` | Called by backdrop click or Escape key. |
448
- | `intensity` | `number` | `5` | Controls refraction strength. |
449
- | `tint` | `string` | `undefined` | Adds a glass tint color. |
450
- | `children` | `React.ReactNode` | `undefined` | Sheet content. |
110
+ `intensity` (1–10) scales refraction strength everywhere.
451
111
 
452
- ---
112
+ ## Light and dark
453
113
 
454
- ## LiquidGlassFilter
114
+ Tokens follow `prefers-color-scheme`. To force a theme, set `data-theme="light"` or `data-theme="dark"` on any ancestor. Override any `--lg-*` variable to restyle, e.g. `--lg-accent`, `--lg-fill` or `--lg-blur`.
455
115
 
456
- Use `LiquidGlassFilter` once near the top of your app or page. It renders shared SVG filter definitions for refraction levels `1` through `10`.
116
+ ## Build your own glass
457
117
 
458
118
  ```tsx
459
- import { LiquidGlassFilter } from '@zakisheriff/liquid-glass';
460
-
461
- function Root() {
462
- return (
463
- <LiquidGlassFilter>
464
- <App />
465
- </LiquidGlassFilter>
466
- );
467
- }
468
- ```
469
-
470
- You can skip it for quick demos because each component can inject its own filter fallback, but using the provider is cleaner for production apps.
471
-
472
- ---
119
+ import { useRefraction, usePress } from '@zakisheriff/liquid-glass';
473
120
 
474
- ## Hooks
475
-
476
- ### useGlassEffect
477
-
478
- Use `useGlassEffect` when building your own custom glass component. It returns a `style` object with glass CSS variables and a matching `filterId`.
479
-
480
- ```tsx
481
- import { useGlassEffect } from '@zakisheriff/liquid-glass';
482
-
483
- function CustomGlassPanel() {
484
- const { style, filterId } = useGlassEffect({
485
- intensity: 7,
486
- tint: 'rgba(0, 122, 255, 0.14)',
487
- shimmer: true,
488
- thickness: 2,
489
- blur: 18,
490
- });
491
-
492
- return (
493
- <div data-liquid-glass style={style}>
494
- Custom glass panel using {filterId}
495
- </div>
496
- );
121
+ function Droplet() {
122
+ const ref = useRef<HTMLDivElement>(null);
123
+ useRefraction(ref, { kind: 'lens', zoom: 1.3, dispersion: 1 });
124
+ usePress(ref);
125
+ return <div ref={ref} className="lg-glass" style={{ width: 240, height: 160, borderRadius: 999 }} />;
497
126
  }
498
127
  ```
499
128
 
500
- ### useGlassAnimation
129
+ `createSpring`, `SPRINGS` and `haptic()` are exported too.
501
130
 
502
- Use `useGlassAnimation` when creating custom interactive glass elements. It gives you hover, press, and focus state plus pointer/focus handlers.
131
+ ## Browser support
503
132
 
504
- ```tsx
505
- import { useGlassAnimation } from '@zakisheriff/liquid-glass';
506
-
507
- function CustomGlassButton() {
508
- const { isHovered, isPressed, isFocused, handlers } = useGlassAnimation();
509
-
510
- return (
511
- <button
512
- {...handlers}
513
- style={{
514
- transform: isPressed ? 'scale(0.98)' : 'scale(1)',
515
- opacity: isHovered || isFocused ? 1 : 0.86,
516
- }}
517
- >
518
- Custom
519
- </button>
520
- );
521
- }
522
- ```
523
-
524
- ---
525
-
526
- ## Styling Tips
133
+ - **Chrome / Edge / Arc:** live refraction of anything behind the glass through `backdrop-filter: url(#svg)`.
134
+ - **Safari:** lenses (switch, slider, tab bar, segmented) refract a live copy of the content beneath them, including magnification and the colour split. Bars, buttons and cards over arbitrary page content get frosting, rims and motion.
135
+ - **Firefox:** uses the same path as Safari; not yet tested.
136
+ - Respects `prefers-reduced-motion` and `prefers-reduced-transparency`.
527
137
 
528
- - Put glass components over a visible background, image, gradient, or soft color surface so blur/refraction has something to bend.
529
- - Use `intensity={3}` to `intensity={6}` for production UI and `intensity={7}` to `intensity={10}` for dramatic demos.
530
- - Use subtle tint values such as `rgba(0, 122, 255, 0.12)` instead of fully opaque colors.
531
- - Keep `LiquidGlassFilter` mounted once around repeated glass components for cleaner DOM output.
532
- - Import `@zakisheriff/liquid-glass/styles.css` only once.
533
-
534
- ---
535
-
536
- ## Browser Support
537
-
538
- - Chrome 89+
539
- - Edge 89+
540
- - Safari 15.4+
541
- - Firefox 103+
542
-
543
- `backdrop-filter` support is required for the full liquid glass look.
544
-
545
- ---
546
-
547
- ## Project Structure
548
-
549
- ```text
550
- liquid-glass/
551
- ├── src/
552
- │ ├── index.ts
553
- │ ├── components/
554
- │ │ ├── GlassButton/
555
- │ │ ├── GlassCard/
556
- │ │ ├── GlassInput/
557
- │ │ ├── GlassNav/
558
- │ │ ├── GlassSheet/
559
- │ │ └── GlassSlider/
560
- │ ├── filters/
561
- │ │ └── LiquidGlassFilter.tsx
562
- │ ├── hooks/
563
- │ │ ├── useGlassAnimation.ts
564
- │ │ └── useGlassEffect.ts
565
- │ └── styles/
566
- │ └── base.css
567
- ├── demo/
568
- ├── package.json
569
- ├── tsconfig.json
570
- └── tsup.config.ts
571
- ```
572
-
573
- ---
574
-
575
- ## Development
138
+ ## Develop
576
139
 
577
140
  ```bash
578
- git clone https://github.com/zakisheriff/Liquid-Glass.git
579
- cd Liquid-Glass
580
141
  npm install
142
+ npm run site # Next.js landing page at localhost:3000, renders straight from src/
143
+ npm run build # library → dist/
581
144
  ```
582
145
 
583
- Run the library build:
584
-
585
- ```bash
586
- npm run build
587
- ```
588
-
589
- Watch the library build:
590
-
591
- ```bash
592
- npm run dev
593
- ```
594
-
595
- Run the demo:
596
-
597
- ```bash
598
- npm run demo
599
- ```
600
-
601
- ---
602
-
603
146
  ## License
604
147
 
605
- MIT License. Free for personal and commercial projects.
606
-
607
- ---
608
-
609
- ## Support the Project
610
-
611
- If Liquid Glass helped you build a better interface, you can support future updates here:
612
-
613
- <div align="center">
614
- <a href="https://buymeacoffee.com/theoneatom">
615
- <img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" height="60" width="217" alt="Buy Me A Coffee">
616
- </a>
617
- </div>
618
-
619
- ---
620
-
621
- <p align="center">
622
- Made by <strong>Zaki Sheriff</strong>
623
- </p>
624
-
625
- <p align="center">
626
- <em>Because interfaces should feel as good as they look.</em>
627
- </p>
148
+ MIT © Zaki Sheriff. Not affiliated with Apple Inc.