GlassKit Elements
Complete reference for all 46 web components – built by Jungherz GmbH. Vanilla JS, Shadow DOM, native form participation.
Installation
CDN (quickest)
npm
Selective Import
Import only what you need for smaller bundles:
Theming
Set data-theme on the <html> element. All components sync automatically via a shared MutationObserver.
Token defaults and color-scheme. The elements put GlassKit’s token defaults on the document once, in @layer glasskit-defaults, so any stylesheet of yours wins over them. Since 1.20.0 that layer carries the --gl-* tokens only. color-scheme stays off the page: each element sets it on its own theme wrapper, so a select’s list, a date picker or a scrollbar inside an element matches its theme while the page keeps its own. Before, importing the elements switched the whole page to color-scheme: dark — text without a colour of its own turned white, links light blue, native controls dark.
The token names stay global, so a component of yours that reads var(--gl-…, fallback) gets GlassKit’s value. A page that declares the tokens itself, or wants them on part of the page only, switches the defaults off — the attribute is watched, so it may also come or go later:
The elements then take the tokens from wherever they inherit them: glasskit.css, or a block of your own on a container around them.
Focus marks
Since GlassKit 1.40.0 every element shows where the keyboard is, in one solid colour: --gl-focus-ring. <glk-button>, <glk-pill> and the actions of <glk-modal> draw it as an outline; they had no mark at all, and a rule of the page could not reach them in their shadow roots. The other elements take the ring, 2 px wide and no longer a tint. GlassKit’s orange reads 3:1 or more on the page and on glass. Press Tab through these:
The colour follows the brand. What lies behind the glass decides how bright it gets, and a darker brand can fall short on the brightest spot, glass on a glow card in the middle of the page in dark mode. One of your own goes into the token, solid; measure it there.
A project that set --gl-border-focus or --gl-shadow-focus itself keeps its own ring until it drops them. In forced colors, Windows’ high contrast mode, the browser drops box-shadow, and every element shows an outline in the text colour.
Density
For admin screens, desktop layouts and narrow forms, data-density="compact" on the <html> element makes every control denser: fields and buttons 40px high instead of 52 and 56, smaller toggles, checkboxes and radios, denser list rows and modal actions. The sizes are GlassKit's density tokens (GlassKit 1.21.0), so they reach every shadow root by inheritance — a project's own values too; with data-glk-defaults="off" the preset comes from glasskit.css on the page, like every other token. The same observer mirrors the attribute onto each element's theme wrapper, so switching at runtime needs nothing else.
Solid and tint surfaces
Not every screen wants glass. data-surface="solid" on the <html> element makes every surface opaque and turns blur and gloss off — cards, fields, buttons, lists, sheets — each in the colour the glass shows over the theme’s middle background. It is GlassKit’s solid surface preset (GlassKit 1.24.0): tokens only, so it reaches every shadow root by inheritance, and a project’s own values do too; with data-glk-defaults="off" it comes from glasskit.css on the page. Since 1.24.0 the observer mirrors this attribute onto each element’s theme wrapper as well, so a rule keyed on it matches inside the shadow roots.
On a page with a background of its own — a brand colour, a photo — data-surface="tint" (GlassKit 1.25.0) makes the surfaces in the flow see-through tints of the text colour instead, nothing blurred. What lies over other content keeps the solid values, inside the shadow roots too: the panels of <glk-modal>, <glk-sheet>, <glk-popover>, <glk-toast> and the tab bars, with the fields inside them, and the secondary button. The wrapper mirrors this value like any other.
Primary as text
GlassKit 1.26.0 gives the primary a second token: --gl-color-primary fills, --gl-color-primary-text colours text and line icons on the page or the glass. In the elements that is the icon and label of the active <glk-tab-item>, <glk-list-item variant="accent">, the value of <glk-range>, the primary action of <glk-modal>, and the trigger under the pointer and the chevron of an open <glk-accordion-item>. It defaults to the primary. A brand that darkens its primary for white button text lightens the text in its dark theme, and the buttons keep their colour; the token reaches every shadow root by inheritance. Write the light rule after the dark one, because :root matches a page in the light theme too:
--gl-tab-bar-active-color colours the icon and label of the active tab alone, for a spotlight that needs a lighter tone still; unset, they take --gl-color-primary-text.
Accent fills
White text on GlassKit’s orange reads 2.0 to 3.8:1 where the accent fills a surface: the primary <glk-button>, the chosen day of <glk-calendar> and <glk-date-strip>, the number of the current step in <glk-steps>. GlassKit 1.32.0 gives these fills tokens of their own, unset by default, so nothing changes until a project sets them: --gl-btn-primary-bg replaces the whole background of the primary button (today’s gradient when unset), --gl-color-primary-fill fills the chosen days and the current step (the primary when unset). A brand that keeps white text darkens the fills and leaves its primary alone — the primary also draws focus rings, borders and the accent as text. The tokens reach every shadow root by inheritance; with these values white reads 5:1 or more on every fill, in both themes:
A brand that turns to a dark ink instead sets --gl-color-on-primary. Since GlassKit 1.32.0 the dot of <glk-radio> follows it as the checkbox tick does; before, it stayed white on the same orange.
Printing
Print dialogs leave out background graphics by default. With GlassKit 1.21.1 the parts that carry a state keep their colours on paper — checkbox, radio, toggle, progress, the current step, the chosen day, the slider thumb, the tone dots — inside the elements as well. A dark page prints its light text and surfaces on white paper; a page meant for printing switches to the light theme for it, and the elements follow:
Form Integration
All form components participate in native forms via ElementInternals: their value goes into FormData, and a reset restores it. Since 1.20.0 the form also learns whether they are valid. The inner field checks required, pattern, min, type="email" and the like, and the element reports its verdict: form.checkValidity() is false while a required field is empty, a submit stops at the first invalid field with the browser’s own message, reportValidity() focuses it, and validity, validationMessage and willValidate answer on the element. <glk-button type="submit"> submits its form and type="reset" resets it — before 1.20.0 both did nothing.
Labels are tied to their fields: a screen reader names the field by its label, and a click on the label text focuses it — as do element.focus() and a click on a <label for> that names the element. The hint of <glk-input> is read as the field’s description.
Disabled (since 1.22.3): every form element follows its own disabled and a <fieldset disabled> around it, as native controls do — dimmed, out of the tab order, no input, a submit button sends nothing, and FormData leaves it out. Before, a fieldset reached only the form data: the fields inside stayed usable, and a submit button sent the form empty. The disabled property reflects the attribute, as on a native control.
Content Components
<glk-title>
Styled heading with text shadow.
<glk-badge>
Inline status badge with color variants — and, with interactive, a filter chip.
interactive renders the badge as a real <button> — pointer cursor, hover tint, focus ring, keyboard operable — and makes it emit glk-click. selected marks the chip that is on and is mirrored to aria-pressed. Try the row: it moves selected on glk-click.
| Attribute | Type | Values |
|---|---|---|
variant | String | primary | success | warning (since 1.18.0) | error |
interactive | Boolean | Pressable chip; enables glk-click |
selected | Boolean | The chip that is on — deepens the badge's own color, sets aria-pressed |
size | String | sm (default) | md: a chip to choose with, 36 px high; property size (since 1.33.0) |
Events: glk-click when interactive is set. Part: badge — the <span>, or the <button> with interactive (since 1.33.0).
Choice chips (since 1.33.0). A badge is 25 to 26 px high, right for a status or a filter above a list. A chip that answers a question in a form — one sector of several in a sign-up, say — takes size="md": 36 px high, in the small text of a form, its label centred. Interactive, it takes taps on 44 px, 4 px above and below its edges, the target every control keeps. GlassKit’s .glass-badge--md draws it; --gl-badge-md-height sets another height. Try the row:
<glk-avatar>
Circular avatar with initials or image.
| Attribute | Type | Values |
|---|---|---|
size | String | sm (32 px) | (default, also md, 44 px) | lg (56 px) |
src | String | Image URL |
Since 1.37.0 an avatar in the leading box of a <glk-list-item> takes the box’s size: 40 px with leading-lg, the avatar of a contact list, and 28 px without. A 44 px one was cut by the box, a 32 px one looked lost in it. GlassKit’s --gl-avatar-size sets any other size, on the element or a container around it, and --gl-avatar-font-size the initials’ size with it; on the avatar itself it wins over the box. Parts (since 1.37.0): avatar, the circle, and image, the picture in it.
<glk-card>
Glass-effect content card.
| Attribute | Type | Description |
|---|---|---|
glow | Boolean | Adds gradient glow effect |
fill | Boolean | Stretches the card to the full height of its grid or flex cell and makes it a flex column, so margin-top: auto pushes a footer down (since 1.8.0). The card yields to its cell: content that cannot wrap, like a nowrap list subtitle, is truncated instead of widening the card (since 1.15.2) |
<glk-divider>
<glk-status>
Status notice with message. Since 1.35.0 the message may be the element’s content, with markup; message stays the short form for plain text and shows while the content is empty (whitespace does not count). GlassKit’s --gl-status-color sets its colour. Parts (since 1.35.0): status, message. Since 1.36.0 the message has no margin of its own (GlassKit 1.36.0): the browser’s 1em above and below it made the notice 82 px high instead of 54 px.
<glk-empty>
Empty state for lists and result pages: icon plate, title, short text and one action. An empty title or text hides its element.
| Attribute | Type | Values |
|---|---|---|
title | String | Heading; hidden when empty |
text | String | Muted text; hidden when empty |
Slots: default (an <svg> icon; a plain circle as fallback), action. Parts: empty, icon, title, text, action.
Buttons
<glk-button>
Glass-styled button with three variants and size options.
| Attribute | Type | Values |
|---|---|---|
variant | String | primary | secondary | tertiary |
size | String | sm | md | lg | auto, or a height and auto together: sm auto, a small button as wide as its text (since 1.31.0) |
disabled | Boolean | Disables the button |
type | String | button | submit | reset — submit and reset act on the element’s form (since 1.20.0) |
aria-label, aria-labelledby, aria-describedby | String | Name and describe the native button from the host instead of its content (since 1.36.0) |
Events: glk-click Part: button, the native button inside (since 1.31.0)
Since GlassKit 1.31.0 every button keeps room beside its label, 24 px unless --gl-btn-padding-x sets another: a small button that takes its width from its text, in a row or an empty state, touched the text with its edges before. --gl-btn-radius rounds the buttons alone — 9999px for pill-shaped ones — and leaves lists and the segmented control as they are.
type="submit" submits the form the element sits in, type="reset" resets it — once the click has finished bubbling, so a listener that calls preventDefault() on the click stops it, as on a native button. A form with invalid fields does not submit and shows the browser’s message. The submit event names the element as its submitter; .form is its form, and element.click() acts like a click. aria-expanded, aria-haspopup and aria-pressed set on the element are handed on to the native button inside, which is what screen readers read (since 1.20.0). Since 1.36.0 aria-label and aria-labelledby name it too — an icon alone, or “Restore” that should say “Restore Info page 55” —, and aria-describedby describes it. aria-labelledby and aria-describedby point at elements of the page through element reflection, as on <glk-toggle>. Before, they stayed on the element, which has no role, and named nothing.
focus() on the element focuses the button inside, and so does autofocus (since 1.33.2; before, the element could not take the focus from outside). <glk-pill>, <glk-tab-item> and <glk-tab-accessory> do the same. Elements with more than one control hand focus() to the one Tab reaches: <glk-segmented> the chosen option, <glk-calendar> and <glk-date-strip> the day that is the tab stop, <glk-image-picker> its choose button, <glk-accordion-item> its trigger, an interactive or sortable <glk-list-item> its row and an interactive <glk-badge> its button.
<glk-pill>
Small circular icon button (46x46px).
| Attribute | Type | Description |
|---|---|---|
label | String | Accessible aria-label |
disabled | Boolean | Disables the button |
aria-expanded, aria-haspopup and aria-pressed are handed on to the native button inside (since 1.20.0) — <glk-popover> sets aria-expanded on its trigger.
Form Components
All form components support name, value, disabled and participate in native <form> submission. The browser’s input event reaches the element once per key or step (since 1.36.0; before, <glk-input>, <glk-textarea>, <glk-search> and <glk-range> sent one of their own on top, and a listener on the element got each twice).
<glk-input>
Text input with label, hint, and error state.
| Attribute | Type | Description |
|---|---|---|
label | String | Input label |
type | String | text, email, password, ... |
placeholder | String | Placeholder text |
hint | String | Helper text, read as the field’s description |
error | Boolean | Error styling; marks the field invalid for screen readers (aria-invalid, since 1.20.0). It does not block the form — a server’s verdict arrives this way |
required | Boolean | Required field; while it is empty the form does not submit (since 1.20.0) |
readonly | Boolean | Read-only: focusable, selectable and submitted, but not editable; property readOnly (since 1.22.0) |
min, max, step | String | Passed to the inner field: range and step of the picker for dates, times and numbers (since 1.17.0) |
minlength, maxlength, pattern | String | Passed to the inner field (since 1.17.0) |
autocomplete, inputmode | String | Autofill and on-screen keyboard, passed to the inner field (since 1.17.0) |
label-hidden | Boolean | The label stays the field’s name, out of sight (since 1.36.0) — below |
aria-label, aria-labelledby | String | Name the field from the host instead of its label (since 1.36.0) |
counter | Boolean | The value’s length at the end of the label row, “12/58” with maxlength (since 1.37.0) — as on <glk-textarea> |
Events: glk-input, glk-change
Slots (since 1.22.0): prefix and suffix put an icon, a currency, a unit or a button inside the field’s box, at its start and end — right to left they swap sides. Each shows only while something is slotted into it; its width is measured and the text keeps clear of it. A click on slotted text, an icon or a disabled control goes through to the field; enabled controls, <glk-button> and <glk-select> included, links and elements with tabindex take their own (since 1.22.2 — before, every slotted element took the click). Slot the control itself: one wrapped in a slotted element needs pointer-events: auto from the page. A container locked with pointer-events: none does not hold a control; lock it with inert, or disable the control. Their text is read with the field as its description. The box is the part box, the affixes prefix and suffix.
A place in the label row (since 1.33.0). slot="label-end" puts a link at the end of the label’s line — “Forgot password?” beside “Password”. The place comes after the field in the shadow tree, so the keyboard reaches the link after the field, which reads best in a sign-in form: email, password, “Forgot password?”, then the button. (Safari tabs to links only with Option+Tab, or with its setting for it, as on every page.) It shows only while something is slotted: then label and link share the line, the link at its end, and the field spans the width below. <glk-textarea> and <glk-select> have the same place. GlassKit’s .glass-input-group--label-end draws it. Parts: label on the label, label-end on the place.
A name without a visible label (since 1.36.0). Fields in a table under one shared header — opening hours with the columns From and To for each day — each need their label as their name, but showing it in every cell repeats the header. label-hidden keeps label as the field’s name and takes it out of sight, as on the switches; aria-label or aria-labelledby on the element name the field directly. A group around each row names the day. <glk-select> and <glk-textarea> take the same attributes. Since 1.38.0 GlassKit’s --gl-label-hidden: 1 does the same for every field in a container and can be set from a container or media query, where the attribute cannot follow: the labels out of sight while the week is a table, above the fields when it turns into a list. It needs style queries on custom properties: Chrome 111, Safari 18 and Firefox 151. Without them the labels stay above their fields — for older browsers set label-hidden from a script, or put the rules of a visually hidden label on ::part(label) in the same query.
<glk-textarea>
Attributes: label, rows, placeholder, required, readonly (since 1.22.0), name, value, disabled. The label names the field. slot="label-end" and the parts label and label-end as on <glk-input> (since 1.33.0). Since 1.36.0 label-hidden, aria-label and aria-labelledby as on <glk-input>. Since 1.37.0 minlength, maxlength, autocomplete and inputmode reach the field, as on <glk-input> — before, a text area took any number of characters —, and counter counts its characters (below).
Events: glk-input { value } on every key; since 1.35.0 glk-change { value } once a value is done — on leaving the field with a changed value, as on <glk-input>, and on Ctrl+Enter or Cmd+Enter, where Enter alone breaks the line. Once for each value: a change reported by the keys is not reported again on leaving. A native change goes out with it.
A character counter (since 1.37.0): counter shows the length of the value at the end of the label row — “48/145” with maxlength, the length alone without —, in GlassKit’s .glass-input-group__counter. Past the limit, as a value set by script may be, it turns to the error colour. It is part of the field’s description, so a screen reader reads it with the field, and it stands after a link in slot="label-end". <glk-input> has it too. Part: counter.
<glk-select>
Children: native <option> elements. With required and an empty first option (value="") the form does not submit until a choice is made (since 1.20.0). The label names the field. A value — attribute or property — that names no option yet is kept and selected once its option arrives, until the user picks another (since 1.22.0; before, a value set as a property before the options were copied was lost). A form reset returns to the value attribute. slot="label-end" and the parts label and label-end as on <glk-input> (since 1.33.0). Since 1.36.0 label-hidden, aria-label and aria-labelledby as on <glk-input>.
A placeholder (since 1.37.0): placeholder puts the native pattern in front of the options — an option with an empty value, disabled and hidden — and shows it in GlassKit’s placeholder colour while no value matches an option: a record without a choice yet, value="", a value that names no option. It cannot be picked, required keeps the form from submitting while it shows, and the form gets no value for it, as from a native select. Before, the first option showed as chosen, and picking it changed nothing, so the page could not tell “nothing chosen” from “the first one”. With a placeholder the empty value means “nothing chosen”, unless an option of the page carries it.
<glk-search>
The search field has no visible label; label names it for screen readers (since 1.20.0) — without it the placeholder is all they can say.
<glk-toggle>
Switch toggle with form participation.
| Attribute | Type | Description |
|---|---|---|
label | String | Toggle label |
checked | Boolean | Checked state |
disabled | Boolean | Disabled state |
required | Boolean | Must be on before the form submits (since 1.20.0) |
label-hidden | Boolean | The label stays the switch’s name, out of sight (since 1.33.1) |
label-position | String | end (default) or start: the label before the switch (since 1.33.1) |
full | Boolean | The control over the whole row, text and switch at its two ends; with label-position="start" the switch at the row’s end, as in the settings of iOS (since 1.39.0) |
aria-label, aria-labelledby | String | Name the switch from the host instead of its label (since 1.33.1) |
Events: glk-change → { checked: boolean } · Parts: track, label (since 1.33.1)
The switch is the native checkbox inside, with role="switch": one control for screen readers, named by label, its state read from the checkbox. Since 1.20.0 the element itself carries no role, aria-checked or aria-disabled — style and select on [checked] and [disabled]. element.click() and a <label> around the element or naming it toggle it, as they do a native checkbox; the same holds for <glk-checkbox> and <glk-radio>. Without label the element is exactly as large as its track, 52 × 30 px.
A name without a visible label (since 1.33.1). In a settings row the title stands on the left and the switch at the end, where its own label would show the title a second time. label-hidden keeps label as the switch’s name and takes it out of sight. aria-label on the element names the switch directly. aria-labelledby points at a title of the page by its id — through element reflection, since an id from the page does not reach into the shadow root, with the title’s text as a fallback name. label-position="start" puts a visible label before the switch. The same attributes work on <glk-checkbox> and <glk-radio>.
The switch at the row’s end (since 1.39.0). full spreads the control over its row: with label-position="start" the text stands at the row’s start and the switch at its end, as in the settings of iOS, mirrored right to left. GlassKit 1.39.0’s --label-start and --full do the same without the elements. The whole row is the label, so a click anywhere on it switches. <glk-checkbox> and <glk-radio> take the same attributes. In a list row the switch goes into slot="trailing" with label-hidden instead, the row’s title as its name (above).
<glk-checkbox>
required keeps the form from submitting until the box is ticked (since 1.20.0).
Since 1.33.1 label-hidden, label-position and aria-label / aria-labelledby on the element work as on <glk-toggle>. Parts: box, label.
<glk-radio>
required on any radio of a group makes the group required; any checked radio satisfies it, as with native radios (since 1.20.0).
Since 1.33.1 label-hidden, label-position and aria-label / aria-labelledby on the element work as on <glk-toggle>. Parts: circle, label.
<glk-range>
| Attribute | Type | Description |
|---|---|---|
min | Number | Minimum (default: 0) |
max | Number | Maximum (default: 100) |
value | Number | Current value |
step | Number | Step increment |
Events: glk-input { value } on every step; since 1.36.0 glk-change { value } once a value is set — when the pointer lets go of the thumb, and on every key, as the native slider’s change: one request instead of one per step of a drag. A native change goes out with it.
<glk-segmented>
A small, exclusive choice as one control. Renders one <button> per option, the chosen one marked aria-pressed="true"; a value change only re-sets that attribute, so focus stays where it was. Form-associated: a surrounding <form> receives name=value, reset restores the initial value. Try it: Tab to a button, press Space. More options than fit: overflow="scroll" keeps one row that scrolls sideways and keeps the chosen option in view, overflow="wrap" breaks it into lines.
| Attribute | Type | Values |
|---|---|---|
options | JSON | [{ value, label, tone?, disabled?, badge?, badgeLabel?, badgeTone? }] — tone: success | warning | error; badge: a count after the label (since 1.29.0); badgeTone: primary | success | warning | error, the count’s own colour (since 1.31.0) |
value | String | The chosen option's value |
full | Boolean | Buttons share the width |
overflow | String | scroll — one row that scrolls sideways, the chosen option kept in view; wrap — breaks into lines. Without it the row stays one line (since 1.17.0) |
label | String | aria-label of the group |
name | String | Form field name (form-associated) |
disabled | Boolean | The whole row (since 1.22.3); a <fieldset disabled> around it disables it too |
droplet | Boolean | The chosen option sits on a drop of glass that glides to the next one and can be dragged (since 1.27.0) |
icon-only | Boolean | The options show their icons alone, square; each label becomes the button’s aria-label and title (since 1.28.0; property iconOnly) |
Events: glk-change { value } — only on a change made by the user. Slots: icon-<value> (since 1.28.0). Parts: group, item (each option) and badge (its count), the last two since 1.31.0.
Droplet (since 1.27.0). droplet gives the chosen option the drop of the tab bar: it runs to a new option, stretches on the way and settles, the text it passes lights up, and a finger can drag it. A drag that ends on an option selects it like a tap — value, glk-change and the form value follow; disabled options are skipped. With overflow="scroll" a swipe still scrolls the row: only the drop itself is dragged, and the row scrolls along at its edges. Recommended wherever a segmented control is used:
Icons (since 1.28.0). Each option takes an icon from the slot icon-<value> — an <svg>, a font icon such as Material Icons, an <img>. It sits in GlassKit’s .glass-segmented__icon before the label, in the option’s colour, and grows under the drop; an option without one has no icon box. icon-only shows the icons alone, for a light / dark / auto switch: the options become square, and each label becomes the button’s aria-label and title. The icon box is hidden from assistive technology, so a font icon’s text never joins the name.
Coloured logos (since 1.35.0). An SVG icon strokes in the option’s colour, which outlines a coloured logo — the mark of an image source — in the text colour. icon-style="color" keeps the logos’ own fills and strokes for every option, "iconStyle": "color" in an option’s JSON for that one (GlassKit’s .glass-segmented__icon--color). Attributes on the <svg> itself do not help: the slotted rule wins over them in all three engines.
Counts (since 1.29.0). badge on an option shows how much waits behind it — open invoices, new tickets — as a small pill after the label, in tabular figures; where the dot only says that something is there, the badge says how much. A number or a short text; missing, empty or 0 shows none. Without a tone the pill is neutral, with one it takes the tone’s colour. The name says it with the label, “Tickets, 1”, and badgeLabel words it, “Tickets, 1 open”. In an icon-only row the badge sits at the icon’s corner, as on <glk-tab-item>, and the button’s title carries it as well. New options with the same values in the same order fill the buttons in place: a count that changes keeps the focus and the drop where they are.
A colour of the count’s own (since 1.31.0). badgeTone — primary, success, warning or error — colours the count alone, with GlassKit’s .glass-segmented__badge--*: the look of the badge variants, without the dot that tone puts before the label. Where an option has both, the count keeps its own colour. Size and hairline come from GlassKit’s tokens, --gl-segmented-badge-height, -font-size and -border, which reach the element by inheritance; for anything else the count is the part badge and each option the part item.
GlassKit’s tokens for the chosen option reach the element by inheritance (GlassKit 1.28.0): --gl-segmented-active-bg, --gl-segmented-active-shadow and --gl-segmented-active-color — for a dark brand on which the light surface leaves a white label below 4.5:1. The drop takes the same surface.
Tooltips per option (since 1.39.0): an icon-only row shows each label in a tooltip — on hover after a moment, at once on keyboard focus, on a long press, as <glk-tooltip> — where it had the browser’s title, which showed neither on focus nor on touch. An option’s hint in options is the tooltip’s second line, GlassKit’s .glass-tooltip__hint, and the button’s description; in a row with labels an option with a hint shows the hint alone. tooltip-placement (top, the default, bottom, start, end) says where they open — bottom for a row in a head. Part: tooltip. Hover or focus an option:
<glk-calendar>
One month with a day to pick. The days are buttons in a role="group", the chosen one aria-pressed="true", each named with its full date; month title, weekday names and the first day of the week come from Intl for the locale (week-start overrides). One tab stop: arrows move by a day or a week, Home/End to the ends of the week, PageUp/PageDown by a month — moving past the month’s edge shows that month and emits glk-month. Arrows only move focus; Enter or Space picks, so a calendar that opens a sheet on every pick stays quiet while the user looks around. Days outside min/max are aria-disabled: in the arrow path, announced, never picked. Form-associated like <glk-segmented>. Try it: Tab into the grid, use the arrows, press Enter.
| Attribute | Type | Values |
|---|---|---|
month | String | Shown month YYYY-MM; without it the month of the value, else of today. Reflected when the user navigates; a value set to another month flips to it |
value | String | Chosen day YYYY-MM-DD |
today | String | The day with the warm border; the browser’s day when missing |
min, max | String | Days outside cannot be picked (aria-disabled) |
marks | JSON | { "2026-09-30": ["error", "warning"] } — up to three tones per day: primary | success | warning | error |
locale | String | BCP 47 tag for names and week start; without it the page language — the lang of the nearest ancestor, usually <html lang>, also across shadow roots — else the browser language (page language since 1.19.2) |
week-start | Number | 0 = Sunday … 6 = Saturday; from the locale when missing, Monday where the browser cannot say |
label | String | aria-label of the day group |
prev-label, next-label | String | Names of the nav buttons; “Previous month” / “Next month” by default |
name | String | Form field name (form-associated) |
disabled | Boolean | Arrows and days (since 1.22.3); a <fieldset disabled> around it disables it too |
Events: glk-change { value } on a pick by the user; glk-month { month } when the user moves to another month. Properties: month, value, marks, locale, label, disabled. Parts: calendar, head, title, grid.
<glk-image-picker>
One image with a preview, resized on the client before it goes anywhere. Choose opens the file dialog from a real button; the file is decoded with createImageBitmap, the EXIF rotation of a phone photo applied, drawn onto a canvas no larger than max and handed out as a data URL in glk-change. The src property holds it and is not reflected, so a data URL of megabytes never lands in the DOM. A file the browser cannot decode — Chrome and HEIC, a corrupt file — emits glk-error instead of failing silently. Not form-associated: listen to glk-change and upload. Try it with a photo from your phone.
| Attribute | Type | Values |
|---|---|---|
src | String | Starting image: URL or data URL |
label | String | Visible label; names the group |
hint | String | Small muted line; none by default — what is accepted depends on accept and the browser |
round | Boolean | Circular preview, for avatars |
max | Number | Longest edge in px after resizing, default 1024 |
type, quality | String, Number | Output MIME (default image/jpeg; image/webp where the browser encodes it, PNG otherwise) and quality 0–1 (default 0.82) |
accept | String | File dialog filter, default image/* |
choose-label, change-label, remove-label | String | Button texts; “Choose”, “Change”, “Remove” by default |
Events: glk-change { dataUrl, width, height, size } after a pick, and on remove with an empty dataUrl and zeros; glk-error { message, name } when the file cannot be decoded. Property: src (not reflected). Parts: picker, preview, meta, label, hint, actions.
Feedback
<glk-progress>
Progress bar with its label and value. Since 1.33.2 the element is the progress bar for assistive technology: role="progressbar" with the value, 0, max and the value text, named by label — or, for a bar without a visible label, by aria-label or aria-labelledby on the element.
| Attribute | Type | Values |
|---|---|---|
label | String | The text over the bar at its start; names the bar |
value | Number | 0 – max; with decimals since 1.33.2 |
max | Number | The value of a full bar, 100 by default; the fill is value / max (since 1.33.2) |
value-text | String | The text at the end of the label row, such as 3 of 20, and the bar’s value text for screen readers; without it, the percentage (since 1.33.2) |
variant | String | success | error |
size | String | sm | (default) | lg |
Parts: label, value, track, fill (since 1.33.2) Properties: value, max, valueText
<glk-modal>
Modal dialog with title, body, and action buttons. Since 1.20.0 it is a native <dialog>, opened with showModal(): it lies above everything else, the page behind it is inert for pointer, keyboard and screen readers, focus moves into it and goes back to where it came from when it closes, and its content is out of reach while it is closed. The title names the dialog.
Are you sure you want to proceed?
| Attribute | Type | Description |
|---|---|---|
open | Boolean | Show/hide |
title | String | Header title |
Methods: .show(), .close() (a promise since 1.32.0) Events: glk-open (whenever it opens, since 1.30.0), glk-close, glk-closed (since 1.32.0)
Since 1.35.0 glk-open, glk-close and glk-closed stay at the element: they do not bubble, as the native close and toggle do not, so a container around it no longer takes them for its own. Listen on the element itself.
While the modal is open the page behind it does not scroll (since 1.30.0): the top layer kept it inert for pointer and keyboard, but a wheel or a finger over the dimmed area still moved it.
glk-closed (since 1.32.0) follows once the modal has faded out and its dialog has closed, however it closed — Escape, the dimmed area, .close(), the attribute — and at once under prefers-reduced-motion; .close() returns a promise that settles at the same moment. A page that renders the modal from its state removes it there, and the fade shows; before, it had to guess the duration or cut the fade short.
Which element gets the focus on opening, browsers decide differently — Chrome takes the first field of the content, Safari the first action. Mark one with autofocus, in the content or among the actions, to settle it. Escape and a click on the dimmed area close the modal with its fade and emit glk-close; .close() does not emit. While it is open, everything outside is inert — a <glk-toast> shown then is neither clickable nor announced, so give feedback inside the modal or close it first.
The actions are copies of the buttons in slot="actions", and a click on one is handed to its original. Since 1.28.0 the copies follow every change of the originals, attributes included: a confirm button that starts disabled unlocks once the page enables it, also through a framework that binds only disabled. A copy keeps its focus while it changes, and an inline onclick runs once per click, on the original — before, it ran twice.
<glk-toast>
Notification at the top of the screen that hides itself — and, since 1.19.0, one that offers something: with action-label (or show(message, { action })) it gets a button and an ×, and stays until one of them is used unless a duration is set. The action emits glk-action and closes the toast — unless a listener calls preventDefault() or shows the next message; the × and Escape emit glk-close. While the pointer or the focus is on it, it does not time out. It is a polite live region, so the message is announced.
| Attribute | Type | Values |
|---|---|---|
message | String | The text |
variant | String | success | error | warning — colours the icon and the action |
duration | Number | ms; 0 keeps it up. Default 3000 — with an action, no timeout unless set |
visible | Boolean | Shown |
action-label, action-value | String | The action button and the value glk-action reports (the label when missing) (since 1.19.0) |
dismissible | Boolean | An × without an action; an action always brings one (since 1.19.0) |
close-label | String | Name of the ×, “Close” by default (since 1.19.0) |
Methods: .show(message, variant, duration), .show(message, { variant, duration, action: { label, value }, dismissible }), .dismiss(). Slot: icon — replaces the built-in icon; leave its stroke unset and it takes the variant colour. Events: glk-action { action, label } (cancelable), glk-close (× or Escape), glk-dismiss (timed out).
Since 1.35.0 glk-close stays at the toast and does not bubble; glk-action and glk-dismiss still do.
Above a sheet or a modal (since 1.39.0): a <glk-sheet> or <glk-modal> lies in the top layer as a native dialog, and the toast, fixed in the page, stood under it and its blurred overlay — “That name is taken” for a sheet’s form could not be read. The toast is a popover="manual" now, open while it is in the document — hidden it stays invisible and lets the pointer through, and as a live region it keeps being read — and every show() puts it in again, last and so on top. Beside a modal it can be seen, but, as everything outside the dialog, not used or announced: put a message a screen reader must hear into the dialog itself. A toast shown before a dialog opens lies under it until its next show().
<glk-popover>
Anchored dropdown / menu container. Wraps a trigger element (via slot="trigger") and its floating content. The element manages .is-open toggling, outside-click dismiss, and Escape-key close internally — no manual class toggling needed. After Escape the focus goes back to the trigger when it was in the panel, since 1.38.0 also in a shadow root of an app’s own elements, where it stayed behind in the hidden panel.
| Attribute | Type | Default | Description |
|---|---|---|---|
open | Boolean | false | Visibility state (reflected as .is-open on the inner surface) |
placement | String | bottom | top | bottom | start | end — below the trigger and centred, above it with top; start and end align it at the trigger’s start or end edge |
| Slot | Purpose |
|---|---|
trigger | Element that toggles the popover when clicked |
| (default) | Floating content shown while open |
Events: glk-open, glk-close. Since 1.35.0 glk-open, glk-close and glk-closed stay at the element: they do not bubble, as the native close and toggle do not, so a container around it no longer takes them for its own. Listen on the element itself. Escape closes the popover and is marked as handled (preventDefault(), since 1.35.0): a sheet or a modal around it stays open, and a container can tell from defaultPrevented that the popover took the key.
Methods: .show(), .close(), .toggle()
Heads-up: the method is deliberately called .toggle() — not .togglePopover(), which collides with the native HTMLElement.togglePopover() API.
The trigger tells whether the popover is open: it gets aria-expanded, also after it is swapped (since 1.20.0). <glk-button> and <glk-pill> hand it on to their native button.
Top layer (since 1.32.0). The panel opens in the top layer (the popover API), position: fixed there, so it sits right on a scrolled page too, and is placed by script: next to the trigger on the side placement asks for, flipped to the other side where the viewport leaves no room, shifted along it to stay inside, and kept there while the page scrolls. Before, it hung absolutely below the trigger: an overflow: hidden around it cut it off, at the screen’s edges it left the screen, and closed it still widened the page by its box. Escape gives the focus back to the trigger when it was inside the panel. For a list of actions, <glk-menu> brings the keyboard of a menu; the popover stays for free content.
<glk-tooltip>
A short name or hint for a control, on hover and focus (since 1.32.0) — GlassKit’s .glass-tooltip. The control is the element in slot="trigger", or the one for names by its id in the same document or shadow root, so a tooltip can serve a control rendered elsewhere; the text is the tooltip’s own content. Try it — hover the buttons, or reach them with Tab:
| Attribute | Type | Values |
|---|---|---|
for | String | The id of the control, in the same document or shadow root; without it the element in slot="trigger" |
placement | String | top (default) | bottom | start | end — start and end follow the writing direction |
show-delay | Number | ms on hover before it shows, default 400; focus and a long press do not wait |
as-label | Boolean | The text is the control’s name (aria-label) rather than its description — for an icon-only control |
The text describes the control: it becomes the aria-description of the element that takes the focus — inside <glk-button>, <glk-pill> or <glk-tab-item> their native button — and follows changes of the text; with as-label it is the control’s name. Whatever the control said there before comes back when the tooltip goes. It shows on hover after show-delay, on keyboard focus at once, and by touch while a finger rests on the control — a long press of 500 ms, after which it stays 1.5 s; a tap never shows it and is never held up. It hides when the pointer leaves the control and the tooltip, so the pointer may move onto it (WCAG 1.4.13), on blur, on a press, and on Escape, which leaves the focus where it is and a dialog around it open. It lies in the top layer — popover="hint" where the browser knows it —, never cut off by a box around it, flipped and shifted to stay in the viewport.
Methods: show(), hide(). Properties: placement, htmlFor. Slots: default (the text), trigger. Part: tooltip. GlassKit’s tokens reach it by inheritance: --gl-tooltip-bg, --gl-tooltip-color, --gl-tooltip-max-width (240 px) and --gl-tooltip-offset, its distance from the control (8 px).
<glk-sheet>
Bottom sheet — the mobile sibling of <glk-modal>. Since 1.30.0 its overlay is a native <dialog> opened with showModal(), like the modal’s: it lies in the top layer, above every fixed or transformed element of the page whatever its z-index — a tab bar with a backdrop filter can no longer land above it —, the page behind it is inert and does not scroll, and focus moves in (an autofocus element takes it). Opening and closing are animated by GlassKit's .glass-sheet block, and under prefers-reduced-motion it switches at once. It emits glk-open whenever it opens — attribute, property or show() — so a page can hide its own fixed bars; scrim click and Escape close it and emit glk-close, close() does not. inline embeds the panel in the flow without an overlay.
Sheet content: a list, text, a form. This one is inline.
Tap outside or press Escape to close.
| Attribute | Type | Values |
|---|---|---|
open | Boolean | Shown as an overlay |
inline | Boolean | In the flow, no overlay, always visible |
title | String | Heading and aria-label |
label | String | The dialog’s name without a visible title (since 1.35.0; before, it had none) |
dismissible | Boolean | A round close button at the end of the head (since 1.35.0); a click on it closes like a click outside, with glk-close |
close-label | String | Its name, “Close” by default (since 1.35.0) |
placement | String | bottom (default) | start | end: a panel at that side, full height, without grip, actions side by side (since 1.35.0) |
modeless | Boolean | Opened with show(): no scrim, the page stays usable, other dialogs open above it (since 1.35.0). Set or removed on an open sheet, it reopens in the other mode, and the page’s scroll lock follows (since 1.40.0) |
initial-focus | String | panel: a modal sheet starts at its panel, not at the first field it holds — no on-screen keyboard over a sheet that is opened to be read (since 1.39.0) |
Methods: show(), close(). Slots: default (content), actions; since 1.35.0 eyebrow (a short line above the title), leading and trailing (before and after it in the head); since 1.36.0 subtitle (below it). Parts: overlay, sheet, title, body, actions; since 1.35.0 grip, head, eyebrow, leading, trailing, close; since 1.36.0 subtitle and close-icon, the glyph of the close button. Events: glk-close — only when the user closes it (scrim, Escape); glk-closed — once it has slid out (since 1.32.0).
glk-closed (since 1.32.0) follows once the sheet has slid out and its dialog has closed, however it closed — scrim, Escape, close(), the attribute — and at once under prefers-reduced-motion; close() returns a promise that settles at the same moment. A page that renders the sheet from its state removes it there, and the slide shows. An inline sheet shows no overlay, so nothing slides: close() settles at once.
The head (since 1.35.0): slot="eyebrow" puts a short line above the title, leading a mark or an icon chip before it, trailing a badge after it, and dismissible a round close button at its end, named by close-label. Each place shows only while it holds something; a title alone stands as before. Without a title, label names the dialog. Since 1.36.0 slot="subtitle" puts a badge or a line below the title, where one in trailing squeezed the title in a narrow sheet, and the head of a sheet without a title, places and close button takes no room (GlassKit 1.36.0; before, it kept 8 px). GlassKit’s --gl-sheet-close-size, --gl-sheet-close-icon-size and --gl-sheet-close-icon-stroke size the close button and its glyph, and the part close-icon reaches the glyph.
Restoring replaces the current version.
The badge stands below the title, which keeps its width; the close button is plain, 44 px with a 20 px glyph.
At a side, modeless (since 1.35.0): placement="end" or "start" puts the panel at that side of the window, as high as the window less 16 px at both ends, 440 px wide (GlassKit’s --gl-sheet-side-inset and --gl-sheet-side-width), sliding in from that side, mirrored right to left, without a grip and with its actions side by side — a side panel on a desktop. modeless opens it with show() instead of showModal(): no scrim, the page stays usable and its chosen row in view, a modal opened later lies above it, Escape inside it closes it and a click outside does not, and the focus moves into the panel on opening — or to what carries autofocus — and back where it came from on closing. Since 1.36.0 a popover or menu open in a modeless sheet closes first on Escape — before, the sheet closed and left it open in the top layer —, and GlassKit’s --gl-sheet-side-inset-block-start and -block-end set the top and the bottom on their own, below a fixed bar of the page.
A modal panel at the end edge, full height.
The page stays usable beside it. Escape closes it.
Events (since 1.35.0): glk-open, glk-close and glk-closed stay at the element: they do not bubble, as the native close and toggle do not, so a container around it no longer takes them for its own. Listen on the element itself. On dark mode’s glass the sheet’s glow starts lower, and the controls on it keep their contrast — see GlassKit 1.35.0’s dark glass.
Where the focus starts (since 1.39.0): showModal() focuses the first thing a sheet holds, and when that is a text field a phone brings up its keyboard over the sheet. initial-focus="panel" starts a modal sheet at its panel instead, as a modeless one does; an element with autofocus still wins. The sheet slides in whatever takes the focus: GlassKit 1.39.0’s overlay clips without scrolling, and the sheet focuses without scrolling — a focus while it slid in used to scroll the overlay, and the panel stood at its place at once or swung past it.
Containers
<glk-accordion> + <glk-accordion-item>
Collapsible accordion sections.
| Attribute | Component | Description |
|---|---|---|
title | glk-accordion-item | Trigger text |
open | glk-accordion-item | Expanded state |
Events: glk-toggle → { open: boolean } Parts: item, trigger, content, body (since 1.30.0)
The trigger carries aria-expanded and aria-controls; a closed section is inert, so its links and fields are out of the tab order and out of the accessibility tree until it opens (since 1.20.0). An open section takes the height of its content, however long, and slides to it (GlassKit 1.30.0) — until then it ended at 500 px and cut off the rest.
A summary in the head (since 1.39.0): slot="summary" puts the values of a closed entry beside its title — a headline, a date — in GlassKit’s .glass-accordion__summary: the room up to the chevron, one muted line with an ellipsis. It stands inside the trigger, so a click on it, Enter and Space open the item as on the title, and it is part of the trigger’s name. It shows while something is slotted; hide it while the item is open, where the fields show the values themselves, with glk-accordion-item[open] [slot="summary"] { display: none; }. Part: summary. Since GlassKit 1.39.0 the trigger also shows a ring for the keyboard.
<glk-list> + <glk-list-item>
iOS-style grouped settings list. Items carry a leading icon, title + optional subtitle, and a trailing element. Dividers between items are drawn automatically — never add <hr> markup between items. Supports section headers, large icons, multi-line subtitles, trailing values, and semantic variants.
| Attribute | Component | Description |
|---|---|---|
header | glk-list | Section header text — uppercase label above the list |
flush | glk-list | Edge-to-edge variant — removes side borders and radius and reaches the edges of its container: a <glk-card>, the body of a <glk-modal>, a <glk-sheet> (both edges since 1.29.1; elsewhere --gl-list-flush-inset names the container’s padding, 20 px unless set) |
bare | glk-list | Strips background, border, shadow — for embedding inside <glk-popover> or <glk-card> |
sortable | glk-list | The items can be reordered by mouse, touch and keyboard (since 1.32.0) — see Sorting |
group | glk-list | Lists with the same group exchange items, and breadcrumbs of that group take them (since 1.32.0) |
grid | glk-list | The items as tiles side by side, each a pane of glass (since 1.34.0) — below |
handle | glk-list, glk-list-item | start puts the handle before the icon, end (default) after the trailing content; on the list for all its items, an item’s own wins (since 1.34.0) |
title | glk-list-item | Primary text |
subtitle | glk-list-item | Secondary text (muted, optional) |
interactive | glk-list-item | Hover / focus / active states + emits glk-click; since 1.32.0 a button for the keyboard and assistive technology: in the Tab order, Enter and Space click it — in a sortable list Space picks it up —, a focus ring shows |
container | glk-list-item | In a sortable list: takes a dropped item inside it, a submenu (since 1.32.0) |
no-drag | glk-list-item | In a sortable list: stays where it is (since 1.32.0) |
selected | glk-list-item | The entry a list beside its detail shows: a pill of raised glass, aria-current="true" on the row; the page sets it (since 1.34.0) |
center | glk-list-item | Centered single-text variant (e.g. for action rows) |
leading-lg | glk-list-item | Large 40×40 leading icon with rounded corners (for app icons) |
wrap | glk-list-item | Multi-line subtitle (up to 3 lines with ellipsis) |
detail | glk-list-item | Muted trailing value text (e.g. file size, version) |
variant | glk-list-item | danger (red destructive) or accent (primary color) |
| Slot | Component | Purpose |
|---|---|---|
leading | glk-list-item | Icon slot (24×24 SVG, or 32×32 with leading-lg) |
trailing | glk-list-item | Chevron, badge, or button (rendered after detail value) |
title-trailing | glk-list-item | Beside the title — a badge such as “AI”, a mark —; it moves under the title where the row is too narrow (since 1.35.0) |
extra | glk-list-item | Below the subtitle: a link (“Undo”), a line of chips (since 1.35.0) |
handle | glk-list-item | A grip at the row’s end, or its start with handle="start" (since 1.34.0): in a sortable list a pointer starts a drag only there, a finger at once; the keyboard still picks the item up on its row (since 1.32.0) |
Events: glk-click on <glk-list-item> when interactive is set. A sortable list emits the glk-sort events and takes messages, the texts it announces — see Sorting.
Parts (since 1.34.0): item, the row, and handle on <glk-list-item>; since 1.35.0 also title, subtitle, title-trailing and extra, since 1.36.0 leading and trailing; header and list on <glk-list>. GlassKit’s --gl-list-title-size, --gl-list-title-weight and --gl-list-subtitle-size set a row’s type (since 1.35.0), and --gl-list-item-selected-inset, -radius, -shadow, -color and -weight shape the chosen row — 0, 0, none make a flat tint over the whole row. Since 1.36.0 the title of the chosen row takes the row’s colour, so -color reaches it, and --gl-list-leading-width widens the leading box — a time and a chip before the text —, the dividers following it.
A list beside its detail (since 1.34.0): selected marks the entry an editor next to the list shows. GlassKit’s .is-selected lays a pill of raised glass into the row, as the selected item of a <glk-tree> has, and the row says aria-current="true". The page sets it — a click does not — and moves it when another entry opens.
Tiles (since 1.34.0): grid lays the items out side by side, as many columns as fit at GlassKit’s --gl-list-tile-width (140 px). Every tile is a pane of glass of its own: the icon at the top, title and subtitle at its foot, the trailing slot in the top end corner, no dividers. Sorted, the tiles move on the horizontal axis — before a tile on its start half, after it on its end half, into a container in its middle — and the line stands upright in the gap. The keyboard keeps their order: Up and Down step from place to place, Right goes into a container. Drag a tile, or drop one into “Submenu”.
The grip first (since 1.34.0): handle="start" on the list, or on one item, puts the handle before the icon, and the keyboard reaches a button in it before the row’s other controls. Its width is the page’s, so the dividers run from the row’s padding until GlassKit’s --gl-list-item-divider-inset says where the text begins.
Until 1.32.0 an interactive item was a plain list item that only a pointer could reach. Now its row is a button: it takes the focus in the Tab order, Enter clicks it on keydown and Space on keyup, as on a native button — in a sortable list Space picks the item up instead —, and a screen reader announces it as a button.
Changes in place (since 1.32.0): as in <glk-tree>, the page appends, removes and moves items with the DOM’s own methods, without rendering the list again. A moved item is the same element and keeps the focus; the focus of a removed one goes to the item that took its place, else to the one before it — while the focus was in the list. highlight() on an item flashes its row for 1.2 s (GlassKit’s .is-flash, tinted by --gl-flash-color), for an item that changed elsewhere; under prefers-reduced-motion nothing flashes.
Wrapping text (since 1.23.0): title and subtitle keep to one line, and wrap clamps the subtitle at three lines. GlassKit’s list tokens change that for a whole app, one list or one row — they are inherited into the element: --gl-list-title-white-space and --gl-list-subtitle-white-space (normal wraps) and --gl-list-subtitle-lines (the clamp of wrap, none shows every line). A word wider than the column breaks instead of running out of the row, and hyphens set on glk-list or the page reaches the text as well.
Framework-safe: both elements use pure Shadow DOM with slot projection — no child node cloning — so they compose cleanly inside lit-html templates, HybridsJS, React, Vue, and Svelte.
<glk-tree> + <glk-tree-item>
A tree with levels that open and close (since 1.32.0) — GlassKit’s .glass-tree: the structure of an app, menus with submenus, folders. The levels are nested <glk-tree-item> elements. It follows the WAI-ARIA tree view: role="tree" named by label, one tab stop — the selected item, else the first — and the keyboard below. A click on a row selects it, a click on its twisty opens or closes it. The tree has no surface of its own: put it in a card or a sidebar. Try it — open “Footer”, whose children load when it opens, and “Archive”, whose first load fails; the button moves “Contact” as another device would:
| Attribute | Component | Description |
|---|---|---|
label | glk-tree | The tree’s name |
selection | glk-tree | single (default) | none — with none no item is selected, and glk-tree-select still comes: a tree of links |
sortable, group | glk-tree | The items move by mouse, touch and keyboard — see Sorting |
label | glk-tree-item | The row’s text and the item’s name — its children’s text stays out of it |
value | glk-tree-item | What glk-tree-select reports and the tree’s value; the label when missing |
expanded | glk-tree-item | Open |
selected | glk-tree-item | Selected; one item per tree |
disabled | glk-tree-item | Reached by the arrow keys and announced as unavailable, but not selected |
has-children | glk-tree-item | Children still to come: the twisty shows before any child exists, and opening the item loads them, once |
load-error | glk-tree-item | The children could not load, the reason as its value (property loadError) — see below |
container, no-drag | glk-tree-item | For a sortable tree — see Sorting |
Keyboard: Down and Up move to the next and previous visible item, Home and End to the first and the last; Right opens an item or moves to its first child, Left closes it or moves to its parent, both mirrored right to left; Enter and Space select — the selection does not follow the focus; * opens every sibling; a typed letter moves to the next item that starts with it. The keys and the typed letters work on what has loaded.
Events: glk-tree-toggle { item, expanded } and glk-tree-select { item, value }, cancelable and before anything changes; glk-tree-load { item, retry }, below. Properties: value (the selected item’s), items (the top level; on an item its children); on an item also loading and loadError. Method of <glk-tree-item>: highlight(). Slots of <glk-tree-item>: default (the child items), icon, trailing (a badge, a status, an action — a click there selects nothing), handle. Parts: tree; on the item item, row, twisty, label, group, and since 1.34.0 icon and handle. The icon field is GlassKit’s --gl-tree-icon-size square (18 px, since 1.34.0): 28px takes a tinted chip as list rows show, where it was squeezed to 18 px before.
Loading on demand. has-children says that children are still to come. Opening such an item emits glk-tree-load { item, retry }, cancelable; the item then loads — loading is true, aria-busy is set, a spinner takes the twisty’s place — until child items arrive or has-children goes. It loads once: closed and opened again, it keeps its children and emits no second load; has-children added again after it went allows another. An item moved into one that has not loaded yet loads nothing and does not count as loaded, so opening it later still emits glk-tree-load. Cancelled, the item shows no loading state, for a page that fills it from a cache or reports an error itself; children appended inside the handler count as loaded at once.
When loading fails, the page sets load-error="message" (property loadError; an empty value reads “Could not load.”). The item closes and shows GlassKit’s .is-error — the twisty turns into a “!” in the error colour —, the message becomes the item’s description, and the tree announces “Label: message” in a polite live region. Opening the item again retries: load-error goes, and glk-tree-load comes with retry: true.
Changes in place. The page appends, removes, moves and renames items with the DOM’s own methods, without rendering the tree again: expanded levels, the selection and the scroll position stay, and a moved item is the same element. The focus stays on a moved item; where the focused item was removed, it goes to the one that took its place, else to the one before it, else to the open item around it, and where the item now lies in a level that closed, to the open item around it. That only while the focus was in the tree: a focus that left by Tab, a click or the page’s own focus() stays where it went. highlight() flashes an item’s row for 1.2 s — GlassKit’s .is-flash, tinted by --gl-flash-color —, for an item that changed elsewhere: on another device, by an undo, in an AI run. Under prefers-reduced-motion nothing flashes.
The roles and states sit on the items themselves (ElementInternals): treeitem, aria-level, aria-setsize and aria-posinset — the browser cannot count them through the slots —, aria-expanded, aria-selected, aria-disabled and, while children load, aria-busy. GlassKit’s tokens reach the tree by inheritance: --gl-tree-indent (20 px per level) and --gl-tree-row-height (36 px).
<glk-table>
A native <table class="glass-table"> in its light DOM, kept a table — its semantics, copy and paste, find in page, markup rendered on the server — with what a list of invoices or users needs around it (since 1.32.0): sortable headers, a header that stays in view while the rows scroll, row actions within reach, an empty state, and cards on narrow screens. The table stays in the page, so the page’s glasskit.css styles it. Try it — sort a column, scroll the box, open a row’s menu; below 640 px of width the rows become cards:
| Invoice | Customer | Date | Amount | Status | |
|---|---|---|---|---|---|
| 2026-1048 | Bergmann Bakery | 2026-10-27 | 1,240.00 € | Open | |
| 2026-1047 | Kaya Florists | 2026-10-24 | 86.50 € | Paid | |
| 2026-1046 | Northside Dental Practice | 2026-10-21 | 3,980.00 € | Overdue | |
| 2026-1045 | Alder & Sons Joinery | 2026-10-17 | 512.30 € | Paid | |
| 2026-1044 | Marlow Yoga Studio | 2026-10-12 | 149.00 € | Paid | |
| 2026-1043 | Okafor Translations | 2026-10-08 | 720.00 € | Open |
| Invoice | Customer | Date | Amount |
|---|
| Attribute | Type | Values |
|---|---|---|
sort | String | The data-sort key of the sorted column |
direction | String | ascending (default) | descending |
sticky-header | Boolean | The wrap scrolls both ways, as high as --gl-table-max-height (60vh), and the header cells stick to its top on a surface of their own |
list-below | String | A width such as 640px: narrower than that — measured on the element, not the viewport — each row becomes a card |
Sorting. A header cell with data-sort="<key>" gets a button inside it and aria-sort on itself (ascending, descending, none). A click, Enter or Space emits glk-table-sort { key, direction } — ascending for a new column, then turning —, cancelable and before the state changes. The page sorts the rows, often on the server, and renders them; the element only shows the state, which sort and direction set.
Row actions. Cells with class="glass-table__actions" stay at the row’s end while the table scrolls sideways, on a surface of their own: a <glk-menu>, or icon buttons with a <glk-tooltip>. The wrap’s edges shade where more columns wait. Sort buttons and row actions are in the Tab order; there is no grid navigation with arrow keys.
Empty. While the body has no rows, the slot="empty" content — a <glk-empty> — shows below the header. Cards. Below list-below the element copies each header’s text into its column’s cells as data-label, and GlassKit shows it before the value; the actions move to the card’s top end, numbers keep their tabular figures. The header stays for assistive technology, hidden from view, and the table’s roles are set explicitly, so a screen reader still meets a table.
Events: glk-table-sort. Properties: sort, direction, stickyHeader, listBelow. Slots: default (the table), empty. Parts: wrap (the scroller), empty. GlassKit’s tokens reach the table: --gl-table-max-height, --gl-table-header-bg, --gl-table-cell-padding (9px 10px) and --gl-table-header-padding (8px 10px).
Sorting by drag and drop
sortable on <glk-list> or <glk-tree> lets the visitor reorder the items (since 1.32.0): with mouse and pen after a few pixels, by touch after a long press of 500 ms — before it a swipe scrolls the page —, and with the keyboard. A raised copy follows the pointer, a line shows where the item lands, an item that takes it inside lights up, and the others glide out of the way. Lists with the same group exchange items, and so do trees, but a list never with a tree; breadcrumbs of that group take items from both. Without a group a list or a tree keeps its items to itself, and breadcrumbs with drop-target and no group still take them. Items with container — in a tree also items with children — take others inside them; in a tree a closed one opens after a moment under the dragged item. Try it — move a page within the list, into “Services”, or onto “My app” in the path; “Main menu” stands for the list’s own level and takes none:
| Attribute | Component | Description |
|---|---|---|
sortable | glk-list, glk-tree | The items can be reordered |
group | glk-list, glk-tree, glk-breadcrumbs | A name: lists with the same one exchange items, trees too, and breadcrumbs with it take items from both |
drop-target | glk-breadcrumbs | The crumbs take items from sortable lists and trees without a group; drop-target and group may change at run time |
container | glk-list-item, glk-tree-item | Takes a dropped item inside it — a submenu |
no-drag | glk-list-item, glk-tree-item | Stays where it is; the others still move around it |
slot="handle" | glk-list-item, glk-tree-item | A grip: a pointer starts a drag only there, a finger at once; Space still picks the item up on its row, so an <svg> will do |
Keyboard: Space on an item picks it up, also where it has a handle (in a tree Enter still selects). Up and Down move it, Home and End to the ends; Right moves it into the item above, if that one takes items, Left out to the level above — from the top level onto the crumb of the level above —, both mirrored right to left. Space drops it, and the focus stays on it; Escape and Tab cancel. Every step is announced through a live region, and each item says how to move it.
In a shadow root (since 1.34.0): the item under the pointer is looked up in the root of each list or tree taking part, so a sortable list inside another element’s shadow root — the usual case in an app built of web components — takes drags by mouse and touch, and a group may span several roots. Until then only the keyboard sorted there. The folded levels of the “…” crumb take drops as well.
Items side by side (since 1.34.0) — the tiles of <glk-list grid>, or a layout of the page’s own — sort on the horizontal axis, mirrored right to left, with the line upright (GlassKit’s .is-sort-inline). Whether they stand side by side is read from the layout. The keyboard keeps the order of the items.
A sorter of the page’s own (since 1.34.0) uses the crumbs as drop targets too. dropTargetAt(x, y) on <glk-breadcrumbs> returns { item, index, current } for the crumb at a point of the viewport — item is its <glk-breadcrumb>, a folded level while the “…” menu is open —, { overflow: true } over “…”, or null. markDrop(target, { refused }) lights the crumb up while the drag is over it, or shows that it refuses the item; over “…” the menu opens after a moment, and markDrop(null) clears. The crumbs need drop-target or a group; the move on the drop is the page’s.
Events go to the element that owns the dragged item, each with via: 'mouse', 'touch' or 'keyboard'. glk-sort-start { item, from }; glk-sort-over { item, target, position } while the target changes, with position before, after or inside — cancelled, the target shows that it refuses the item, and a drop there does nothing; glk-sort { item, from, to, target, position } on the drop, cancelable and before anything moves, from and to as { container, index }; and glk-sort-cancel { item }, also for a drop back where the item came from. Not cancelled, the element moves the node itself; cancelled, the DOM is the page’s, which renders the new order from its state — the items glide into place either way. A drop on a crumb, or into a list’s container item, moves nothing: that level is not in the DOM, and the page moves the item there. The current crumb takes no drop from a list, since it stands for the list’s own level. If the page removes an item while it is dragged, the drag is cancelled.
Property messages on the list or tree translates the announcements: roleDescription and instructions are texts; pickedUp, moved, into, onto, dropped and cancelled are functions that get the label, the position, the size and the container. It applies at once, also to a list or tree that is sortable already. --gl-sort-duration (180 ms) and --gl-sort-easing (ease-out) time the glide; under prefers-reduced-motion nothing glides.
Build your own element
Since 1.14.0 the base classes are exported. A project element that extends GlkElement gets what every <glk-*> has: an open shadow root with GlassKit's stylesheet adopted (so .glass-btn & Co. work inside), the theme wrapper that follows data-theme and data-density, listeners re-armed when the element moves, and emit() for bubbling, composed events. GlkFormElement adds ElementInternals for native form participation. Try it — this button is a <demo-counter> defined on this page:
demo-count…
| Setup | Import |
|---|---|
| Bundle (ESM) | import { GlkElement, GlkFormElement } from '@jungherz-de/glasskit-elements'; |
| Per component | import { GlkElement } from '@jungherz-de/glasskit-elements/base.js'; — the very module the components import, so instanceof GlkElement holds across both. The per-component files leave @jungherz-de/glasskit/glasskit-styles.js external: a bundler resolves it, an import map needs an entry for it. Never next to the <script> bundle — that carries its own copy of the class. |
CDN / <script> | const { GlkElement } = GlassKitElements; |
Hooks: render() builds into this._wrapper; setupEvents() / teardownEvents() run on every connect / disconnect; onAttributeChanged(name, old, value) fires after the first render. Helpers: createElement(tag, classes, attrs), getBoolAttr() / setBoolAttr(), emit(name, detail). Return true from static get displayInline() for an inline element, and set static get observesLightDom() to have projectLightDom() re-run whenever light-DOM children change. Since 1.20.0, static get delegatesFocus() returning true hands the focus to the first field or button inside (on for GlkFormElement, and since 1.33.2 for <glk-button>, <glk-pill>, <glk-tab-item> and <glk-tab-accessory>), and a GlkFormElement whose get _validityField() returns its native field reports that field’s validity on the host after every setFormValue() and attribute change. Since 1.22.3, applyDisabled(disabled) hands the disabled state to the native controls: override it in a GlkFormElement. It runs after the first render and whenever the element’s own disabled or a <fieldset disabled> around it changes — no fieldset reaches into the shadow root by itself.
Building a complete website?
GlassKit Elements is the app layer of the GlassKit family – web components for application UIs. For complete marketing websites – sections, i18n, SEO – the intended path is GlassKit Web, the official Astro template built on the same design language. The pure-CSS foundation underneath both is GlassKit.