@zakisheriff/liquid-glass 0.3.3 → 0.3.4
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 +435 -55
- package/dist/index.css +8 -3
- package/dist/index.css.map +1 -1
- package/dist/index.js +19 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
<br />
|
|
7
7
|
|
|
8
8
|
[](https://www.npmjs.com/package/@zakisheriff/liquid-glass)
|
|
9
|
-
[](https://www.npmjs.com/package/@zakisheriff/liquid-glass)
|
|
10
|
+
[](https://www.npmjs.com/package/@zakisheriff/liquid-glass?activeTab=code)
|
|
11
11
|
[](https://www.npmjs.com/package/@zakisheriff/liquid-glass?activeTab=dependencies)
|
|
12
12
|
<br />
|
|
13
13
|

|
|
@@ -49,93 +49,473 @@ Works with Next.js (the bundle is marked `"use client"`), Vite and CRA.
|
|
|
49
49
|
|
|
50
50
|
## Components
|
|
51
51
|
|
|
52
|
-
| Component | What it does |
|
|
53
|
-
| --- | --- |
|
|
54
|
-
| `GlassButton` | Pill or circle
|
|
55
|
-
| `GlassSwitch` | The knob lifts into a clear lens that refracts the track. Tap, or drag with rubber-banding. |
|
|
56
|
-
| `
|
|
57
|
-
| `GlassSegmented` |
|
|
58
|
-
| `
|
|
59
|
-
| `
|
|
60
|
-
| `
|
|
61
|
-
| `
|
|
62
|
-
| `GlassSheet` |
|
|
52
|
+
| Component | Import | What it does |
|
|
53
|
+
| --- | --- | --- |
|
|
54
|
+
| [Button](#button--glassbutton) | `GlassButton` | Pill or circle. Swells, leans toward a drag, wobbles on release. |
|
|
55
|
+
| [Toggle switch](#toggle-switch--glassswitch) | `GlassSwitch` | The knob lifts into a clear lens that refracts the track. Tap, or drag with rubber-banding. |
|
|
56
|
+
| [Slider](#slider--glassslider) | `GlassSlider` | Thin track with a lens thumb, or a Control Center block. |
|
|
57
|
+
| [Segmented control](#segmented-control--glasssegmented) | `GlassSegmented` | The control swells and the selection becomes a draggable lens. |
|
|
58
|
+
| [Tab bar](#tab-bar--glassnav) | `GlassNav` | Floating tab bar. The selection inflates into a lens you can drag across tabs. |
|
|
59
|
+
| [Menu](#menu--glassmenu) | `GlassMenu` | Pull-down menu that grows out of its glass button and folds back into it. |
|
|
60
|
+
| [Search and text field](#search-and-text-field--glassinput) | `GlassInput` | Text or search field with icon, trailing accessory and clear button. |
|
|
61
|
+
| [Card](#card--glasscard) | `GlassCard` | Refracting panel, frosted or clear. |
|
|
62
|
+
| [Sheet](#sheet--glasssheet) | `GlassSheet` | Bottom sheet. Drag or flick to dismiss; with detents, half height to full screen. |
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
Every example below assumes `useState` from React and the stylesheet imported once. Icons such as `<PlusIcon />` stand for any React node, like an SVG icon component. `intensity` (1–10) scales refraction strength on every component.
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
| Glass | `<GlassButton>Glass</GlassButton>` |
|
|
69
|
-
| Filled | `<GlassButton variant="filled">Filled</GlassButton>` |
|
|
70
|
-
| Tinted | `<GlassButton variant="tinted">Tinted</GlassButton>` |
|
|
71
|
-
| Tinted filled | `<GlassButton variant="filled" tint="#af52de">Tinted filled</GlassButton>` |
|
|
72
|
-
| Clear | `<GlassButton variant="clear">Clear</GlassButton>` |
|
|
73
|
-
| Destructive | `<GlassButton destructive>Delete</GlassButton>` |
|
|
74
|
-
| Destructive filled | `<GlassButton variant="filled" destructive>Delete</GlassButton>` |
|
|
75
|
-
| Icon circle | `<GlassButton icon={<PlusIcon />} aria-label="Add" />` |
|
|
66
|
+
<!-- components:start -->
|
|
67
|
+
### Button · `GlassButton`
|
|
76
68
|
|
|
77
|
-
|
|
69
|
+
A pill, or a circle when it has an icon and no label. It swells under the finger, leans toward a drag and wobbles as it settles.
|
|
78
70
|
|
|
79
|
-
|
|
71
|
+
**Variants**
|
|
80
72
|
|
|
81
73
|
```tsx
|
|
82
|
-
|
|
83
|
-
<GlassSwitch checked={on} onChange={setOn} tint="#ff9f0a" aria-label="Focus" />
|
|
74
|
+
import { GlassButton } from '@zakisheriff/liquid-glass';
|
|
84
75
|
|
|
76
|
+
<GlassButton>Glass</GlassButton>
|
|
77
|
+
<GlassButton variant="clear">Clear</GlassButton>
|
|
78
|
+
<GlassButton variant="tinted">Tinted</GlassButton>
|
|
79
|
+
<GlassButton variant="filled">Filled</GlassButton>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**Any colour**
|
|
83
|
+
|
|
84
|
+
```tsx
|
|
85
|
+
<GlassButton variant="tinted" tint="#ff9f0a">Orange label</GlassButton>
|
|
86
|
+
<GlassButton variant="filled" tint="#af52de">Purple fill</GlassButton>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**Destructive**
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
<GlassButton destructive>Delete</GlassButton>
|
|
93
|
+
<GlassButton variant="filled" destructive>Delete</GlassButton>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Icons**
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
{/* Icon with a label */}
|
|
100
|
+
<GlassButton icon={<PlusIcon />}>New note</GlassButton>
|
|
101
|
+
|
|
102
|
+
{/* Icon only: becomes a circle, so give it an accessible name */}
|
|
103
|
+
<GlassButton icon={<PlusIcon />} aria-label="Add" />
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Sizes**
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
<GlassButton size="sm">Small</GlassButton> {/* 36px */}
|
|
110
|
+
<GlassButton size="md">Medium</GlassButton> {/* 44px, default */}
|
|
111
|
+
<GlassButton size="lg">Large</GlassButton> {/* 52px */}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Handling clicks**
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
<GlassButton variant="filled" onClick={() => save()} disabled={saving}>
|
|
118
|
+
Save
|
|
119
|
+
</GlassButton>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
| Prop | Type | Default | Description |
|
|
123
|
+
| --- | --- | --- | --- |
|
|
124
|
+
| `variant` | `'glass' \| 'clear' \| 'tinted' \| 'filled'` | `'glass'` | Regular glass, see-through glass, glass with a coloured label, or a solid colour. |
|
|
125
|
+
| `tint` | `string` | `accent blue` | Any CSS colour. Colours the label for `tinted` and the fill for `filled`. |
|
|
126
|
+
| `destructive` | `boolean` | `false` | Red label, or a red fill with `filled`, for delete and other irreversible actions. |
|
|
127
|
+
| `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Height: 36, 44 or 52 px. |
|
|
128
|
+
| `icon` | `ReactNode` | | Leading icon. With no children the button becomes a circle. |
|
|
129
|
+
| `shimmer` | `boolean` | `true` | Light bloom under the finger while pressed. |
|
|
130
|
+
| `thickness` | `number (1–4)` | `1` | Rim bevel scale. Wider bevels bend more of the backdrop. |
|
|
131
|
+
| `intensity` | `number (1–10)` | `5` | Refraction strength, from subtle to heavy. |
|
|
132
|
+
|
|
133
|
+
Also accepts every `<button>` prop (`onClick`, `disabled`, `type`, `aria-*`, …).
|
|
134
|
+
|
|
135
|
+
### Toggle switch · `GlassSwitch`
|
|
136
|
+
|
|
137
|
+
An iOS toggle. On press the knob lifts into a clear lens that refracts the track. Tap it, or drag the knob with rubber-banding at the ends.
|
|
138
|
+
|
|
139
|
+
**Controlled**
|
|
140
|
+
|
|
141
|
+
```tsx
|
|
142
|
+
import { useState } from 'react';
|
|
143
|
+
import { GlassSwitch } from '@zakisheriff/liquid-glass';
|
|
144
|
+
|
|
145
|
+
function WifiSetting() {
|
|
146
|
+
const [on, setOn] = useState(true);
|
|
147
|
+
return <GlassSwitch checked={on} onChange={setOn} aria-label="Wi-Fi" />;
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
**Uncontrolled**
|
|
152
|
+
|
|
153
|
+
```tsx
|
|
154
|
+
<GlassSwitch defaultChecked onChange={(on) => console.log(on)} aria-label="Bluetooth" />
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**Custom on colour**
|
|
158
|
+
|
|
159
|
+
```tsx
|
|
160
|
+
<GlassSwitch checked={focus} onChange={setFocus} tint="#ff9f0a" aria-label="Focus" />
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
**In a settings list, with a visible label**
|
|
164
|
+
|
|
165
|
+
```tsx
|
|
166
|
+
<label className="setting">
|
|
167
|
+
<span>Live Activities</span>
|
|
168
|
+
<GlassSwitch checked={live} onChange={setLive} />
|
|
169
|
+
</label>
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**Disabled**
|
|
173
|
+
|
|
174
|
+
```tsx
|
|
175
|
+
<GlassSwitch checked disabled aria-label="Managed by your organisation" />
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
| Prop | Type | Default | Description |
|
|
179
|
+
| --- | --- | --- | --- |
|
|
180
|
+
| `checked` | `boolean` | | On or off, when you control the state. |
|
|
181
|
+
| `defaultChecked` | `boolean` | | Starting state, when the switch manages its own state. |
|
|
182
|
+
| `onChange` | `(checked: boolean) => void` | | Called with the new state after a tap or a drag. |
|
|
183
|
+
| `tint` | `string` | `system green` | On-state colour. Any CSS colour. |
|
|
184
|
+
| `disabled` | `boolean` | `false` | Dims the switch and ignores input. |
|
|
185
|
+
| `intensity` | `number (1–10)` | `5` | Refraction strength, from subtle to heavy. |
|
|
186
|
+
|
|
187
|
+
Also accepts other `<button>` props (`aria-label`, `id`, `className`, …).
|
|
188
|
+
|
|
189
|
+
The switch is a `role="switch"` button: Space and Enter toggle it. Give it an `aria-label`, or wrap it in a `<label>` with visible text.
|
|
190
|
+
|
|
191
|
+
### Slider · `GlassSlider`
|
|
192
|
+
|
|
193
|
+
A thin iOS track whose thumb lifts into a lens that magnifies the rail, or a Control Center block that fills and stretches under the finger.
|
|
194
|
+
|
|
195
|
+
**Track with a lens thumb**
|
|
196
|
+
|
|
197
|
+
```tsx
|
|
198
|
+
import { GlassSlider } from '@zakisheriff/liquid-glass';
|
|
199
|
+
|
|
200
|
+
const [volume, setVolume] = useState(40);
|
|
201
|
+
<GlassSlider value={volume} onChange={setVolume} aria-label="Volume" />
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**Control Center block**
|
|
205
|
+
|
|
206
|
+
```tsx
|
|
207
|
+
<GlassSlider
|
|
208
|
+
showThumb={false}
|
|
209
|
+
value={brightness}
|
|
210
|
+
onChange={setBrightness}
|
|
211
|
+
icon={<SunIcon />}
|
|
212
|
+
label="Display"
|
|
213
|
+
/>
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
**Range, steps and colour**
|
|
217
|
+
|
|
218
|
+
```tsx
|
|
219
|
+
{/* Snaps to 5 °C steps between 10 and 30 */}
|
|
220
|
+
<GlassSlider min={10} max={30} step={5} value={temp} onChange={setTemp} tint="#ff9f0a" aria-label="Temperature" />
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
| Prop | Type | Default | Description |
|
|
224
|
+
| --- | --- | --- | --- |
|
|
225
|
+
| `value` | `number` | `0` | Current value. |
|
|
226
|
+
| `onChange` | `(value: number) => void` | | Called while dragging, with the full-precision value. |
|
|
227
|
+
| `min` | `number` | `0` | Lowest value. |
|
|
228
|
+
| `max` | `number` | `100` | Highest value. |
|
|
229
|
+
| `step` | `number \| 'any'` | `'any'` | Continuous by default. A number snaps to fixed increments. |
|
|
230
|
+
| `showThumb` | `boolean` | `true` | `true`: thin track with a lens thumb. `false`: Control Center block. |
|
|
231
|
+
| `icon` | `ReactNode` | | Icon inside the block slider. |
|
|
232
|
+
| `label` | `string` | | Label inside the block slider. Its number is rounded for display. |
|
|
233
|
+
| `tint` | `string` | `accent blue (white for blocks)` | Fill colour. |
|
|
234
|
+
| `intensity` | `number (1–10)` | `5` | Refraction strength, from subtle to heavy. |
|
|
235
|
+
|
|
236
|
+
Also accepts other `<input type="range">` props (`aria-label`, `disabled`, `name`, …).
|
|
237
|
+
|
|
238
|
+
Arrow keys, Page Up/Down, Home and End work as on a native range input.
|
|
239
|
+
|
|
240
|
+
### Segmented control · `GlassSegmented`
|
|
241
|
+
|
|
242
|
+
A row of choices. On press the whole control swells and the selection becomes a lens you can drag between segments.
|
|
243
|
+
|
|
244
|
+
**Text segments**
|
|
245
|
+
|
|
246
|
+
```tsx
|
|
247
|
+
import { GlassSegmented } from '@zakisheriff/liquid-glass';
|
|
248
|
+
|
|
249
|
+
const [mode, setMode] = useState(0);
|
|
250
|
+
<GlassSegmented options={['Chat', 'Work', 'Study']} value={mode} onChange={setMode} aria-label="Mode" />
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
**With icons**
|
|
254
|
+
|
|
255
|
+
```tsx
|
|
256
|
+
<GlassSegmented
|
|
257
|
+
options={[{ label: 'Light', icon: <SunIcon /> }, { label: 'Dark', icon: <MoonIcon /> }]}
|
|
258
|
+
value={theme}
|
|
259
|
+
onChange={setTheme}
|
|
260
|
+
aria-label="Appearance"
|
|
261
|
+
/>
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
**Compact**
|
|
265
|
+
|
|
266
|
+
```tsx
|
|
267
|
+
<GlassSegmented size="sm" options={['Day', 'Week', 'Month']} value={range} onChange={setRange} />
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
| Prop | Type | Default | Description |
|
|
271
|
+
| --- | --- | --- | --- |
|
|
272
|
+
| `options` | `Array<string \| { label, icon? }>` | | Segment labels, or label and icon pairs. |
|
|
273
|
+
| `value` | `number` | | Index of the selected segment. |
|
|
274
|
+
| `onChange` | `(index: number) => void` | | Called with the index of the newly selected segment. |
|
|
275
|
+
| `size` | `'sm' \| 'md'` | `'md'` | Height: 28 or 36 px. |
|
|
276
|
+
| `intensity` | `number (1–10)` | `5` | Refraction strength, from subtle to heavy. |
|
|
277
|
+
| `aria-label` | `string` | | Accessible name for the group. |
|
|
278
|
+
| `className, style` | | | Applied to the control. |
|
|
279
|
+
|
|
280
|
+
Arrow keys, Home and End move the selection.
|
|
281
|
+
|
|
282
|
+
### Tab bar · `GlassNav`
|
|
283
|
+
|
|
284
|
+
A floating iOS 26 tab bar. The selection inflates into a lens you can drag across the tabs. Icons with labels, or icons only.
|
|
285
|
+
|
|
286
|
+
**Icons and labels**
|
|
287
|
+
|
|
288
|
+
```tsx
|
|
289
|
+
import { GlassNav } from '@zakisheriff/liquid-glass';
|
|
290
|
+
|
|
291
|
+
const [tab, setTab] = useState(0);
|
|
85
292
|
<GlassNav
|
|
86
293
|
activeIndex={tab}
|
|
87
294
|
onChange={setTab}
|
|
295
|
+
aria-label="Sections"
|
|
88
296
|
items={[
|
|
89
297
|
{ label: 'Home', icon: <HomeIcon /> },
|
|
90
|
-
{ label: '
|
|
298
|
+
{ label: 'Saved', icon: <BookmarkIcon /> },
|
|
299
|
+
{ label: 'Library', icon: <GridIcon /> },
|
|
300
|
+
{ label: 'Search', icon: <SearchIcon /> },
|
|
91
301
|
]}
|
|
92
302
|
/>
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
**Icons only**
|
|
93
306
|
|
|
307
|
+
```tsx
|
|
308
|
+
{/* Labels become each tab's accessible name */}
|
|
94
309
|
<GlassNav showLabels={false} activeIndex={tab} onChange={setTab} items={tabs} />
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
**Tabs plus a separate search button**
|
|
313
|
+
|
|
314
|
+
```tsx
|
|
315
|
+
<div style={{ display: 'flex', gap: 12 }}>
|
|
316
|
+
<GlassNav activeIndex={tab} onChange={setTab} items={tabs} />
|
|
317
|
+
<GlassButton icon={<SearchIcon />} aria-label="Search" size="lg" />
|
|
318
|
+
</div>
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
| Prop | Type | Default | Description |
|
|
322
|
+
| --- | --- | --- | --- |
|
|
323
|
+
| `items` | `Array<{ label: string; icon?: ReactNode }>` | | The tabs. Icons sit above labels. |
|
|
324
|
+
| `activeIndex` | `number` | `0` | Index of the selected tab. |
|
|
325
|
+
| `onChange` | `(index: number) => void` | | Called when a tab is tapped, or when the lens is dragged onto one. |
|
|
326
|
+
| `showLabels` | `boolean` | `true` | `false` shows icons only. |
|
|
327
|
+
| `intensity` | `number (1–10)` | `5` | Refraction strength, from subtle to heavy. |
|
|
328
|
+
| `aria-label` | `string` | | Accessible name for the tab list. |
|
|
329
|
+
| `className, style` | | | Applied to the bar. |
|
|
330
|
+
|
|
331
|
+
Arrow keys, Home and End move between tabs. Position the bar yourself, for example `position: fixed; bottom: 24px`.
|
|
332
|
+
|
|
333
|
+
### Menu · `GlassMenu`
|
|
334
|
+
|
|
335
|
+
A pull-down menu that grows out of its glass button and folds back into it with a jiggle. Slide a finger across the items to pick one.
|
|
336
|
+
|
|
337
|
+
**Actions**
|
|
338
|
+
|
|
339
|
+
```tsx
|
|
340
|
+
import { GlassMenu } from '@zakisheriff/liquid-glass';
|
|
95
341
|
|
|
96
342
|
<GlassMenu
|
|
97
343
|
icon={<EllipsisIcon />}
|
|
98
344
|
aria-label="More"
|
|
99
345
|
items={[
|
|
100
|
-
{ label: '
|
|
101
|
-
{ label: '
|
|
346
|
+
{ label: 'Share', icon: <ShareIcon />, onSelect: share },
|
|
347
|
+
{ label: 'Duplicate', icon: <CopyIcon />, onSelect: duplicate },
|
|
348
|
+
{ label: 'Delete', icon: <TrashIcon />, destructive: true, onSelect: remove },
|
|
102
349
|
]}
|
|
103
350
|
/>
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
**Choices with a checkmark**
|
|
354
|
+
|
|
355
|
+
```tsx
|
|
356
|
+
<GlassMenu
|
|
357
|
+
icon={<SortIcon />}
|
|
358
|
+
aria-label="Sort by"
|
|
359
|
+
items={['Date', 'Name', 'Size'].map((sort) => ({
|
|
360
|
+
label: sort,
|
|
361
|
+
checked: sort === current,
|
|
362
|
+
onSelect: () => setCurrent(sort),
|
|
363
|
+
}))}
|
|
364
|
+
/>
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
**Placement and size**
|
|
368
|
+
|
|
369
|
+
```tsx
|
|
370
|
+
{/* Grows from the left edge of a small trigger, 260px wide */}
|
|
371
|
+
<GlassMenu icon={<EllipsisIcon />} aria-label="More" align="start" size="sm" width={260} items={items} />
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
| Prop | Type | Default | Description |
|
|
375
|
+
| --- | --- | --- | --- |
|
|
376
|
+
| `icon` | `ReactNode` | | Icon on the trigger button, such as an ellipsis. |
|
|
377
|
+
| `items` | `Array<{ label, icon?, checked?, destructive?, disabled?, onSelect? }>` | | Menu rows. `checked` adds a trailing checkmark; `destructive` makes the label red. |
|
|
378
|
+
| `aria-label` | `string` | | Accessible name for the trigger. Required. |
|
|
379
|
+
| `align` | `'start' \| 'end'` | `'end'` | Edge of the trigger the menu grows from. |
|
|
380
|
+
| `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Trigger size, as for GlassButton. |
|
|
381
|
+
| `width` | `number` | `230` | Menu width in px. |
|
|
382
|
+
| `check` | `ReactNode` | | Replaces the trailing checkmark icon. |
|
|
383
|
+
| `className` | `string` | | Applied to the menu wrapper. |
|
|
384
|
+
|
|
385
|
+
Escape or a tap outside closes the menu. Arrow keys move between items.
|
|
386
|
+
|
|
387
|
+
### Search and text field · `GlassInput`
|
|
388
|
+
|
|
389
|
+
A glass text field with a leading icon, an optional trailing accessory and a clear button.
|
|
390
|
+
|
|
391
|
+
**Search**
|
|
392
|
+
|
|
393
|
+
```tsx
|
|
394
|
+
import { GlassInput } from '@zakisheriff/liquid-glass';
|
|
395
|
+
|
|
396
|
+
const [query, setQuery] = useState('');
|
|
397
|
+
<GlassInput
|
|
398
|
+
type="search"
|
|
399
|
+
placeholder="Search"
|
|
400
|
+
value={query}
|
|
401
|
+
onChange={(event) => setQuery(event.target.value)}
|
|
402
|
+
trailing={<MicIcon />}
|
|
403
|
+
aria-label="Search"
|
|
404
|
+
/>
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
**Text field with a label**
|
|
408
|
+
|
|
409
|
+
```tsx
|
|
410
|
+
<GlassInput label="Name" placeholder="Your name" value={name} onChange={(e) => setName(e.target.value)} />
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
**Custom icon and clear behaviour**
|
|
414
|
+
|
|
415
|
+
```tsx
|
|
416
|
+
<GlassInput
|
|
417
|
+
icon={<MailIcon />}
|
|
418
|
+
type="email"
|
|
419
|
+
placeholder="Email"
|
|
420
|
+
value={email}
|
|
421
|
+
onChange={(e) => setEmail(e.target.value)}
|
|
422
|
+
onClear={() => setEmail('')}
|
|
423
|
+
tint="#30d158"
|
|
424
|
+
/>
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
| Prop | Type | Default | Description |
|
|
428
|
+
| --- | --- | --- | --- |
|
|
429
|
+
| `type` | `string` | `'text'` | Any input type. `'search'` adds a magnifier icon. |
|
|
430
|
+
| `value` | `string` | | Current text. |
|
|
431
|
+
| `onChange` | `(event) => void` | | Standard input change event. |
|
|
432
|
+
| `placeholder` | `string` | | Hint shown while empty. |
|
|
433
|
+
| `label` | `string` | | Small label above the field. |
|
|
434
|
+
| `icon` | `ReactNode` | | Leading icon. |
|
|
435
|
+
| `trailing` | `ReactNode` | | Trailing accessory, such as a microphone. |
|
|
436
|
+
| `onClear` | `() => void` | | Called by the clear button. Without it, clearing sends an empty `onChange`. |
|
|
437
|
+
| `tint` | `string` | | Caret and focus glow colour. |
|
|
438
|
+
| `intensity` | `number (1–10)` | `5` | Refraction strength, from subtle to heavy. |
|
|
104
439
|
|
|
105
|
-
|
|
106
|
-
<GlassSegmented size="sm" options={[{ label: 'Light', icon: <SunIcon /> }, 'Dark']} value={t} onChange={setT} />
|
|
440
|
+
Also accepts every other `<input>` prop (`name`, `autoFocus`, `disabled`, …), and `ref` reaches the input.
|
|
107
441
|
|
|
108
|
-
|
|
109
|
-
<GlassSlider showThumb={false} value={brightness} onChange={setBrightness} icon={<SunIcon />} label="Display" />
|
|
442
|
+
### Card · `GlassCard`
|
|
110
443
|
|
|
111
|
-
|
|
444
|
+
A refracting glass panel for grouping content and controls: frosted, or clear.
|
|
112
445
|
|
|
113
|
-
|
|
114
|
-
<GlassCard variant="clear">…</GlassCard>
|
|
446
|
+
**Regular and clear**
|
|
115
447
|
|
|
116
|
-
|
|
117
|
-
|
|
448
|
+
```tsx
|
|
449
|
+
import { GlassCard } from '@zakisheriff/liquid-glass';
|
|
450
|
+
|
|
451
|
+
<GlassCard>Frosted panel</GlassCard>
|
|
452
|
+
<GlassCard variant="clear">See-through panel</GlassCard>
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
**Spacing, corners and tint**
|
|
456
|
+
|
|
457
|
+
```tsx
|
|
458
|
+
<GlassCard padding="20px" radius="32px" tint="rgb(255 55 95 / 0.18)">
|
|
459
|
+
<h3>Now playing</h3>
|
|
460
|
+
<GlassSlider value={progress} onChange={seek} aria-label="Position" />
|
|
461
|
+
</GlassCard>
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
| Prop | Type | Default | Description |
|
|
465
|
+
| --- | --- | --- | --- |
|
|
466
|
+
| `variant` | `'regular' \| 'clear'` | `'regular'` | Frosted or see-through glass. |
|
|
467
|
+
| `padding` | `string` | `'24px'` | Inner padding, any CSS length. |
|
|
468
|
+
| `radius` | `string` | `'28px'` | Corner radius, any CSS length. |
|
|
469
|
+
| `tint` | `string` | | CSS colour washed over the glass. |
|
|
470
|
+
| `thickness` | `number (1–4)` | `1` | Rim bevel scale. |
|
|
471
|
+
| `intensity` | `number (1–10)` | `5` | Refraction strength, from subtle to heavy. |
|
|
472
|
+
|
|
473
|
+
Also accepts every `<div>` prop (`className`, `style`, `onClick`, …).
|
|
474
|
+
|
|
475
|
+
### Sheet · `GlassSheet`
|
|
476
|
+
|
|
477
|
+
A floating bottom sheet with a spring entrance. Drag or flick it down to dismiss. With detents it opens at half height and drags up to full screen.
|
|
478
|
+
|
|
479
|
+
**Fits its content**
|
|
480
|
+
|
|
481
|
+
```tsx
|
|
482
|
+
import { GlassSheet, GlassButton } from '@zakisheriff/liquid-glass';
|
|
483
|
+
|
|
484
|
+
const [open, setOpen] = useState(false);
|
|
485
|
+
<GlassButton onClick={() => setOpen(true)}>Details</GlassButton>
|
|
486
|
+
<GlassSheet open={open} onClose={() => setOpen(false)} aria-label="Details">
|
|
487
|
+
<p>Anything goes here.</p>
|
|
488
|
+
</GlassSheet>
|
|
118
489
|
```
|
|
119
490
|
|
|
120
|
-
|
|
491
|
+
**Half height, then full screen**
|
|
121
492
|
|
|
122
|
-
|
|
493
|
+
```tsx
|
|
494
|
+
<GlassSheet open={open} onClose={() => setOpen(false)} detents={['medium', 'large']} aria-label="Comments">
|
|
495
|
+
{comments}
|
|
496
|
+
</GlassSheet>
|
|
497
|
+
```
|
|
123
498
|
|
|
124
|
-
|
|
499
|
+
**Inside a container**
|
|
125
500
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
| `GlassSlider` | `value`, `min`, `max`, `step`, `onChange(value)`, `showThumb`, `icon`, `label`, `tint`, `intensity` |
|
|
134
|
-
| `GlassInput` | `type`, `value`, `onChange(event)`, `placeholder`, `label`, `icon`, `trailing`, `onClear`, `tint`, `intensity` |
|
|
135
|
-
| `GlassCard` | `variant` (`regular` · `clear`), `padding`, `radius`, `tint`, `thickness`, `intensity` |
|
|
136
|
-
| `GlassSheet` | `open`, `onClose()`, `detents` (`['medium', 'large']`), `container`, `tint`, `aria-label`, `intensity` |
|
|
501
|
+
```tsx
|
|
502
|
+
{/* Stays inside a positioned element (e.g. a phone mockup) without locking page scroll */}
|
|
503
|
+
const [frame, setFrame] = useState<HTMLDivElement | null>(null);
|
|
504
|
+
<div ref={setFrame} style={{ position: 'relative', height: 600, overflow: 'hidden' }}>
|
|
505
|
+
<GlassSheet open={open} onClose={() => setOpen(false)} container={frame}>…</GlassSheet>
|
|
506
|
+
</div>
|
|
507
|
+
```
|
|
137
508
|
|
|
138
|
-
|
|
509
|
+
| Prop | Type | Default | Description |
|
|
510
|
+
| --- | --- | --- | --- |
|
|
511
|
+
| `open` | `boolean` | | Whether the sheet is shown. |
|
|
512
|
+
| `onClose` | `() => void` | | Called when the scrim is tapped, Escape is pressed or the sheet is swiped down. |
|
|
513
|
+
| `detents` | `Array<'medium' \| 'large'>` | | Resting heights. `['medium', 'large']` opens at half height. Unset: fits its content. |
|
|
514
|
+
| `container` | `HTMLElement \| null` | `viewport` | Positioned element to keep the sheet inside. |
|
|
515
|
+
| `tint` | `string` | | CSS colour washed over the glass. |
|
|
516
|
+
| `aria-label` | `string` | | Accessible name for the dialog. |
|
|
517
|
+
| `intensity` | `number (1–10)` | `5` | Refraction strength, from subtle to heavy. |
|
|
518
|
+
<!-- components:end -->
|
|
139
519
|
|
|
140
520
|
## Lightweight
|
|
141
521
|
|
package/dist/index.css
CHANGED
|
@@ -552,11 +552,16 @@
|
|
|
552
552
|
left: 0;
|
|
553
553
|
}
|
|
554
554
|
.lg-menu.lg-glass {
|
|
555
|
-
--lg-glass-fill: var(--lg-
|
|
556
|
-
--lg-glass-blur:
|
|
555
|
+
--lg-glass-fill: color-mix(in srgb, var(--lg-fill) 55%, transparent);
|
|
556
|
+
--lg-glass-blur: 12px;
|
|
557
|
+
--lg-saturate: 1.9;
|
|
557
558
|
position: absolute;
|
|
558
559
|
inset: 0;
|
|
559
|
-
box-shadow:
|
|
560
|
+
box-shadow:
|
|
561
|
+
0 18px 44px rgb(0 0 0 / 0.18),
|
|
562
|
+
inset 0 0 0 0.5px rgb(255 255 255 / 0.6),
|
|
563
|
+
inset 0 1px 1px rgb(255 255 255 / 0.75),
|
|
564
|
+
inset 0 -1px 1px rgb(255 255 255 / 0.25);
|
|
560
565
|
transform-origin: top right;
|
|
561
566
|
transition: none;
|
|
562
567
|
pointer-events: none;
|