Repository navigation
Density tokens for control sizes, and a compact preset via data-density="compact" - #5
Merged
Merged
Conversation
The heights of fields, buttons, toggles, checkboxes, radios, list rows and modal actions were px literals in the component rules. A denser admin or desktop layout had to override a dozen selectors and keep the toggle's thumb, its travel and the first-line alignment in step by hand. They are tokens now, at the values GlassKit has always drawn and read with that value as fallback, as --gl-modal-max-width is: --gl-control-height, --gl-btn-height / -sm / -lg, --gl-textarea-min-height, --gl-list-item-min-height, --gl-toggle-width, --gl-toggle-height, --gl-toggle-thumb-size, --gl-check-size and --gl-modal-action-height. The thumb's inset ((height - thumb) / 2 - 1px, 3px as before) and travel (width - height) in both directions, the invisible inputs on top of the controls and the first-line margins of toggle, checkbox and radio are derived from them. --gl-control-padding-x and --gl-list-item-padding-y stay unset and fall back to --gl-space-md, like --gl-toast-top, so a spacing override still reaches fields and list rows wherever it is declared. The select keeps its :dir(rtl) padding pair, with the token on the text side. [data-density="compact"], after the theme blocks, sets 40px fields and buttons (sm 32, lg 48), 12px inside the fields, an 88px textarea, 48px list rows with 10px padding, a 44 x 26 toggle with an 18px thumb, 20px checkbox and radio, 44px modal actions. build-styles-js moves it into tokensCss with the theme blocks, so GlassKit Elements gets the values by inheritance and a project's own density values reach its shadow roots too. Measured in Chromium and WebKit against 1.20.0, left to right and right to left: without the attribute every control measures as before, and full-page screenshots of a test page in both themes and of index, showcase and docs (EN/DE) are pixel-identical outside regions that differ between any two renders; with it, the compact values at load and switched at runtime, the select's padding and chevron and the toggle's thumb mirrored, every label still centred on its first line. Docs and showcase (EN/DE), SKILL.md, README, theme-override.css.
dobexx
added a commit
that referenced
this pull request
Oct 5, 2026
Releases pull request #5: the control sizes of fields, buttons, toggle, checkbox, radio, list rows and modal actions are tokens, read with the old values as fallback, and data-density="compact" on <html> swaps in a denser set. Without the attribute every page renders pixel-identical to 1.20.0 (docs, showcase, index in English and German, both themes, left to right and right to left; Chromium and WebKit).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Control heights were px literals, so a denser layout (admin screens, desktop UIs, narrow forms) meant overriding a dozen selectors and keeping the toggle's thumb, its travel and the first-line alignment in step by hand. This PR turns the control sizes into tokens, with today's values as defaults, so nothing changes unless a page opts in, and adds a compact preset:
Tokens
--gl-control-height(input, select, search)52px40px--gl-control-padding-x(input, select, textarea)var(--gl-space-md)var(--gl-space-sm)--gl-btn-height/-sm/-lg56px/44px/64px40px/32px/48px--gl-textarea-min-height120px88px--gl-list-item-min-height56px48px--gl-list-item-padding-yvar(--gl-space-md)10px--gl-toggle-width×--gl-toggle-height52px×30px44px×26px--gl-toggle-thumb-size22px18px--gl-check-size(checkbox, radio)24px20px--gl-modal-action-height52px44px:root, [data-theme="dark"]block and read with today's value as fallback, the convention 1.20.0 uses for--gl-modal-max-widthand--gl-select-chevron. An older token sheet next to thiscomponentsSheet, or GlassKit Elements withdata-glk-defaults="off"and no stylesheet, keeps the old sizes.(height − thumb) / 2 − 1pxinside the track (3px at 52 × 30, as before) and travelswidth − height, from the right and to the left under:dir(rtl). The invisible inputs that lie on top of the controls since 1.20.0 take the same sizes, and the first-line margins of toggle, checkbox and radio use them, so any size stays aligned.--gl-toast-top: the rules fall back tovar(--gl-space-md), so a spacing override declared anywhere still reaches fields and list rows exactly as before. The select keeps its:dir(rtl)padding pair; the token takes the text side in both directions, the chevron's room stays with the chevron.--gl-list-item-padding-ymakes the compact list work: with 16px top and bottom padding a plain row is about 50px, so a 48px minimum would never show.Preset and stylesheet split
[data-density="compact"]is a bare attribute selector (like[data-theme="light"]) after the theme blocks.build-styles-js.mjssplits it intotokensCss/tokensSheetwith the theme blocks and fails if it is missing there or ifcomponentsCssdeclares a density token. GlassKit Elements adopts onlycomponentsSheetin its shadow roots and putstokensCsson the document, so the compact values reach every element by inheritance, and so does a project's own[data-density="compact"] { --gl-btn-height: 36px; }. InsidecomponentsSheetthe preset would re-declare the tokens in every shadow root and block such overrides. AglassSheetconsumer with adata-themeelement inside its shadow root mirrorsdata-densityonto it (SKILL.md); the companion GlassKit-Elements PR (JUNGHERZ/GlassKit-Elements#10) does that for its theme wrapper.Compatibility
:rootor a subtree reach field and list-row padding as before.data-theme="dark"element; keepdata-densityon<html>.Verification (Playwright 1.63, Chromium and WebKit, 1.20.0 vs. this branch)
data-density="compact"(at load and toggled at runtime): fields 40px with 12px inner padding, buttons 40/32/48, textarea 88, list rows 48 with or without a 28px icon, toggle 44×26 with an 18px thumb and equal end gaps in both directions, checkbox/radio 20 with their inputs exactly on top, modal actions 44. Underdir="rtl"the select's 12px move right with the chevron on the left; labels stay centred on their first line; removing the attribute restores every value.npm run build,npm run check:versionsandnpm run check:packagepass.Docs
README (Theming → Density, token list, cheat sheet), SKILL.md (density section after Right to Left, token table, rules,
tokensSheet, shadow-DOM pitfall), docs.html and de/docs.html (token table, Density section with live preview), showcase.html and de/showcase.html (density switch), theme-override.css (example), CHANGELOG (Unreleased).Release notes for the maintainer
## [Unreleased]; left untouched.