glasslikeui 1.9.0 → 1.10.0
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 +892 -24
- package/dist/actions/adaptiveTone.d.ts +50 -0
- package/dist/actions/adaptiveTone.js +569 -0
- package/dist/actions/alertLogic.d.ts +67 -0
- package/dist/actions/alertLogic.js +123 -0
- package/dist/actions/anchorPlacement.d.ts +92 -0
- package/dist/actions/anchorPlacement.js +137 -0
- package/dist/actions/dragSnap.d.ts +1 -1
- package/dist/actions/dragSnapMath.d.ts +70 -0
- package/dist/actions/dragSnapMath.js +115 -0
- package/dist/actions/glassToneLogic.d.ts +182 -0
- package/dist/actions/glassToneLogic.js +513 -0
- package/dist/actions/heightTransition.d.ts +32 -0
- package/dist/actions/heightTransition.js +64 -0
- package/dist/actions/index.d.ts +1 -0
- package/dist/actions/index.js +1 -0
- package/dist/actions/inertSiblings.js +20 -4
- package/dist/actions/menuLogic.d.ts +40 -0
- package/dist/actions/menuLogic.js +68 -0
- package/dist/actions/modalDialog.d.ts +19 -0
- package/dist/actions/modalDialog.js +48 -0
- package/dist/actions/popoverLogic.d.ts +25 -0
- package/dist/actions/popoverLogic.js +48 -0
- package/dist/actions/rovingIndex.d.ts +30 -0
- package/dist/actions/rovingIndex.js +49 -0
- package/dist/actions/scrollRunTracker.d.ts +36 -0
- package/dist/actions/scrollRunTracker.js +77 -0
- package/dist/actions/scrollUnder.d.ts +21 -0
- package/dist/actions/scrollUnder.js +29 -0
- package/dist/actions/segmentedLogic.d.ts +38 -0
- package/dist/actions/segmentedLogic.js +59 -0
- package/dist/actions/sheetLogic.d.ts +43 -0
- package/dist/actions/sheetLogic.js +71 -0
- package/dist/actions/sliderLogic.d.ts +29 -0
- package/dist/actions/sliderLogic.js +53 -0
- package/dist/actions/swipeActions.d.ts +46 -2
- package/dist/actions/swipeActions.js +267 -46
- package/dist/actions/tabBarMinimize.d.ts +31 -0
- package/dist/actions/tabBarMinimize.js +38 -0
- package/dist/actions/tabViewLogic.d.ts +47 -0
- package/dist/actions/tabViewLogic.js +71 -0
- package/dist/actions/toggleKnobLogic.d.ts +57 -0
- package/dist/actions/toggleKnobLogic.js +66 -0
- package/dist/actions/toolbarFocus.d.ts +44 -0
- package/dist/actions/toolbarFocus.js +228 -0
- package/dist/actions/topLayer.d.ts +12 -0
- package/dist/actions/topLayer.js +18 -0
- package/dist/components/dialog/ActionSheet.svelte +457 -0
- package/dist/components/dialog/ActionSheet.svelte.d.ts +25 -0
- package/dist/components/dialog/Alert.svelte +337 -0
- package/dist/components/dialog/Alert.svelte.d.ts +28 -0
- package/dist/components/dialog/index.d.ts +6 -0
- package/dist/components/dialog/index.js +6 -0
- package/dist/components/glass/Glass.svelte +49 -17
- package/dist/components/glass/Glass.svelte.d.ts +8 -0
- package/dist/components/glass/GlassSection.svelte +9 -1
- package/dist/components/glass/LensFilters.svelte +4 -2
- package/dist/components/glass/Popover.svelte +379 -0
- package/dist/components/glass/Popover.svelte.d.ts +30 -0
- package/dist/components/glass/Sheet.svelte +470 -103
- package/dist/components/glass/Sheet.svelte.d.ts +55 -7
- package/dist/components/glass/index.d.ts +3 -0
- package/dist/components/glass/index.js +1 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +4 -0
- package/dist/components/interactive/Badge.svelte +97 -6
- package/dist/components/interactive/Badge.svelte.d.ts +13 -2
- package/dist/components/interactive/Button.svelte +162 -20
- package/dist/components/interactive/Button.svelte.d.ts +14 -1
- package/dist/components/interactive/IconButton.svelte +214 -4
- package/dist/components/interactive/IconButton.svelte.d.ts +2 -1
- package/dist/components/interactive/ProgressView.svelte +306 -0
- package/dist/components/interactive/ProgressView.svelte.d.ts +25 -0
- package/dist/components/interactive/Segment.d.ts +14 -0
- package/dist/components/interactive/Segment.js +1 -0
- package/dist/components/interactive/SegmentedControl.svelte +399 -0
- package/dist/components/interactive/SegmentedControl.svelte.d.ts +17 -0
- package/dist/components/interactive/Slider.svelte +299 -0
- package/dist/components/interactive/Slider.svelte.d.ts +23 -0
- package/dist/components/interactive/TabView.svelte +573 -41
- package/dist/components/interactive/TabView.svelte.d.ts +25 -0
- package/dist/components/interactive/Toggle.svelte +287 -16
- package/dist/components/interactive/Toggle.svelte.d.ts +12 -0
- package/dist/components/interactive/index.d.ts +4 -0
- package/dist/components/interactive/index.js +3 -0
- package/dist/components/list/List.svelte +41 -17
- package/dist/components/list/List.svelte.d.ts +1 -0
- package/dist/components/list/ListRow.svelte +208 -47
- package/dist/components/list/ListRow.svelte.d.ts +16 -1
- package/dist/components/menu/Menu.svelte +51 -27
- package/dist/components/menu/Menu.svelte.d.ts +5 -0
- package/dist/components/menu/MenuItem.svelte +82 -25
- package/dist/components/menu/MenuItem.svelte.d.ts +8 -0
- package/dist/components/menu/MenuSection.svelte +95 -0
- package/dist/components/menu/MenuSection.svelte.d.ts +18 -0
- package/dist/components/menu/MenuSubmenu.svelte +196 -0
- package/dist/components/menu/MenuSubmenu.svelte.d.ts +11 -0
- package/dist/components/menu/index.d.ts +4 -1
- package/dist/components/menu/index.js +3 -1
- package/dist/components/navigation/NavigationBar.svelte +97 -15
- package/dist/components/navigation/NavigationBar.svelte.d.ts +6 -0
- package/dist/components/toolbar/Toolbar.svelte +43 -0
- package/dist/components/toolbar/Toolbar.svelte.d.ts +13 -0
- package/dist/components/toolbar/ToolbarItemGroup.svelte +45 -0
- package/dist/components/toolbar/ToolbarItemGroup.svelte.d.ts +14 -0
- package/dist/components/toolbar/ToolbarSpacer.svelte +36 -0
- package/dist/components/toolbar/ToolbarSpacer.svelte.d.ts +12 -0
- package/dist/components/toolbar/index.d.ts +7 -0
- package/dist/components/toolbar/index.js +7 -0
- package/dist/components/typography/Text.svelte +9 -1
- package/dist/constants/alertAction.d.ts +19 -0
- package/dist/constants/alertAction.js +1 -0
- package/dist/constants/badge.d.ts +32 -0
- package/dist/constants/badge.js +47 -0
- package/dist/constants/buttons.d.ts +45 -0
- package/dist/constants/buttons.js +52 -0
- package/dist/constants/colors.d.ts +9 -4
- package/dist/constants/colors.js +9 -4
- package/dist/constants/index.d.ts +3 -0
- package/dist/constants/index.js +3 -0
- package/dist/constants/progress.d.ts +56 -0
- package/dist/constants/progress.js +75 -0
- package/dist/constants/variants.d.ts +6 -2
- package/dist/constants/variants.js +2 -2
- package/dist/styles/glasslikeui.css +135 -1
- package/dist/styles/lens.css +21 -19
- package/dist/styles/squircle.css +17 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -32,6 +32,10 @@ stylesheets you want:
|
|
|
32
32
|
<!-- rest of app -->
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
+
`LensFilters` supplies the squircle clip path used by `.glass-squircle`. It
|
|
36
|
+
also still defines the deprecated `#glass-lens-refract` filter, which `Glass`
|
|
37
|
+
no longer applies.
|
|
38
|
+
|
|
35
39
|
Optional: wire browser accessibility prefs into the library's fallback
|
|
36
40
|
attributes on non-Safari browsers:
|
|
37
41
|
|
|
@@ -61,12 +65,23 @@ attributes on non-Safari browsers:
|
|
|
61
65
|
## Variants and intensity
|
|
62
66
|
|
|
63
67
|
`Glass` (and its consumers: `GlassCard`, `GlassSection`, `List`,
|
|
64
|
-
`TabView`)
|
|
68
|
+
`TabView`) blurs the page behind it and lays a tinted fill on top. Its edge
|
|
69
|
+
has a smooth lens rim: a thin specular line and a soft glow inside every
|
|
70
|
+
side. Nothing displaces the surface's shape, so the edge stays crisp and the
|
|
71
|
+
same on all four sides.
|
|
72
|
+
|
|
73
|
+
Avoid opacity, filter, clip-path or mask on a glass surface, or a blend mode
|
|
74
|
+
on `.glass-content`: any of them stops the blur reaching the page. For the
|
|
75
|
+
same reason, where `corner-shape` is missing (such as Firefox), a
|
|
76
|
+
`.glass-squircle` glass surface keeps rounded corners instead of being
|
|
77
|
+
clipped.
|
|
78
|
+
|
|
79
|
+
`Glass` takes two orthogonal props:
|
|
65
80
|
|
|
66
81
|
- `variant` -- `regular` (default) or `clear`. Clear requires a
|
|
67
82
|
`<GlassDimLayer />` companion for legibility.
|
|
68
83
|
- `intensity` -- `subtle`, `standard` (default), or `prominent`.
|
|
69
|
-
Controls blur
|
|
84
|
+
Controls blur and saturation together.
|
|
70
85
|
|
|
71
86
|
## Components
|
|
72
87
|
|
|
@@ -78,18 +93,26 @@ attributes on non-Safari browsers:
|
|
|
78
93
|
| `GlassEffectContainer` | Groups glass siblings with shared shadow. |
|
|
79
94
|
| `GlassDimLayer` | Required under `variant="clear"`. |
|
|
80
95
|
| `GlassMorph` | Tag a subtree for View Transitions morph. |
|
|
81
|
-
| `LensFilters` |
|
|
96
|
+
| `LensFilters` | Squircle clip path (mount once). |
|
|
82
97
|
| `Sheet` | Bottom sheet with detents + drag-to-snap. |
|
|
83
|
-
| `
|
|
98
|
+
| `Popover` | Panel anchored to its source; a sheet on compact widths. |
|
|
99
|
+
| `Alert` | Centred alert with roles and an optional field. |
|
|
100
|
+
| `ActionSheet` | Confirmation dialog that grows from its source. |
|
|
101
|
+
| `NavigationBar` | Top bar with no fill of its own, and a scroll edge effect under it once content scrolls beneath. Supports `largeTitle` collapse. |
|
|
84
102
|
| `NavigationLink` | Pill-style link. |
|
|
85
|
-
| `TabView` | Floating tab bar.
|
|
103
|
+
| `TabView` | Floating tab bar with badges, a search tab, a bottom accessory and minimise on scroll. |
|
|
104
|
+
| `SegmentedControl` | iOS-style segmented picker with a sliding thumb. |
|
|
105
|
+
| `Toolbar` / `ToolbarItemGroup` / `ToolbarSpacer` | Toolbar of grouped glass capsules with roving focus. |
|
|
86
106
|
| `Button` | `filled` / `outlined` / `plain` / `tinted` / `destructive` / `glass` / `glassProminent`. |
|
|
87
|
-
| `IconButton` | `plain` / `filled`.
|
|
107
|
+
| `IconButton` | `plain` / `filled` / `glass` / `glassProminent`. |
|
|
88
108
|
| `Toggle` | iOS-style switch over a native checkbox. |
|
|
89
|
-
| `
|
|
109
|
+
| `ProgressView` | Spinner, bar or ring; determinate or not. |
|
|
110
|
+
| `Badge` | `default` / `accent` / `notification`; text, count or dot. |
|
|
111
|
+
| `Slider` | iOS-style slider over a native range input. |
|
|
90
112
|
| `Text` | Dynamic-Type-aware text. |
|
|
91
113
|
| `Label` | Icon + title pair with SwiftUI label styles. |
|
|
92
|
-
| `List` / `ListRow` |
|
|
114
|
+
| `List` / `ListRow` | `plain`, `inset`, `grouped` or `insetGrouped` list on an opaque card, with swipe actions on either edge. |
|
|
115
|
+
| `Menu` / `MenuItem` / `MenuSection` / `MenuSubmenu` | Pull-down menu with sections, submenus, checkable and disabled items. |
|
|
93
116
|
| `HStack` / `VStack` / `ZStack` / `Grid` / `Spacer` / `Divider` / `ScrollView` | Layout primitives. |
|
|
94
117
|
| `SymbolImage` | SVG icon renderer. |
|
|
95
118
|
|
|
@@ -113,24 +136,284 @@ child (`span`, `label`, `strong`, `b`, `em`, `small`, `svg` or `img`), so
|
|
|
113
136
|
panels and cards built from stacks, paragraphs and grids keep their layout.
|
|
114
137
|
Bare text directly inside a `rect` is not centred, wrap it in a `span`.
|
|
115
138
|
|
|
139
|
+
A class you pass to `Glass` can set the surface's `position`, because its own
|
|
140
|
+
`position: relative` has zero specificity. Keep the surface positioned
|
|
141
|
+
(relative, absolute, fixed or sticky): its frost and rim layers are placed
|
|
142
|
+
against it.
|
|
143
|
+
|
|
116
144
|
Buttons get the same treatment through the `glass` and
|
|
117
145
|
`glassProminent` variants, which read their blur and saturation from
|
|
118
146
|
the shared intensity tokens rather than duplicating them.
|
|
119
147
|
|
|
148
|
+
## Adaptive text on glass
|
|
149
|
+
|
|
150
|
+
Glass is see-through, so text on it must suit what is behind it, not only the
|
|
151
|
+
theme. As on iOS 26, `Glass` flips its text between dark and light to suit the
|
|
152
|
+
backdrop: dark glyphs over a white page, light glyphs over a dark photo. Every
|
|
153
|
+
component built on `Glass` gets this, including the `TabView` bar and
|
|
154
|
+
`ToolbarItemGroup` capsules.
|
|
155
|
+
|
|
156
|
+
```svelte
|
|
157
|
+
<Glass>...</Glass> <!-- tone="auto", the default -->
|
|
158
|
+
<Glass tone="dark">...</Glass> <!-- the backdrop is dark: light text -->
|
|
159
|
+
<Glass tone="light">...</Glass> <!-- the backdrop is light: dark text -->
|
|
160
|
+
<Glass tone="theme">...</Glass> <!-- the theme's text colours, as before -->
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
`auto` is the default because Liquid Glass is chrome that floats over content
|
|
164
|
+
it does not control. Use `theme` for a surface whose own fill is opaque enough,
|
|
165
|
+
or `light` and `dark` when you know the backdrop. A forced `light` or `dark` is
|
|
166
|
+
written into the markup, so server-rendered pages have it before any script
|
|
167
|
+
runs.
|
|
168
|
+
|
|
169
|
+
How it works:
|
|
170
|
+
|
|
171
|
+
- The surface gets `data-glass-tone="light"` over a light backdrop and
|
|
172
|
+
`data-glass-tone="dark"` over a dark one. `glasslikeui.css` turns that into
|
|
173
|
+
`--glass-fg` (black or white), `--glass-fg-secondary` (the same at 60%, as
|
|
174
|
+
iOS secondary labels) and `--glass-fg-accent` (the accent, mixed toward black
|
|
175
|
+
or white as far as it must be to hold 4.5:1). Read them for text of your own
|
|
176
|
+
on glass, with the theme colour as the fallback:
|
|
177
|
+
`color: var(--glass-fg, var(--color-text))`. Outside a toned surface the
|
|
178
|
+
fallback is used, so nothing changes where the feature is off.
|
|
179
|
+
- A page cannot read the pixels behind an element, so the backdrop is
|
|
180
|
+
estimated. A few points on the surface are hit tested with
|
|
181
|
+
`elementsFromPoint`, open shadow roots included. The surface and its content
|
|
182
|
+
are skipped, the background colours below it are painted together, alpha and
|
|
183
|
+
opacity included, and the surface's own fill is painted on top. A linear
|
|
184
|
+
gradient is read at each point; other gradients are read as their stops.
|
|
185
|
+
Colours in any CSS colour space (`oklch()`, `lab()` and the rest) are
|
|
186
|
+
converted to sRGB. The tone is the one whose text holds 4.5:1 over the result.
|
|
187
|
+
- The glass `saturate()` backdrop filter is modelled. Chromium saturates the
|
|
188
|
+
fill and the page under it together, which clips channels and changes how
|
|
189
|
+
light a colour is: dark glass over red shows pure red, and over green a
|
|
190
|
+
darker green. This is checked by pixel in Chromium. Safari and Firefox,
|
|
191
|
+
which also paint `backdrop-filter`, are taken to paint it the same way. Where `CSS.supports()` reports `backdrop-filter` or
|
|
192
|
+
`-webkit-backdrop-filter`, the tone is measured over that saturated painting.
|
|
193
|
+
Where neither is supported, the page shows through with the fill over it,
|
|
194
|
+
and that is what is measured.
|
|
195
|
+
- Accent text is measured over the glass and over the glass under the
|
|
196
|
+
selection fill (`--glass-active-bg`), as the selected tab sits on it. Where
|
|
197
|
+
no accent holds, the selected label is black or white and the selection
|
|
198
|
+
pill leans the other way (`--glass-tone-active-bg`), so the label stands out
|
|
199
|
+
from the pill too.
|
|
200
|
+
- `data-glass-tone-secondary` is `80` or `100` when 60% would not hold 4.5:1,
|
|
201
|
+
and `data-glass-tone-accent` holds how much accent the selected `TabView` tab
|
|
202
|
+
keeps (`100`, `75`, `50`, `25` or `0`).
|
|
203
|
+
- It does not flicker. A tone is kept while its text still holds 4.5:1, so a
|
|
204
|
+
backdrop near the middle does not flip it back and forth.
|
|
205
|
+
- It re-checks floating surfaces (fixed or sticky, or inside a fixed or sticky
|
|
206
|
+
element) on scroll, once per frame at most, and every 500ms while one of them
|
|
207
|
+
is on screen and the page is shown. A scroll inside an element also
|
|
208
|
+
re-checks every surface outside it, such as a bar positioned over an inner
|
|
209
|
+
scroller. A surface in the page flow is re-checked as more of it comes on
|
|
210
|
+
screen. Every surface is re-checked on resize, on a change to its own size,
|
|
211
|
+
on a theme or preference change, when a CSS transition or animation on the
|
|
212
|
+
page ends, on `popstate` and `hashchange`, and when you call
|
|
213
|
+
`refreshAdaptiveTone()`. Only surfaces on screen do work. Reads for every
|
|
214
|
+
surface come before any write, so a check forces one layout at most.
|
|
215
|
+
- The first tone is written before the first paint, and the text does not fade
|
|
216
|
+
into it. A forced tone is ready in the markup, so its transitions run
|
|
217
|
+
without script. Later flips cross-fade, and switch at once under reduced motion.
|
|
218
|
+
- Under reduced transparency or more contrast the fill is solid, so the tone
|
|
219
|
+
follows the fill. Under forced colours the tone is off and the system colours
|
|
220
|
+
win.
|
|
221
|
+
- To turn the automatic tone off for a whole page, or a part of it, put
|
|
222
|
+
`data-glass-adaptive="off"` on `<html>` or the element around it.
|
|
223
|
+
- Untoned `Glass`, glass and filled `Button`s and `IconButton`s, and floating
|
|
224
|
+
layers (`[popover]`, `role="dialog"`, `role="alertdialog"`, `role="menu"`,
|
|
225
|
+
`role="listbox"`, `role="tooltip"`) start afresh, so they do not take the tone
|
|
226
|
+
of glass they sit in. A glass button's smoked fill already holds its theme
|
|
227
|
+
label at 4.5:1 over any backdrop.
|
|
228
|
+
|
|
229
|
+
What it cannot see, and what to do:
|
|
230
|
+
|
|
231
|
+
- Images, video, canvas, iframes and inline SVG are not read: the browser does
|
|
232
|
+
not expose their pixels cheaply, and not at all across origins. Mark them, or
|
|
233
|
+
a section that holds them, with `data-glass-backdrop="light"` or `"dark"`. A
|
|
234
|
+
point over an unmarked one is skipped, and a surface with nothing readable
|
|
235
|
+
keeps the theme colours. A hint covers a range: `dark` is anything from black
|
|
236
|
+
to a dark grey (`#444444`), and `light` anything from white to a light grey
|
|
237
|
+
(`#aaaaaa`), so lighter patches in a dark photo still get readable text.
|
|
238
|
+
Text holds 4.5:1 over images inside those ranges. An image between
|
|
239
|
+
`#444444` and `#aaaaaa` fits neither hint: leave it unmarked, and the
|
|
240
|
+
surface keeps the theme colours.
|
|
241
|
+
- Elements with `pointer-events: none` are invisible to hit testing, so an
|
|
242
|
+
overlay like that (a scrim, a decorative layer) is not seen. Put
|
|
243
|
+
`data-glass-backdrop` on the element under it that the hit test does reach,
|
|
244
|
+
such as its section.
|
|
245
|
+
- A closed shadow root cannot be read. A custom element with no open shadow
|
|
246
|
+
root and no background of its own is treated as unknown, so give it, or its
|
|
247
|
+
section, a `data-glass-backdrop` hint.
|
|
248
|
+
- A backdrop changed by script with nothing scrolling, and no transition or
|
|
249
|
+
animation ending, waits for the next 500ms check on a floating surface. Call
|
|
250
|
+
`refreshAdaptiveTone()` after such a change, such as a route swap.
|
|
251
|
+
- Blur and `mix-blend-mode` are not modelled. The estimate is of the colours
|
|
252
|
+
at a few points, which blur averages. A backdrop that runs from dark to light
|
|
253
|
+
under one surface, such as a black to white gradient across a toolbar, or
|
|
254
|
+
busy stripes, has no single tone that holds 4.5:1 everywhere. The tone that
|
|
255
|
+
does best is used. Give such a surface a fill of its own, or `tone="theme"`.
|
|
256
|
+
|
|
257
|
+
The `adaptiveTone` action is exported for surfaces of your own:
|
|
258
|
+
`<div use:adaptiveTone={{ tone: 'auto' }}>`.
|
|
259
|
+
|
|
260
|
+
## Button sizes, shapes, roles and loading
|
|
261
|
+
|
|
262
|
+
`Button` mirrors SwiftUI's `controlSize`, `buttonBorderShape` and
|
|
263
|
+
`ButtonRole`. All of these are opt in; a Button without them is unchanged.
|
|
264
|
+
|
|
265
|
+
```svelte
|
|
266
|
+
<Button variant="glass" size="xl">Continue</Button>
|
|
267
|
+
<Button variant="glassProminent" shape="circle">Go</Button>
|
|
268
|
+
<Button variant="glass" shape="roundedRect">Edit</Button>
|
|
269
|
+
<Button variant="tinted" buttonRole="destructive">Delete</Button>
|
|
270
|
+
<Button variant="filled" buttonRole="confirm">Done</Button>
|
|
271
|
+
<Button variant="filled" loading loadingLabel="Saving">Save</Button>
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
- `size`: `sm`, `md` (default), `lg` or `xl`, the iOS 26 extra large size.
|
|
275
|
+
- `shape`: `capsule` (default), `circle` (square, for a short label; for an icon alone use `IconButton`, which takes a `label`) or
|
|
276
|
+
`roundedRect` (`--glass-radius-sm`). Works with every variant.
|
|
277
|
+
- `buttonRole`: `cancel`, `destructive` or `confirm` (`primary` is accepted
|
|
278
|
+
as an alias of `confirm`). `destructive` swaps the accent for
|
|
279
|
+
`--color-danger` within the variant (fill, text and wash; the plain `glass`
|
|
280
|
+
label stays neutral, since red text cannot hold 4.5:1 over every backdrop).
|
|
281
|
+
`confirm` sets the label in semibold. `cancel` carries no look of its own.
|
|
282
|
+
The resolved role shows as `data-role`. It is not an ARIA role: the element
|
|
283
|
+
stays a button or link.
|
|
284
|
+
- `loading`: shows the iOS spinner over the label, in the label colour. The
|
|
285
|
+
label stays in place, transparent, so the width does not jump and the
|
|
286
|
+
accessible name is kept (or replaced by `loadingLabel`). The button gets
|
|
287
|
+
`aria-busy="true"` and `aria-disabled="true"`, stays focusable, and ignores
|
|
288
|
+
clicks, including form submission. A link drops its `href` while loading,
|
|
289
|
+
as when disabled, but gets `tabindex="0"`, so it stays in the Tab order and
|
|
290
|
+
keeps focus if it had it.
|
|
291
|
+
|
|
292
|
+
`IconButton` takes `variant="glass"` and `variant="glassProminent"`, the
|
|
293
|
+
iOS 26 toolbar glass buttons. It is already a circle at every size, and its
|
|
294
|
+
glass layers are the same rules as the glass `Button`.
|
|
295
|
+
|
|
296
|
+
Pressed, a `glass` or `glassProminent` `Button` or `IconButton`, and the
|
|
297
|
+
`Sheet` close button, grows by 4% and settles back with a small overshoot on
|
|
298
|
+
release, as iOS 26 glass does. The fill still deepens as before. Under
|
|
299
|
+
`prefers-reduced-motion` or `data-reduced-motion="true"` it does not grow.
|
|
300
|
+
|
|
301
|
+
## Progress
|
|
302
|
+
|
|
303
|
+
`ProgressView` mirrors SwiftUI's `ProgressView`. Leave `value` unset for an
|
|
304
|
+
indeterminate view; give it a `value` (out of `total`, default 1) for a
|
|
305
|
+
determinate one.
|
|
306
|
+
|
|
307
|
+
```svelte
|
|
308
|
+
<ProgressView accessibilityLabel="Loading" />
|
|
309
|
+
<ProgressView value={0.4} label="Downloading" currentValueLabel="40%" />
|
|
310
|
+
<ProgressView value={3} total={10} progressViewStyle="circular" size="lg" />
|
|
311
|
+
<ProgressView progressViewStyle="linear" label="Syncing" glass />
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
- `progressViewStyle`: `automatic` (default) draws a linear bar when
|
|
315
|
+
determinate and the eight spoke iOS spinner when not. `linear` and
|
|
316
|
+
`circular` force either shape, so an indeterminate bar and a determinate
|
|
317
|
+
ring are both available.
|
|
318
|
+
- `size`: `sm`, `md` (default, the 20pt iOS indicator) or `lg` (37pt).
|
|
319
|
+
- `label` (or a `children` snippet) names the progressbar and sits above a
|
|
320
|
+
bar or below a spinner. Without one, pass `accessibilityLabel`; with
|
|
321
|
+
neither, the progressbar is named "Loading", so it is never nameless.
|
|
322
|
+
- `currentValueLabel` shows under the view. When determinate it is also the
|
|
323
|
+
`aria-valuetext`; when indeterminate it describes the progressbar through
|
|
324
|
+
`aria-describedby`.
|
|
325
|
+
- `glass` sets the view on a blurred glass platter.
|
|
326
|
+
|
|
327
|
+
It renders `role="progressbar"`. Determinate views carry `aria-valuemin`
|
|
328
|
+
(0), `aria-valuemax` (the total) and `aria-valuenow` (clamped into range);
|
|
329
|
+
indeterminate ones carry `aria-busy="true"` and no value. The bar fills with
|
|
330
|
+
logical sizing, so it grows from the right under `dir="rtl"`. Under reduced
|
|
331
|
+
motion the spinner and the indeterminate bar stop moving and fade slowly
|
|
332
|
+
instead, and a determinate fill jumps to its value. Under reduced
|
|
333
|
+
transparency the glass platter turns solid. The fill uses `--color-accent`;
|
|
334
|
+
restyle the track with `--glass-progress-track` and the spinner with
|
|
335
|
+
`--progress-spinner-color`. Text follows `--color-text` and `--color-text-secondary`,
|
|
336
|
+
falling back to `--glass-text-color-default` when the page sets neither.
|
|
337
|
+
|
|
338
|
+
## List
|
|
339
|
+
|
|
340
|
+
`List` mirrors SwiftUI's list styles. Rows are content, so every style but
|
|
341
|
+
`plain` draws them on an opaque card, the iOS grouped background
|
|
342
|
+
(`#1c1c1e` dark, `#ffffff` light), not on Liquid Glass: the HIG keeps glass for
|
|
343
|
+
the controls and navigation that float above the content.
|
|
344
|
+
|
|
345
|
+
- `insetGrouped` (the default): a card inset 16px from each side, with 26px
|
|
346
|
+
corners.
|
|
347
|
+
- `inset`: the same inset card with smaller corners (`--glass-radius-sm`).
|
|
348
|
+
- `grouped`: a card that runs edge to edge, with square corners.
|
|
349
|
+
- `plain`: no card. The rows sit on the page.
|
|
350
|
+
|
|
351
|
+
A `ListRow` is 44px tall, or 52px with a `subtitle`, with the title at 17px and
|
|
352
|
+
the subtitle at 13px. Its separator starts where the text starts, after any
|
|
353
|
+
`leading` icon, and runs to the trailing edge. The last row has none. A pressed
|
|
354
|
+
interactive row fills with the iOS cell highlight. Set your page background
|
|
355
|
+
(`#000000` dark, `#f2f2f7` light in iOS) yourself.
|
|
356
|
+
|
|
357
|
+
The title and the library's subtitle colour hold 4.5:1 on the card and on the
|
|
358
|
+
pressed highlight, in both themes. The subtitle uses `--color-text-secondary`
|
|
359
|
+
when your page sets it, and then its contrast is yours to check: a typical
|
|
360
|
+
secondary grey holds 4.5:1 on the card but can fall to about 3.3:1 on the
|
|
361
|
+
pressed highlight.
|
|
362
|
+
|
|
363
|
+
A swipeable row slides on the card colour inside a `List`, even when your page
|
|
364
|
+
sets `--color-bg`. Outside a card, or in a `plain` list, it slides on
|
|
365
|
+
`--color-bg`.
|
|
366
|
+
|
|
120
367
|
## Swipe actions and pull to refresh
|
|
121
368
|
|
|
122
|
-
`ListRow`
|
|
123
|
-
`.swipeActions(edge:
|
|
369
|
+
`ListRow` takes swipe actions on either edge or both, mirroring SwiftUI's
|
|
370
|
+
`.swipeActions(edge: .leading)` and `.swipeActions(edge: .trailing)` on one
|
|
371
|
+
row. Dragging right reveals the leading actions and dragging left the trailing
|
|
372
|
+
ones (the other way round in a right to left layout, from `dir="rtl"` or CSS
|
|
373
|
+
`direction: rtl`). Dragging back past the resting point closes one side and
|
|
374
|
+
opens the other. Only one row is open at a time. A tap on an open row closes
|
|
375
|
+
it and does nothing else, and the click a browser sends after a swipe never
|
|
376
|
+
reaches the row.
|
|
124
377
|
|
|
125
378
|
```svelte
|
|
126
|
-
<ListRow
|
|
379
|
+
<ListRow>
|
|
127
380
|
{#snippet children()}{item.title}{/snippet}
|
|
128
|
-
{#snippet
|
|
129
|
-
<button onclick={() =>
|
|
381
|
+
{#snippet leadingSwipeActions()}
|
|
382
|
+
<button style="background: #0a84ff" onclick={() => pin(item)}>Pin</button>
|
|
383
|
+
{/snippet}
|
|
384
|
+
{#snippet trailingSwipeActions()}
|
|
385
|
+
<button onclick={() => more(item)}>More</button>
|
|
386
|
+
<button style="background: #d70015" onclick={() => remove(item)}>Delete</button>
|
|
130
387
|
{/snippet}
|
|
131
388
|
</ListRow>
|
|
132
389
|
```
|
|
133
390
|
|
|
391
|
+
As in iOS 26, each action is its own capsule, inset from the row with a gap
|
|
392
|
+
between them. The default capsule is grey (`#636366`) with a white 15px
|
|
393
|
+
semibold label. The capsule rules use `:where()`, so your own colours and
|
|
394
|
+
shapes on the buttons win. Give each a colour that holds 4.5:1 with its label.
|
|
395
|
+
With forced colours each capsule gets a `ButtonText` outline.
|
|
396
|
+
|
|
397
|
+
A full swipe, past half the row, runs the edge-most action: the first leading
|
|
398
|
+
action or the last trailing one, which is the first in SwiftUI's order. Its
|
|
399
|
+
capsule stretches across the row as you drag. It is on for both edges by
|
|
400
|
+
default, as in SwiftUI. Turn it off with `leadingAllowsFullSwipe={false}` or
|
|
401
|
+
`trailingAllowsFullSwipe={false}`, or pass `onLeadingFullSwipe` or
|
|
402
|
+
`onTrailingFullSwipe` to run something else instead. After the action the row
|
|
403
|
+
springs back closed, as in iOS. For a row the action removes, return `true`
|
|
404
|
+
from the callback to leave it swiped away until it goes.
|
|
405
|
+
|
|
406
|
+
The actions need no swipe. They follow the row in the reading order (leading
|
|
407
|
+
first, then the row, then trailing), so a screen reader reads them and Tab
|
|
408
|
+
reaches them. Focus on an action opens its edge, so it is on screen, and the
|
|
409
|
+
edge closes when focus leaves.
|
|
410
|
+
|
|
411
|
+
`swipeActions` with `swipeEdge` and `allowsFullSwipe` still works and is
|
|
412
|
+
deprecated. It fills its edge when that edge has no snippet of its own. Its full
|
|
413
|
+
swipe stays off by default, runs only `onFullSwipe` and leaves the row swiped
|
|
414
|
+
away, as before. Unlike before, it follows a right to left layout: a leading
|
|
415
|
+
strip sits on the right there.
|
|
416
|
+
|
|
134
417
|
`ScrollView` accepts an `onRefresh` handler, mirroring
|
|
135
418
|
`.refreshable`. The indicator stays up until the returned promise
|
|
136
419
|
settles -- including when it rejects:
|
|
@@ -144,16 +427,46 @@ settles -- including when it rejects:
|
|
|
144
427
|
Dragging past the width of the action strip is damped by a rubber band
|
|
145
428
|
and never travels further than the row is wide. The strip grows to fill
|
|
146
429
|
exactly the space the row has uncovered, so it stays attached to the row
|
|
147
|
-
and the edge-most action
|
|
148
|
-
|
|
149
|
-
your own styles on the buttons still win.
|
|
430
|
+
and the edge-most action keeps its label centred as it stretches. Only the
|
|
431
|
+
uncovered part of a strip shows, so it never shows through the row at rest.
|
|
150
432
|
|
|
151
433
|
Both are also available as standalone actions for your own markup.
|
|
152
434
|
They drive `--swipe-x` / `--refresh-pull` and `data-swipe-state` /
|
|
153
435
|
`data-refresh-phase`. Style off those. `swipeActions` also writes the
|
|
154
|
-
unsigned distance travelled to `--swipe-reveal
|
|
155
|
-
|
|
156
|
-
|
|
436
|
+
unsigned distance travelled to `--swipe-reveal`, the same distance for the
|
|
437
|
+
open edge to `--swipe-reveal-leading` or `--swipe-reveal-trailing` (the
|
|
438
|
+
other is `0px`), the open edge to `data-swipe-open-edge`, the direction it
|
|
439
|
+
read to `data-swipe-direction`, and sets `data-swipe-dragging` while a drag is
|
|
440
|
+
in progress. Pass `stateElement` to mirror all of these onto an ancestor that
|
|
441
|
+
your strip can read. Pass `leading` and `trailing` (each with
|
|
442
|
+
`actionsElement` or `actionsWidth`, `allowsFullSwipe` and `onFullSwipe`) for
|
|
443
|
+
both edges, and `direction` to override the computed CSS direction it reads at
|
|
444
|
+
the start of each gesture. In that form a full swipe springs back after
|
|
445
|
+
`onFullSwipe` unless it returns `true`.
|
|
446
|
+
|
|
447
|
+
## Navigation bar
|
|
448
|
+
|
|
449
|
+
As in iOS 26, `NavigationBar` has no background and no divider of its own:
|
|
450
|
+
the title and the glass buttons float over the content. Once content scrolls
|
|
451
|
+
under the bar, a scroll edge effect fades in behind it, a blur and a tint
|
|
452
|
+
(`--glass-nav-bg`) that fade out over 24px below the bar, so the title stays
|
|
453
|
+
readable over busy content without a hard edge.
|
|
454
|
+
|
|
455
|
+
The bar watches the window's scroll position. If your content scrolls in a
|
|
456
|
+
container of its own, pass `scrolled` while it is scrolled. With `largeTitle`,
|
|
457
|
+
the effect also shows once the large title collapses.
|
|
458
|
+
|
|
459
|
+
`transparent` is kept for compatibility. It used to hide the bar until
|
|
460
|
+
`scrolled` was set. The default now does that, so `transparent` changes
|
|
461
|
+
nothing but the `transparent` class.
|
|
462
|
+
|
|
463
|
+
The titles use `--glass-fg` when it is set, then `--color-text`, then
|
|
464
|
+
`--glass-text-color-default`, so they follow the adaptive glass text colour.
|
|
465
|
+
|
|
466
|
+
Under reduced transparency the effect becomes a solid bar with no blur and no
|
|
467
|
+
fade. With more contrast it is a 98% opaque bar (black or white) with no blur
|
|
468
|
+
and a `#8e8e93` divider. With forced colours it is `Canvas` with a
|
|
469
|
+
`CanvasText` divider.
|
|
157
470
|
|
|
158
471
|
## Sheet
|
|
159
472
|
|
|
@@ -164,7 +477,10 @@ to mirror all of these onto an ancestor that your strip can read.
|
|
|
164
477
|
```
|
|
165
478
|
|
|
166
479
|
A sheet with a `title` shows a header with the title centred and an icon-only
|
|
167
|
-
close button (`aria-label="Close"`) at the leading side, as on iOS 26
|
|
480
|
+
glass close button (`aria-label="Close"`) at the leading side, as on iOS 26
|
|
481
|
+
sheets. The header has no divider under it. The close button has the same
|
|
482
|
+
glass layers and fills as a `glass` `IconButton`, including the
|
|
483
|
+
`--glass-button-fill` tokens and the reduced transparency fill.
|
|
168
484
|
The sheet is a modal `dialog`, labelled by its title (or by an `aria-label`
|
|
169
485
|
when there is none).
|
|
170
486
|
|
|
@@ -173,6 +489,12 @@ when there is none).
|
|
|
173
489
|
under `dir="rtl"` leading is the right. The button moves in the DOM as well,
|
|
174
490
|
so Tab reaches it first in the header when it leads. The title stays centred
|
|
175
491
|
either way. The header carries `data-close-placement` with the value in use.
|
|
492
|
+
Either way the button sits 4px in from the header's padding, so the two
|
|
493
|
+
placements are mirror images.
|
|
494
|
+
- The title and the close button glyph use `--color-text` when the page sets
|
|
495
|
+
it. Unset, they fall back to
|
|
496
|
+
`--glass-text-color-default`: `#f5f5f7` in the dark theme and `#1d1d1f` in
|
|
497
|
+
the light one.
|
|
176
498
|
|
|
177
499
|
```svelte
|
|
178
500
|
<Sheet bind:isOpen title="Options" closePlacement="trailing">
|
|
@@ -180,6 +502,53 @@ when there is none).
|
|
|
180
502
|
</Sheet>
|
|
181
503
|
```
|
|
182
504
|
|
|
505
|
+
- `detents` takes the named sizes (`small`, `medium`, `large`,
|
|
506
|
+
`fullscreen`) and custom ones: `{ fraction: 0.3 }` is a share of the
|
|
507
|
+
viewport height and `{ height: 320 }` a height in CSS pixels, capped at the
|
|
508
|
+
viewport. The sheet sorts them smallest first and counts detents that come
|
|
509
|
+
to the same size once (the first one given), worked out again when the
|
|
510
|
+
viewport resizes. `initialDetent` matches a custom one by value, and
|
|
511
|
+
`onDetentChange` gets the detent you passed.
|
|
512
|
+
|
|
513
|
+
```svelte
|
|
514
|
+
<Sheet bind:isOpen detents={[{ height: 240 }, 'medium', 'large']} initialDetent={{ height: 240 }}>
|
|
515
|
+
{#snippet children()}...{/snippet}
|
|
516
|
+
</Sheet>
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
- With more than one detent, the grabber is a keyboard `slider` ("Sheet
|
|
520
|
+
size"): Up and Right grow the sheet a detent, Down and Left shrink it,
|
|
521
|
+
Page Up and Page Down do the same, and Home and End go to the smallest and
|
|
522
|
+
largest. It is the first Tab stop in the sheet. `labels` translates what it
|
|
523
|
+
reads out: `size` (its name, "Sheet size"), `small`, `medium`, `large`,
|
|
524
|
+
`fullscreen` and `pixels(n)` for a height detent. Any left out stay in
|
|
525
|
+
English.
|
|
526
|
+
- The sheet remembers the detent picked, not its place in the list, so a
|
|
527
|
+
resize that reorders height detents against the others keeps it on the
|
|
528
|
+
same detent. It opens at `initialDetent` (the smallest detent when that is
|
|
529
|
+
not offered) and goes back to it only when its value changes, so a new
|
|
530
|
+
object with the same value, such as an inline literal, does not reset it.
|
|
531
|
+
If `detents` stops offering the picked size, the sheet moves to the nearest
|
|
532
|
+
one and reports it through `onDetentChange`.
|
|
533
|
+
- `modal={false}` shows a non-modal sheet: no dimmed backdrop, and the page
|
|
534
|
+
behind stays usable. It is a `dialog` without `aria-modal`; Tab is not
|
|
535
|
+
trapped, the page is not made inert or scroll locked, Escape closes it only
|
|
536
|
+
while focus is inside it, and focus returns to the opener on close only if
|
|
537
|
+
it was still in the sheet.
|
|
538
|
+
- `inset` (default `true`) floats the sheet in from the sides and bottom of
|
|
539
|
+
the screen with rounded lower corners below full height, as on iOS 26. At
|
|
540
|
+
`large` or taller it meets the edges and turns more opaque. Pass
|
|
541
|
+
`inset={false}` for an edge to edge sheet, the default before this
|
|
542
|
+
release. Tune it with `--glass-sheet-inset` (8px),
|
|
543
|
+
`--glass-sheet-inset-radius` (`--glass-radius-xl`) and
|
|
544
|
+
`--glass-sheet-full-height-alpha` (0.94).
|
|
545
|
+
|
|
546
|
+
```svelte
|
|
547
|
+
<Sheet bind:isOpen title="Directions" modal={false}>
|
|
548
|
+
{#snippet children()}...{/snippet}
|
|
549
|
+
</Sheet>
|
|
550
|
+
```
|
|
551
|
+
|
|
183
552
|
- Dragging the handle or the header moves the sheet between its detents.
|
|
184
553
|
Presses on the close button or on interactive content never start a drag.
|
|
185
554
|
- The body drags too. A press in the content starts a drag once it pulls down
|
|
@@ -205,6 +574,465 @@ when there is none).
|
|
|
205
574
|
`prefers-reduced-motion` or `data-reduced-motion="true"` the sheet
|
|
206
575
|
unmounts immediately.
|
|
207
576
|
|
|
577
|
+
## Tab bar
|
|
578
|
+
|
|
579
|
+
`TabView` mirrors the iOS 26 tab bar. With none of the options below it is
|
|
580
|
+
the single floating glass capsule it has always been.
|
|
581
|
+
|
|
582
|
+
```svelte
|
|
583
|
+
<TabView
|
|
584
|
+
tabs={[
|
|
585
|
+
{ id: 'home', label: 'Home', icon: homeIcon },
|
|
586
|
+
{ id: 'inbox', label: 'Inbox', icon: inboxIcon, badge: 3 },
|
|
587
|
+
{ id: 'updates', label: 'Updates', icon: bellIcon, badge: true, badgeLabel: 'New updates' },
|
|
588
|
+
{ id: 'search', label: 'Search', role: 'search' }
|
|
589
|
+
]}
|
|
590
|
+
bind:activeTab
|
|
591
|
+
label="Sections"
|
|
592
|
+
minimizeBehavior="onScrollDown"
|
|
593
|
+
>
|
|
594
|
+
{#snippet bottomAccessory({ placement })}
|
|
595
|
+
<NowPlaying compact={placement === 'inline'} />
|
|
596
|
+
{/snippet}
|
|
597
|
+
{#snippet children(id)}...{/snippet}
|
|
598
|
+
</TabView>
|
|
599
|
+
```
|
|
600
|
+
|
|
601
|
+
- `badge` on a tab: a count (below 1 shows nothing, above 99 reads `99+`), a
|
|
602
|
+
short text, or `true` for a dot. The badge is the notification red with
|
|
603
|
+
white text (4.7:1 on the default `--color-danger`; set
|
|
604
|
+
`--glass-badge-notification-bg` and `--glass-badge-notification-text` to
|
|
605
|
+
change it). It is added to the tab's accessible name, as "Inbox, 3".
|
|
606
|
+
`badgeLabel` sets the words read instead, and a dot reads "New" without one.
|
|
607
|
+
- `role: 'search'` sets the tab apart at the trailing end of the bar in its own
|
|
608
|
+
glass circle, showing its icon alone (a magnifying glass when it has none).
|
|
609
|
+
It stays in the same tab list, last in the arrow key order.
|
|
610
|
+
- `bottomAccessory` renders in its own glass capsule above the bar. It gets
|
|
611
|
+
`placement`: `'expanded'` above the bar, `'inline'` when the bar is
|
|
612
|
+
minimised and the accessory sits between the collapsed tab and the search
|
|
613
|
+
tab. It is outside the tab list, so its controls keep their own Tab stops.
|
|
614
|
+
- `minimizeBehavior`: `'never'` (default), `'onScrollDown'` or `'onScrollUp'`.
|
|
615
|
+
The bar follows every scroll on the page: the window, the tab content and
|
|
616
|
+
any scroll container of your own, each on its own run. Text areas and
|
|
617
|
+
anything inside a dialog or popover over the page (a `Sheet`, `Alert` or
|
|
618
|
+
`Popover`, or any `dialog`, `role="dialog"`, `role="alertdialog"` or
|
|
619
|
+
`aria-modal="true"` element) are ignored, as on iOS. A container that leaves
|
|
620
|
+
the page is forgotten. A run of 24px one way
|
|
621
|
+
changes it, so small jitter does not, and it is always expanded within 8px of
|
|
622
|
+
the top. Minimised, it shows only the selected tab's icon (the first tab's
|
|
623
|
+
when the search tab is selected). The labels leave the layout, so the bar
|
|
624
|
+
shrinks to its icons (44px tabs, the height of the inline accessory) with
|
|
625
|
+
each icon centred, and the height change plays with the minimise
|
|
626
|
+
transition (not under reduced motion). Clicking that tab or moving focus into the
|
|
627
|
+
bar expands it, and so do the arrow keys, which move to the next tab as
|
|
628
|
+
usual. The other tabs are hidden from sight only, so screen readers still
|
|
629
|
+
list them. The root carries `data-minimized="true"` or `"false"`.
|
|
630
|
+
|
|
631
|
+
Any of these options lays the bar out as a dock: one fixed (or, with `inline`,
|
|
632
|
+
static) wrapper, `.tab-dock`, holding the glass groups. The main capsule keeps
|
|
633
|
+
its `.tab-bar-container` class but is placed by the dock, so page CSS that
|
|
634
|
+
moves `.tab-bar-container` no longer applies. Position `.tab-dock` instead.
|
|
635
|
+
|
|
636
|
+
Without them the bar is fixed to the bottom of the viewport (the top with
|
|
637
|
+
`position="top"`), clear of the safe area. The tab content is padded by the
|
|
638
|
+
bar's height, so its end scrolls clear of the bar. The dock does not pad the
|
|
639
|
+
content yet, so give the end of your content room for it. A fixed element is
|
|
640
|
+
placed against its nearest ancestor with a `transform`, `filter` or `contain`,
|
|
641
|
+
not against the viewport, so keep those off the elements around a `TabView`.
|
|
642
|
+
|
|
643
|
+
`Badge` takes the same forms on its own:
|
|
644
|
+
|
|
645
|
+
```svelte
|
|
646
|
+
<Badge count={5} variant="notification" label="5 unread messages" />
|
|
647
|
+
<Badge count={120} max={99} variant="notification" /> <!-- 99+ -->
|
|
648
|
+
<Badge dot variant="notification" label="New" />
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
With `count` or `dot`, `label` is the text read aloud rather than shown.
|
|
652
|
+
|
|
653
|
+
## Segmented control
|
|
654
|
+
|
|
655
|
+
```svelte
|
|
656
|
+
<script lang="ts">
|
|
657
|
+
import { SegmentedControl } from 'glasslikeui';
|
|
658
|
+
let range = $state('week');
|
|
659
|
+
</script>
|
|
660
|
+
|
|
661
|
+
<SegmentedControl
|
|
662
|
+
label="Range"
|
|
663
|
+
bind:value={range}
|
|
664
|
+
segments={[
|
|
665
|
+
{ value: 'day', label: 'Day' },
|
|
666
|
+
{ value: 'week', label: 'Week' },
|
|
667
|
+
{ value: 'month', label: 'Month', disabled: true }
|
|
668
|
+
]}
|
|
669
|
+
/>
|
|
670
|
+
```
|
|
671
|
+
|
|
672
|
+
A row of mutually exclusive choices on a glass track, with a raised thumb that
|
|
673
|
+
slides to the chosen segment, like the iOS 26 segmented picker. Use it to pick
|
|
674
|
+
one value. To switch between views with their own content, use `TabView`.
|
|
675
|
+
|
|
676
|
+
- `segments` is a list of `{ value, label, icon?, hidesLabel?, disabled? }`.
|
|
677
|
+
`hidesLabel` keeps the label as the accessible name of an icon-only segment.
|
|
678
|
+
The `Segment` type is exported.
|
|
679
|
+
- `value` is bindable. `onchange` fires with the new value when the user picks a
|
|
680
|
+
different segment, never on render or on a click of the chosen one. A value
|
|
681
|
+
that matches no segment checks nothing and hides the thumb.
|
|
682
|
+
- `label` names the group for assistive technology. `disabled` disables every
|
|
683
|
+
segment.
|
|
684
|
+
- It is a WAI-ARIA radio group: a `radiogroup` of `radio` buttons with
|
|
685
|
+
`aria-checked`. It picks a value and controls no panel, so it is not a
|
|
686
|
+
`tablist`. Tab reaches the chosen segment only. The arrow keys move to the
|
|
687
|
+
next or previous segment and choose it, wrapping at the ends and skipping
|
|
688
|
+
disabled segments. Left and Right swap under `dir="rtl"`. Space and Enter
|
|
689
|
+
choose the focused segment.
|
|
690
|
+
- The thumb slides with `--transition-spring`, so reduced motion makes it jump.
|
|
691
|
+
Under reduced transparency the track drops its blur and turns solid.
|
|
692
|
+
- Holding the chosen segment turns the thumb into Liquid Glass, as on iOS 26
|
|
693
|
+
and like the `Slider` knob: it grows a little and gains the lens blur and
|
|
694
|
+
rim. Dragging it moves the thumb across the segments, skipping disabled
|
|
695
|
+
ones, and the selection moves on release, so `onchange` fires once. A
|
|
696
|
+
cancelled drag puts the thumb back. The thumb keeps 90% of its colour so the
|
|
697
|
+
label holds 4.5:1. It does not grow under reduced motion and stays solid
|
|
698
|
+
under reduced transparency. The control sets `touch-action: pan-y`, so a
|
|
699
|
+
sideways drag moves the thumb instead of the page. The drag captures its
|
|
700
|
+
pointer, so a release outside the window still ends it, and only the
|
|
701
|
+
pointer that started it moves the thumb.
|
|
702
|
+
- Restyle with `--glass-segmented-track` and `--glass-segmented-thumb`. The
|
|
703
|
+
defaults are `#636366` (dark) and `#ffffff` (light) for the thumb, where the
|
|
704
|
+
default labels hold at least 4.5:1.
|
|
705
|
+
|
|
706
|
+
## Slider
|
|
707
|
+
|
|
708
|
+
```svelte
|
|
709
|
+
<script lang="ts">
|
|
710
|
+
import { Slider } from 'glasslikeui';
|
|
711
|
+
let volume = $state(40);
|
|
712
|
+
</script>
|
|
713
|
+
|
|
714
|
+
<Slider label="Volume" bind:value={volume} min={0} max={100} step={5}
|
|
715
|
+
valueText={(v) => `${v} percent`} />
|
|
716
|
+
```
|
|
717
|
+
|
|
718
|
+
A track with an accent fill and a white capsule knob, like the iOS 26 slider.
|
|
719
|
+
While it is pressed or dragged, the knob grows into a clear glass lens.
|
|
720
|
+
|
|
721
|
+
- `value` is bindable. `min`, `max` and `step` default to 0, 100 and 1.
|
|
722
|
+
Unset, the value starts at the midpoint. Bad bounds follow the native
|
|
723
|
+
rules: a max below min becomes min, and a step that is not a positive
|
|
724
|
+
number becomes 1. A value outside the bounds or off a step is shown where
|
|
725
|
+
the slider settles; the binding changes only when the user moves it.
|
|
726
|
+
- `oninput` fires with each new value during a drag. `onchange` fires once
|
|
727
|
+
the user lets go, or after a key press. Neither fires on render.
|
|
728
|
+
- `label` is the accessible name. `valueText` turns the value into the text
|
|
729
|
+
assistive technology reads (`aria-valuetext`).
|
|
730
|
+
- A native `<input type="range">` sits invisibly over the drawn track and
|
|
731
|
+
takes the pointer, the keys and the semantics: role `slider` with its
|
|
732
|
+
`aria-value*`, arrow keys, Page Up and Page Down, and Home and End. Its thumb is sized to the drawn knob, so the value under the
|
|
733
|
+
pointer is the value under the knob. The track runs right to left under
|
|
734
|
+
`dir="rtl"`.
|
|
735
|
+
- The shared focus ring is drawn on the knob. Under reduced motion the knob
|
|
736
|
+
grows without animating. Under reduced transparency it grows but stays
|
|
737
|
+
solid.
|
|
738
|
+
- Under forced colours (Windows High Contrast) the track is outlined in
|
|
739
|
+
`CanvasText`, the fill is `Highlight` and the knob is `ButtonText` with a
|
|
740
|
+
border. A disabled slider turns `GrayText`.
|
|
741
|
+
- Restyle with `--glass-slider-track`, `--glass-slider-fill` (default
|
|
742
|
+
`--color-accent`) and `--glass-slider-knob` (default `#ffffff`).
|
|
743
|
+
|
|
744
|
+
## Toggle
|
|
745
|
+
|
|
746
|
+
```svelte
|
|
747
|
+
<Toggle label="Wi-Fi" bind:checked={wifi} />
|
|
748
|
+
```
|
|
749
|
+
|
|
750
|
+
A switch over a native checkbox with `role="switch"`, drawn as the iOS 26
|
|
751
|
+
switch: a 63 by 28 track, a 37 by 24 capsule knob 2px in from the edge, the
|
|
752
|
+
accent fill when on, and a knob that slides across with the spring
|
|
753
|
+
(`--transition-spring`).
|
|
754
|
+
|
|
755
|
+
- `appearance` picks the switch. `'glass'` (the default) is the iOS 26 switch
|
|
756
|
+
above. `'classic'` is the switch from before iOS 26: a 51 by 31 track with a
|
|
757
|
+
round 27px knob and a solid knob. It keeps the old size, colours, shape,
|
|
758
|
+
shadow and quick slide (`--transition-fast`), but it is not pixel for pixel
|
|
759
|
+
the old switch. The knob is placed with `inset-inline-start`, so Firefox can
|
|
760
|
+
round it a subpixel differently. It also mirrors under `dir="rtl"` and takes
|
|
761
|
+
the more contrast track. The label carries `data-appearance="glass"` or
|
|
762
|
+
`"classic"`.
|
|
763
|
+
- `knob` picks what the knob does when pressed. `'glass'` (the default, and
|
|
764
|
+
`'solid'` with `appearance="classic"`) mirrors iOS 26. While pressed, the
|
|
765
|
+
knob widens into a clear glass lens, centred on the knob. On the glass
|
|
766
|
+
switch the lens is 58 by 38, the size UIKit draws, so it spills about 5px
|
|
767
|
+
past each edge of the track. On the classic switch it is 1.4 by 1.2 times
|
|
768
|
+
the knob. It can be
|
|
769
|
+
dragged along the track and is let go on the side it was dragged to: past
|
|
770
|
+
the middle turns the switch over, short of it leaves it as it was. A drag
|
|
771
|
+
fires `onchange` once, and only when the value changed. A move of 4px or
|
|
772
|
+
less is a tap, which flips the switch. Only the primary pointer presses the
|
|
773
|
+
knob, and only that pointer moves it and lets it go: a second finger is
|
|
774
|
+
ignored. The switch sets `touch-action: pan-y`, so a sideways touch drag is
|
|
775
|
+
not taken for a pan. `'solid'` keeps a white knob with no press or drag.
|
|
776
|
+
- Under `dir="rtl"` the switch mirrors: the knob starts at the right and
|
|
777
|
+
slides, or is dragged, left to turn on.
|
|
778
|
+
- Keyboard use is the native checkbox: Tab to it and press Space. It shows
|
|
779
|
+
the shared focus ring around the track.
|
|
780
|
+
- The off track is the iOS tertiary label grey, `rgba(235, 235, 245, 0.3)` in
|
|
781
|
+
the dark theme and `rgba(60, 60, 67, 0.3)` in the light one. Set
|
|
782
|
+
`--glass-track` and `--glass-track-checked` to change the off and on fills.
|
|
783
|
+
The on fill is the accent, which keeps the white knob at 3:1 or more. The
|
|
784
|
+
iOS system green (`#34c759`) holds only about 2.2:1 against it.
|
|
785
|
+
- The light off track copies iOS. It is about 1.7:1 against a white page, under
|
|
786
|
+
the 3:1 for a control's parts, so the state is carried by where the knob
|
|
787
|
+
sits rather than by the track. Ask for more contrast to get a track that
|
|
788
|
+
holds 3:1.
|
|
789
|
+
- Under more contrast (`prefers-contrast: more` or `data-contrast="more"`) the
|
|
790
|
+
off track darkens to hold 3:1 against the page and the knob in both themes.
|
|
791
|
+
A `--glass-track` set by the page replaces that darker track too, so the
|
|
792
|
+
page then owns the 3:1.
|
|
793
|
+
Under reduced motion the knob moves and changes shape without animating.
|
|
794
|
+
Under reduced transparency the pressed knob widens but stays solid white.
|
|
795
|
+
Under forced colours the track, knob and focus ring use system colours.
|
|
796
|
+
- The label is coloured `var(--glass-fg, var(--color-text))`, so on glass it
|
|
797
|
+
follows the glass tone and elsewhere keeps the page text colour.
|
|
798
|
+
|
|
799
|
+
## Toolbar
|
|
800
|
+
|
|
801
|
+
```svelte
|
|
802
|
+
<script lang="ts">
|
|
803
|
+
import { Toolbar, ToolbarItemGroup, ToolbarSpacer, IconButton, SymbolImage } from 'glasslikeui';
|
|
804
|
+
</script>
|
|
805
|
+
|
|
806
|
+
<Toolbar label="Editing">
|
|
807
|
+
<ToolbarItemGroup label="Markup">
|
|
808
|
+
<IconButton label="Draw"><SymbolImage name="pencil" /></IconButton>
|
|
809
|
+
<IconButton label="Tag"><SymbolImage name="tag" /></IconButton>
|
|
810
|
+
</ToolbarItemGroup>
|
|
811
|
+
<ToolbarSpacer sizing="fixed" />
|
|
812
|
+
<ToolbarItemGroup>
|
|
813
|
+
<IconButton label="Share"><SymbolImage name="square.and.arrow.up" /></IconButton>
|
|
814
|
+
</ToolbarItemGroup>
|
|
815
|
+
<ToolbarSpacer />
|
|
816
|
+
<ToolbarItemGroup>
|
|
817
|
+
<IconButton label="Delete"><SymbolImage name="trash" /></IconButton>
|
|
818
|
+
</ToolbarItemGroup>
|
|
819
|
+
</Toolbar>
|
|
820
|
+
```
|
|
821
|
+
|
|
822
|
+
A row of controls grouped on glass, like an iOS 26 toolbar. The toolbar has
|
|
823
|
+
no fill of its own. Each `ToolbarItemGroup` is one glass capsule shared by
|
|
824
|
+
its controls, and `ToolbarSpacer` splits the groups apart.
|
|
825
|
+
|
|
826
|
+
- `Toolbar` takes `label`, its accessible name, and `orientation`
|
|
827
|
+
(`'horizontal'`, the default, or `'vertical'`). Place it yourself, for
|
|
828
|
+
example fixed to the bottom of the screen.
|
|
829
|
+
- `ToolbarItemGroup` takes an optional `label`. With one, it is announced as
|
|
830
|
+
a `group`. `variant` picks `regular` (default) or `clear` glass.
|
|
831
|
+
- `ToolbarSpacer` takes `sizing`: `'flexible'` (the default, as in SwiftUI)
|
|
832
|
+
takes all the free room and pushes what follows to the far end. `'fixed'`
|
|
833
|
+
is a set gap between two groups, `--toolbar-spacer-fixed` (default
|
|
834
|
+
`--spacing-xs`). Spacers are hidden from assistive technology.
|
|
835
|
+
- It is a WAI-ARIA `toolbar`: one tab stop, on the last control used (the
|
|
836
|
+
first at the start). Left and Right move between the controls across every
|
|
837
|
+
group, swapped under `dir="rtl"`, Up and Down in a vertical toolbar. Focus
|
|
838
|
+
wraps at the ends. Home and End jump to them. Disabled controls (on their
|
|
839
|
+
own or in a disabled `fieldset`) and hidden ones (`hidden`, `inert`,
|
|
840
|
+
`display: none`, `visibility: hidden`) are skipped. `aria-disabled` ones stay
|
|
841
|
+
reachable. A text field, slider or select keeps the arrow keys and a tab stop
|
|
842
|
+
of its own, so Tab always moves on to the rest of the toolbar. Controls added
|
|
843
|
+
later join the roving order. If the focused control is removed or disabled,
|
|
844
|
+
focus moves to a new control put in its place (a Play button swapped for
|
|
845
|
+
Pause), else the nearest remaining one. The controls whose tab index the
|
|
846
|
+
toolbar sets carry `data-toolbar-roving`. A control that stops being one
|
|
847
|
+
(disabled, hidden, or a link that lost its `href`) gives that tab index up.
|
|
848
|
+
Right to left is read from the computed `direction`, so `dir`, `dir="auto"`
|
|
849
|
+
and CSS `direction` all count.
|
|
850
|
+
- The toolbar watches changes to its controls and to the elements that hold
|
|
851
|
+
them. It does not see a change elsewhere that hides a control through CSS,
|
|
852
|
+
such as a class on a sibling that matches `.x ~ .group button`. Hide
|
|
853
|
+
controls with `hidden`, or a class or style on the control or on an element
|
|
854
|
+
that holds it.
|
|
855
|
+
- Spacing tokens: `--toolbar-gap` between items, `--toolbar-group-gap` and
|
|
856
|
+
`--toolbar-group-padding` inside a capsule.
|
|
857
|
+
- The toolbar does not wrap, scroll or collapse items into a menu. A flexible
|
|
858
|
+
spacer shrinks first. Past that, the last items run past the toolbar's end.
|
|
859
|
+
Six icon buttons in three groups fit a 390px wide phone with 24px margins,
|
|
860
|
+
with about 50px to spare. Keep a phone toolbar to what fits, or place it in
|
|
861
|
+
a `ScrollView`. A scrolling container clips focus rings and glass shadows,
|
|
862
|
+
so give it padding on every side if you do.
|
|
863
|
+
|
|
864
|
+
## Popover
|
|
865
|
+
|
|
866
|
+
```svelte
|
|
867
|
+
<Popover title="Share">
|
|
868
|
+
{#snippet label()}Share{/snippet}
|
|
869
|
+
<p>Anyone with the link can view.</p>
|
|
870
|
+
</Popover>
|
|
871
|
+
```
|
|
872
|
+
|
|
873
|
+
`Popover` renders a trigger from `label` and shows its content in a glass
|
|
874
|
+
panel anchored to it. To anchor to a control of your own, leave out `label`
|
|
875
|
+
and pass the element as `anchor`, then open it with `bind:isOpen`.
|
|
876
|
+
|
|
877
|
+
- On a regular width the panel sits 8px below its source (above when there is
|
|
878
|
+
no room), lined up by `align` (`'start' | 'center' | 'end'`, default
|
|
879
|
+
`'center'`, logical so swapped under `dir="rtl"`), and kept 8px inside the
|
|
880
|
+
viewport. It grows out of the source, as popovers do on iOS 26. It follows
|
|
881
|
+
the source as the page scrolls or resizes.
|
|
882
|
+
- It is a non-modal `dialog` named by `title`, else by the trigger. Focus moves
|
|
883
|
+
to its first focusable element (or the panel). Escape, with focus in the
|
|
884
|
+
panel or on the source, closes it and returns focus to the source. Escape
|
|
885
|
+
elsewhere on the page is left alone, and so is an Escape that something
|
|
886
|
+
inside handled first, such as a `Menu` or a nested `Popover`. A press outside
|
|
887
|
+
closes it.
|
|
888
|
+
- Under 600px wide it becomes a modal sheet inset from the screen edges, as on
|
|
889
|
+
iPhone: the page behind is inert, Tab stays inside, and a tap on the dimmed
|
|
890
|
+
backdrop or Escape closes it. Set `compactAdaptation="popover"` to keep the
|
|
891
|
+
anchored popover instead.
|
|
892
|
+
- Where the browser supports the `popover` attribute the panel goes in the top
|
|
893
|
+
layer, so no ancestor's `overflow` or stacking clips it.
|
|
894
|
+
- `onClose` fires once each time it closes. Under reduced motion it fades in
|
|
895
|
+
with no grow or slide.
|
|
896
|
+
|
|
897
|
+
## Menu
|
|
898
|
+
|
|
899
|
+
```svelte
|
|
900
|
+
<Menu morph>
|
|
901
|
+
{#snippet label()}Options{/snippet}
|
|
902
|
+
{#snippet children()}
|
|
903
|
+
<MenuSection title="Edit" size="medium">
|
|
904
|
+
<MenuItem icon="doc.on.doc" onclick={copy}>Copy</MenuItem>
|
|
905
|
+
<MenuItem icon="trash" destructive disabled>Delete</MenuItem>
|
|
906
|
+
</MenuSection>
|
|
907
|
+
<MenuSection>
|
|
908
|
+
<MenuItem checked={grid} onclick={() => (grid = !grid)}>Show grid</MenuItem>
|
|
909
|
+
<MenuSubmenu label="Sort by">
|
|
910
|
+
<MenuItem checked={sort === 'name'} onclick={() => (sort = 'name')}>Name</MenuItem>
|
|
911
|
+
<MenuItem checked={sort === 'date'} onclick={() => (sort = 'date')}>Date</MenuItem>
|
|
912
|
+
</MenuSubmenu>
|
|
913
|
+
</MenuSection>
|
|
914
|
+
{/snippet}
|
|
915
|
+
</Menu>
|
|
916
|
+
```
|
|
917
|
+
|
|
918
|
+
- The panel follows the iOS 26 menu: 44px rows inset 8px and rounded
|
|
919
|
+
concentric with its `--glass-radius-xl` corners, no lines between the items
|
|
920
|
+
of a group, and a thin inset line between groups.
|
|
921
|
+
- `MenuSection` groups items (`role="group"`, named by `title`) and is set off
|
|
922
|
+
from its neighbours by that thin line. `size` mirrors UIMenu's element sizes:
|
|
923
|
+
`'large'` (the default list), `'medium'` (a row, icon over title) or
|
|
924
|
+
`'small'` (a row of icons, the title kept as the accessible name).
|
|
925
|
+
- `MenuItem` takes `checked` to become a `menuitemcheckbox` with a checkmark,
|
|
926
|
+
and `disabled` to dim it. A disabled item stays focusable, as the menu
|
|
927
|
+
pattern asks, but does nothing and does not close the menu. A disabled link
|
|
928
|
+
item drops its `href`.
|
|
929
|
+
- `MenuSubmenu` opens its items in place under it, as on iOS. Click, Enter,
|
|
930
|
+
Space or ArrowRight opens it and focuses its first item; ArrowLeft or Escape
|
|
931
|
+
closes only the submenu and returns focus to its item. The arrows swap
|
|
932
|
+
under `dir="rtl"`. Up and Down move within the menu that has focus.
|
|
933
|
+
- `morph` grows the panel out of the trigger instead of the default scale and
|
|
934
|
+
fade. Under reduced motion it only fades.
|
|
935
|
+
|
|
936
|
+
## Alert and ActionSheet
|
|
937
|
+
|
|
938
|
+
Both take a list of `AlertAction`s, mirroring SwiftUI's `.alert` and
|
|
939
|
+
`.confirmationDialog` with button roles:
|
|
940
|
+
|
|
941
|
+
```ts
|
|
942
|
+
interface AlertAction {
|
|
943
|
+
label: string;
|
|
944
|
+
role?: 'cancel' | 'destructive';
|
|
945
|
+
preferred?: boolean; // drawn filled; Return in the text field runs it
|
|
946
|
+
disabled?: boolean;
|
|
947
|
+
onclick?: () => void;
|
|
948
|
+
}
|
|
949
|
+
```
|
|
950
|
+
|
|
951
|
+
```svelte
|
|
952
|
+
<Alert
|
|
953
|
+
bind:isOpen
|
|
954
|
+
title="Delete photo?"
|
|
955
|
+
message="This photo will be deleted from all your devices."
|
|
956
|
+
actions={[
|
|
957
|
+
{ label: 'Cancel', role: 'cancel' },
|
|
958
|
+
{ label: 'Delete', role: 'destructive', onclick: remove }
|
|
959
|
+
]}
|
|
960
|
+
/>
|
|
961
|
+
```
|
|
962
|
+
|
|
963
|
+
- `Alert` is a modal `alertdialog`, named by its title and described by its
|
|
964
|
+
message. The page behind is inert, Tab stays inside, and focus returns to
|
|
965
|
+
the element that had it when the alert closes.
|
|
966
|
+
- As in iOS 26, the alert's bold title and its message lead from the inline
|
|
967
|
+
start (the left in LTR, the right in RTL), and the text field is a capsule
|
|
968
|
+
like the buttons. The button labels stay centred.
|
|
969
|
+
- One or two short buttons sit in a row, the cancel button leading. Three or
|
|
970
|
+
more, or a label longer than 14 characters, stack, with the cancel button
|
|
971
|
+
last. With no actions the alert shows a single OK button.
|
|
972
|
+
- Focus starts on the text field if there is one, else on the cancel button,
|
|
973
|
+
else on the first button that is not destructive (the least destructive
|
|
974
|
+
choice, as the WAI-ARIA alertdialog pattern asks).
|
|
975
|
+
- Escape runs the cancel action. An alert with one button and no cancel, such
|
|
976
|
+
as an OK alert, runs that button. An alert with two or more actions and no
|
|
977
|
+
cancel ignores Escape by design: the WAI-ARIA alertdialog pattern lets an
|
|
978
|
+
alert that needs a decision stay open, and iOS does the same. Give it a
|
|
979
|
+
`cancel` action if Escape should dismiss it. A click outside never closes an
|
|
980
|
+
alert: the choice has to be made.
|
|
981
|
+
- `textField` (`{ label, placeholder?, type? }`) adds a field above the
|
|
982
|
+
buttons, its text bound through `bind:value`. Return in the field runs the
|
|
983
|
+
`preferred` action.
|
|
984
|
+
- Choosing an action sets `isOpen` to `false`, runs its `onclick`, then calls
|
|
985
|
+
`onClose`. A disabled action does nothing.
|
|
986
|
+
|
|
987
|
+
```svelte
|
|
988
|
+
<button bind:this={source} onclick={() => (isOpen = true)}>Discard</button>
|
|
989
|
+
<ActionSheet
|
|
990
|
+
bind:isOpen
|
|
991
|
+
anchor={source}
|
|
992
|
+
title="Discard this draft?"
|
|
993
|
+
actions={[
|
|
994
|
+
{ label: 'Discard Draft', role: 'destructive', onclick: discard },
|
|
995
|
+
{ label: 'Save Draft', onclick: save },
|
|
996
|
+
{ label: 'Cancel', role: 'cancel' }
|
|
997
|
+
]}
|
|
998
|
+
/>
|
|
999
|
+
```
|
|
1000
|
+
|
|
1001
|
+
- `ActionSheet` is a modal `alertdialog`, named by its `title`, or by `label`
|
|
1002
|
+
(`'Actions'` by default) when there is none.
|
|
1003
|
+
- With an `anchor` on a regular width (600px and up) it grows out of that
|
|
1004
|
+
control, as iOS 26 does, and does not draw its Cancel button: a click
|
|
1005
|
+
outside or Escape cancels instead. The button is still there for screen
|
|
1006
|
+
readers (touch VoiceOver has no Escape key) and the keyboard, hidden from
|
|
1007
|
+
sight until it has focus. Focus starts on the least destructive visible
|
|
1008
|
+
action. When every visible action is destructive (a "Delete Photo, Cancel"
|
|
1009
|
+
sheet), focus starts on the sheet itself, so one Return never deletes and
|
|
1010
|
+
the sheet opens without Cancel, as on iOS. Tab still reaches Cancel.
|
|
1011
|
+
Cancel shows beside the sheet, on the side away from the anchor, without
|
|
1012
|
+
pushing the sheet's rows. The side the sheet takes is chosen when it opens,
|
|
1013
|
+
with room for Cancel on the far side where the window allows, and kept
|
|
1014
|
+
until it closes, so nothing moves under the pointer. Without an
|
|
1015
|
+
anchor, or on a compact width, it is centred on the page, as iOS 26 centres
|
|
1016
|
+
an action sheet with no source, with the cancel action as its last button.
|
|
1017
|
+
- Both forms are one glass panel with the title and message leading and each
|
|
1018
|
+
action a full width capsule, as on iOS 26. The keyboard focus ring follows
|
|
1019
|
+
the capsule.
|
|
1020
|
+
- Escape and a click outside run the cancel action. With no cancel action they
|
|
1021
|
+
just close the sheet. While the cancel action is disabled they do nothing.
|
|
1022
|
+
- Under `prefers-reduced-motion` or `data-reduced-motion="true"` the alert and
|
|
1023
|
+
the action sheet fade in, with no scale, slide or grow. Under reduced
|
|
1024
|
+
transparency their panels turn opaque, like the sheet.
|
|
1025
|
+
- Text uses `--color-text` when the page sets it, else
|
|
1026
|
+
`--glass-text-color-default`. Destructive labels use the danger text colour.
|
|
1027
|
+
`--glass-alert-radius` (34px) and `--glass-action-sheet-radius` (40px) set
|
|
1028
|
+
the corners. Menu and action sheet text reads `--glass-fg` first, so it
|
|
1029
|
+
follows the backdrop's tone when that is set.
|
|
1030
|
+
- A list with two cancel actions or an empty label logs a console warning.
|
|
1031
|
+
- Where the browser supports the `popover` attribute, the alert and the
|
|
1032
|
+
action sheet are shown in the top layer, so one opened from a `Popover` is
|
|
1033
|
+
drawn above it and is not clipped by it. Elsewhere they sit at `z-index`
|
|
1034
|
+
1100.
|
|
1035
|
+
|
|
208
1036
|
## Actions
|
|
209
1037
|
|
|
210
1038
|
| Export | Purpose |
|
|
@@ -214,6 +1042,7 @@ when there is none).
|
|
|
214
1042
|
| `startSheetExit` | Slide a sheet down and out, then report completion. |
|
|
215
1043
|
| `swipeActions` | Swipe a row aside to reveal actions. |
|
|
216
1044
|
| `refreshable` | Pull-to-refresh gesture. |
|
|
1045
|
+
| `adaptiveTone` | Flips text on glass between dark and light to suit the backdrop. Used by `Glass`. `refreshAdaptiveTone()` re-checks every surface. |
|
|
217
1046
|
| `deviceMotion` | Ties the glass highlight angle to device tilt. |
|
|
218
1047
|
| `withGlassTransition` | Wraps a DOM update in a view transition. |
|
|
219
1048
|
| `syncAccessibilityPreferences` | Bridges `prefers-*` media to data-attrs at `:root`. |
|
|
@@ -282,6 +1111,7 @@ Native preference handling with zero config:
|
|
|
282
1111
|
- `prefers-reduced-transparency` -- surfaces go opaque, blur off
|
|
283
1112
|
- `prefers-contrast: more` -- thicker borders, higher opacity
|
|
284
1113
|
- `prefers-reduced-motion` -- transitions and motion highlights off
|
|
1114
|
+
- `forced-colors: active` -- the adaptive tone on glass is off, so system colours win
|
|
285
1115
|
|
|
286
1116
|
Cross-browser fallback attributes (flip at `:root`):
|
|
287
1117
|
|
|
@@ -291,7 +1121,7 @@ Cross-browser fallback attributes (flip at `:root`):
|
|
|
291
1121
|
|
|
292
1122
|
Call `syncAccessibilityPreferences()` to manage these automatically.
|
|
293
1123
|
|
|
294
|
-
`Sheet` is a modal dialog
|
|
1124
|
+
`Sheet` is a modal dialog unless you pass `modal={false}`. While it is open or sliding out, the siblings of the
|
|
295
1125
|
sheet and of each ancestor up to `body` get the `inert` attribute, and are
|
|
296
1126
|
restored exactly when it closes. Ancestors are never made inert, and anything
|
|
297
1127
|
you had already made inert stays inert. Tab and Shift+Tab wrap inside the
|
|
@@ -301,7 +1131,7 @@ Under reduced transparency (the media query, or
|
|
|
301
1131
|
`data-reduced-transparency="true"` on `:root` or on any element around the
|
|
302
1132
|
parts, in both themes):
|
|
303
1133
|
|
|
304
|
-
- `Glass`, and everything built on it, loses its blur
|
|
1134
|
+
- `Glass`, and everything built on it, loses its blur and blended
|
|
305
1135
|
highlight. `--glass-opacity` becomes 1, so the default background is solid
|
|
306
1136
|
`--glass-surface-color`, and a `tint` is painted over a solid base of that
|
|
307
1137
|
colour. A background of your own that works normally works here too, and so
|
|
@@ -316,7 +1146,7 @@ parts, in both themes):
|
|
|
316
1146
|
- `Sheet` turns its blur off, including the backdrop blur
|
|
317
1147
|
(`--glass-backdrop-blur`), and its background becomes near opaque
|
|
318
1148
|
(`--glass-sheet-bg` at 0.98 alpha). `Menu` goes opaque with it.
|
|
319
|
-
- `NavigationBar` becomes near opaque
|
|
1149
|
+
- The `NavigationBar` scroll edge effect becomes a solid bar, near opaque (`--glass-nav-bg` at 0.98 alpha), with no blur or fade.
|
|
320
1150
|
|
|
321
1151
|
The empty `::before` layer is removed from `Glass` and glass `Button`s, so a
|
|
322
1152
|
`::before` rule of your own for the fill cannot cover the solid one, and
|
|
@@ -353,10 +1183,23 @@ Under reduced motion, `withGlassTransition` runs the update with no view
|
|
|
353
1183
|
transition and returns `{ supported: false }`, and `GlassMorph` elements do not
|
|
354
1184
|
animate even in a view transition you start yourself.
|
|
355
1185
|
|
|
1186
|
+
`TabView` follows the WAI-ARIA tabs pattern. The bar is a `tablist` (named by
|
|
1187
|
+
the optional `label` prop) of `tab`s carrying `aria-selected`, and the content
|
|
1188
|
+
is a `tabpanel` labelled by the selected tab. Only the selected tab is in the
|
|
1189
|
+
Tab order. Left and Right select the previous and next tab, wrapping at either
|
|
1190
|
+
end and swapping under `dir="rtl"`; Home and End select the first and last.
|
|
1191
|
+
|
|
1192
|
+
```svelte
|
|
1193
|
+
<TabView {tabs} bind:activeTab label="Sections" />
|
|
1194
|
+
```
|
|
1195
|
+
|
|
356
1196
|
A `Button` with `href` and `disabled` renders a link with no `href`, marked
|
|
357
1197
|
`aria-disabled="true"`. It cannot be focused or followed and does not call
|
|
358
1198
|
`onclick`.
|
|
359
1199
|
|
|
1200
|
+
A disabled `Button`, link or `<button>`, renders at 50% opacity and ignores
|
|
1201
|
+
the pointer, as a disabled `IconButton` does.
|
|
1202
|
+
|
|
360
1203
|
### Focus ring
|
|
361
1204
|
|
|
362
1205
|
The library's buttons, links, rows, tabs, menu items and switch draw one shared
|
|
@@ -428,13 +1271,33 @@ These are unset by default, so you can set them on `:root` or on any ancestor.
|
|
|
428
1271
|
|
|
429
1272
|
| Token | Used by | Default |
|
|
430
1273
|
| ------------------------- | ------------------------------------------------- | --------------------- |
|
|
1274
|
+
| `--glass-track` | The unchecked `Toggle` track. | `rgba(235, 235, 245, 0.3)` dark, `rgba(60, 60, 67, 0.3)` light, `rgba(120, 120, 128, 0.32)` classic |
|
|
431
1275
|
| `--glass-track-checked` | The checked `Toggle` track. | `--color-accent` |
|
|
1276
|
+
| `--glass-segmented-track` | The `SegmentedControl` track. | `rgba(118, 118, 128, 0.24)` dark, `0.12` alpha light |
|
|
1277
|
+
| `--glass-segmented-thumb` | The chosen `SegmentedControl` segment's thumb. | `#636366` dark, `#ffffff` light |
|
|
1278
|
+
| `--glass-slider-track` | The unfilled `Slider` track. | `rgba(120, 120, 128, 0.24)` |
|
|
1279
|
+
| `--glass-slider-fill` | The filled part of the `Slider` track. | `--color-accent` |
|
|
1280
|
+
| `--glass-slider-knob` | The resting `Slider` knob. | `#ffffff` |
|
|
432
1281
|
| `--color-on-accent` | Labels on accent fills: filled `Button`, filled `IconButton` and `glassProminent`. | `white` |
|
|
433
1282
|
| `--color-on-danger` | The `destructive` `Button` label. | `white` |
|
|
434
1283
|
| `--glass-sheet-max-width` | `Sheet` width cap on viewports from 769px. | `900px` |
|
|
1284
|
+
| `--glass-sheet-inset` | Gap around an `inset` `Sheet` below full height. | `8px` |
|
|
1285
|
+
| `--glass-sheet-inset-radius` | Lower corner radius of an `inset` `Sheet`. | `--glass-radius-xl` |
|
|
1286
|
+
| `--glass-sheet-full-height-alpha` | Least background alpha of an `inset` `Sheet` at full height. | `0.94` |
|
|
1287
|
+
| `--color-text` | Text, including the `Sheet` title and header. | the page's; the `Sheet` header falls back to `--glass-text-color-default` (`#f5f5f7` dark, `#1d1d1f` light) |
|
|
1288
|
+
| `--glass-fg` | Text on a toned glass surface (see Adaptive text on glass). Set by `data-glass-tone`. | `#000000` on `light`, `#ffffff` on `dark`, unset elsewhere |
|
|
1289
|
+
| `--glass-fg-secondary` | Secondary text on a toned glass surface. | `--glass-fg` at 60%, or 80% or 100% near a mid backdrop |
|
|
1290
|
+
| `--glass-fg-accent` | Accent text on a toned glass surface, such as the selected tab. | `--color-accent` mixed toward `--glass-fg` until it holds 4.5:1 |
|
|
1291
|
+
| `--glass-text-gradient` | The `GlassSection` title and `Text` with `gradient`. Set in `glasslikeui.css`. | `#ffffff` to `#c7c7cc` dark, `#1d1d1f` to `#48484a` light |
|
|
435
1292
|
| `--glass-button-fill` | The resting fill of the plain `glass` `Button`. You own its contrast. | see below |
|
|
436
1293
|
| `--glass-button-fill-hover` | Its hover fill. | `--glass-button-fill`, else the library hover fill |
|
|
437
1294
|
| `--glass-button-fill-active` | Its pressed fill. | `--glass-button-fill`, else the library pressed fill |
|
|
1295
|
+
| `--glass-list-background` | The `List` card. You own the row text contrast on it. | `#1c1c1e` dark, `#ffffff` light |
|
|
1296
|
+
| `--glass-list-separator` | `ListRow` separators. | `rgba(84, 84, 88, 0.65)` dark, `rgba(60, 60, 67, 0.29)` light |
|
|
1297
|
+
| `--glass-list-row-highlight` | A pressed interactive `ListRow`. | `#3a3a3c` dark, `#d1d1d6` light |
|
|
1298
|
+
| `--glass-list-inset` | Side margin of an `inset` or `insetGrouped` `List`. | `16px` |
|
|
1299
|
+
| `--glass-list-radius` | Corner radius of an `insetGrouped` `List`. | `26px` |
|
|
1300
|
+
| `--glass-nav-edge-fade` | How far the `NavigationBar` scroll edge effect fades below the bar. | `24px` |
|
|
438
1301
|
|
|
439
1302
|
```css
|
|
440
1303
|
.my-sheet {
|
|
@@ -556,7 +1419,7 @@ press and wash colours keep the root's colour, which can put your label below
|
|
|
556
1419
|
| ---------------------- | ----------------------------------------------------- |
|
|
557
1420
|
| Chrome / Edge 111+ | Full. |
|
|
558
1421
|
| Safari 16.4+ | Full, including native `prefers-reduced-transparency`.|
|
|
559
|
-
| Firefox
|
|
1422
|
+
| Firefox 103+ | Full. A `.glass-squircle` glass surface keeps rounded corners. |
|
|
560
1423
|
| Older | Opaque fallback via `@supports not`. |
|
|
561
1424
|
| SSR | All actions guard `typeof window`. |
|
|
562
1425
|
|
|
@@ -567,8 +1430,13 @@ npm run package # svelte-package build
|
|
|
567
1430
|
npm test # vitest once
|
|
568
1431
|
npm run test:watch # vitest watch
|
|
569
1432
|
npm run test:coverage # with v8 coverage
|
|
1433
|
+
npm run test:mutation # Stryker mutation tests
|
|
570
1434
|
```
|
|
571
1435
|
|
|
1436
|
+
The engineering rules are in `standards.md`. How the library is built, and
|
|
1437
|
+
the dependency rings its architecture test enforces, are in
|
|
1438
|
+
`Documentation/Architecture/`.
|
|
1439
|
+
|
|
572
1440
|
## License
|
|
573
1441
|
|
|
574
1442
|
Mozilla Public License 2.0 (MPL-2.0). Copyright (c) 2026 Beau Ayres. See `LICENSE`.
|