Communitygithub.com

Kit d'interface en verre dépoli

Verre dépoli et mouvement calme, sans marque imposée, pour pages d'atterrissage, portfolios, boutiques et tableaux de bord. CSS simple, un peu de JavaScript, couleurs en attente.

Qu'est-ce que Kit d'interface en verre dépoli ?

Barres vitrées, feuilles, boutons, révélations au défilement, dialogues, compteurs et ouverture de logo. Le mouvement reste sur l'opacité et les transformations.

Compatible avec~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/KaanPehlivan/glass-ui/tree/HEAD/skills/glass-ui

Demander à votre IA préférée

Ouvre une nouvelle conversation avec cette compétence d'agent déjà préchargée.

Documentation

Glass and motion

A brand-neutral kit: brand-tinted frosted glass over a wallpaper, and calm, tuned motion. It is plain CSS plus a little plain JS, with no dependencies and no build step. It works on any stack that can load a stylesheet and a script.

Nothing in it belongs to one project:

  • Every colour is a placeholder variable.
  • The demo's content is generic.
  • Layout sizes (bar heights, rail width, save-bar offsets) are variables or live in the demo.

The motion values came out of a production panel, where they were tuned by eye. Each project brings its own brand, fonts and layout.

Files

FileWhat it holds
glass-ui.cssTokens, wallpaper, glass, press and hover, controls, page rise, dialogs, save pill, data motion, the opening, reduced-motion and reduced-transparency fallbacks
glass-ui.jswindow.GlassUI: swapLook (theme or wallpaper cross-fade), slideMarker, countUp, riseOnView and RISE_HEAD_SCRIPT, whenRisen, replay, playOpening and OPENING_HEAD_SCRIPT
react.mdmotion/react versions (layoutId marker, CountUp, live list, tour springs), the opening in Next.js, Tailwind v4 mapping
demo.htmlEvery piece on one page (except the donut fade). Open it to see the target feel, and copy its markup
contrast.mjsThe contrast check for a palette (node contrast.mjs)

Fit it to the project

Pick the pieces by the kind of project. Don't put the full set everywhere.

ProjectPieces
Landing page, corporate site, portfoliowallpaper, a .glass sticky nav, press, card hover, link cards with arrow nudge, data-rise on the first screen, data-rise data-rise-view on each section below it, dialogs; maybe the opening on the home page only
Shop, booking, cataloguethe above plus .popover (filters, dates), a cart or filter <dialog> (a .sheet on phones), .value-in on totals, skeletons, .seg with the sliding marker for variants and tabs
Dashboard, panel, SaaSthe full set: .glass-sheet, a .glass-rail side nav or phone tab bar with the sliding marker, save pill, switches, count-up, chart motion, live feed, theme and wallpaper swap

Sites without an app shell (the first two rows) have no page sheet: put data-no-sheet on <html>.

  • Cards stay at 92%, and the pattern isn't faded under the header.
  • A photo wallpaper keeps the firm veil at every width; without it, hero text fails contrast.
  • A firm veil hides most of the photo, so on these sites the mark or pattern wallpaper usually shows more.

Any stack

  • Plain HTML, WordPress, Shopify, Webflow, Squarespace custom code:
    • Add glass-ui.css to the theme's stylesheet.
    • Load glass-ui.js in <head> and call GlassUI.riseOnView() there.
    • Put the classes in the templates.
  • React, Next.js, Remix: see react.md (motion/react versions, head scripts, Tailwind v4).
  • Vue, Nuxt, Svelte, SvelteKit, Astro, Angular:
    • Import glass-ui.css once, globally.
    • Put the head scripts in the app's HTML shell or head component.
    • Call slideMarker() / swapLook() / countUp() after render (onMounted, onMount, a client script).
    • The CSS animations need nothing from the framework.
  • CSS Modules, scoped styles, CSS-in-JS: the kit's classes are global by design. Load the file as a global stylesheet, or wrap it in :global(...), so hashing doesn't rename them.
  • Tailwind (any version): import the kit into the components layer, so utilities still win (react.md).
  • Right-to-left sites (dir="rtl"): the arrow nudge, switch knob and meters flip on their own.

Keep the project's own:

  • fonts (the kit sets none);
  • spacing;
  • breakpoints, where they differ: the kit uses 48rem / 64rem, so change those media queries to match;
  • radii (--gm-radius-*);
  • bar heights (--gm-top-bar, --gm-bottom-bar).

Apply it

  1. Look first. Open demo.html in a browser (default: the photo wallpaper; the play button replays the opening), so you know the result you are aiming for.

  2. Read the target project.

    • Find out how it styles (plain CSS, Tailwind v4, CSS modules) and whether it already uses React with motion.
    • Check every class the kit defines against the project. List them with grep -oE '^\.[a-z][a-z-]*' glass-ui.css | sort -u, then grep the project for each one, CSS libraries included (Bootstrap has .btn and .card). Rename the kit's class where one clashes.
    • Common clashes: .opening (the kit hides it), .card, .btn, .field, .reveal, .fade-in, .skeleton, .dragging, .sheet, .popover, .spin.
    • Global rules to know about:
      • the reduced-motion * rule cuts every animation on the site, the host's own included;
      • modal <dialog>s under data-gm pop in with a scrim, at zero specificity, so the host's own dialog classes win.
  3. Copy glass-ui.css into the project. Copy only the sections the site needs (see "Which pieces" below), and keep the comments that explain why. With Tailwind, import it into the components layer (react.md).

  4. Map the palette to the brand. Every brand value, in one pass:

    • the two palette blocks [data-gm="light"] and [data-gm="dark"], including --gm-pattern (one pre-tinted tile per theme, made from the brand's mark);
    • the desktop surface (84% / 82%, only under a sheet) in the @media block right after them;
    • in :root: --gm-rail (RGB triplet), --gm-curtain, --gm-curtain-text, --gm-curtain-muted, --gm-scrim, and the radii;
    • .wall-photo's sepia(0.5), which warms the photo; drop it for a cool brand;
    • .glass-rail's remapped text and selection colours;
    • .save-pill's glass in both themes.

    Rules:

    • The glass is tinted with the brand's page colour. It is not white, unless white is the brand.
    • --gm-shade, the shadows and the scrim use the brand's darkest colour. Never pure black.
    • One accent colour does all the actions.
    • "Hover" is a tint of the brand colour, not grey.
    • A light theme can use the brand's dark colour as its accent. A dark theme can use the brand's light or bright colour.

    Copy the same values into contrast.mjs, set its sheet flag, delete the theme or rail the site doesn't have, and run it.

  5. Never change the timing. Keep the durations, distances, stagger steps and curves as they are. They were tuned by eye, and the "why" lines below record what failed.

  6. Add the markup contracts. demo.html has each of these.

    • data-gm on <html>. Only there: any opaque wrapper between the wallpaper and the content hides the wallpaper.
    • A .wall layer.
    • data-rise on the page root, and data-rise-group on its top-level grid or form. data-rise moves its children, never itself, and the steps come from child order. A data-rise nested in another one takes the quicker tab-panel timing, unless it also has data-rise-view.
    • On long pages, also mark each section below the fold with data-rise and data-rise-view. Call GlassUI.riseOnView() in <head>, before the first paint: load glass-ui.js there, or inline RISE_HEAD_SCRIPT. Called later, the blocks have already risen unseen.
    • With a phone tab bar, put data-tabbar on <html> and set --gm-bottom-bar. Set --gm-top-bar to the header's height.
    • .pressable on everything tappable. .nudge or .nudge-back on a link, with .nudge-icon on its arrow.
    • The .save-dock markup. Set its bottom and left around the page's bars.
    • For the opening:
      • the .opening markup;
      • data-opening-target on the page's own logo. If that logo sits on a coloured disc (its parent's background), a coin in that colour grows under it as it lands;
      • OPENING_HEAD_SCRIPT inline in <head>, only on pages that have both of the above;
      • GlassUI.playOpening() after load.

    For JS, include glass-ui.js, or port the functions you need into the project's module. On React use react.md.

    Patterns the markup doesn't cover:

    • Count-ups and timers below the fold: start them with GlassUI.whenRisen(block, fn). It runs at once when nothing waits (reduced motion, no JS rise).
    • Filtering a grid: re-shown cards take their steps from nth-child, hidden ones included. Set --rise inline on the visible ones (0, 1, 2…), then replay them.
    • Popovers: the kit animates and frosts .popover. The page positions and dismisses it; the native popover attribute gives light dismiss.
    • A cart that is a sheet on phones and a modal on desktop: toggle .sheet before showModal(), by matchMedia("(max-width: 47.999rem)").
    • What the kit leaves to the page: padding and radius on .glass and .glass-rail elements, the layout, and the type scale.
  7. Run the check at the end of this file.

Which pieces

PieceClass or attributeValuesUse on
Wallpaper.wall with .wall-mark / .wall-pattern / .wall-photo + .wall-veil; choose one with data-wallphoto: blur 10px, sepia .5, scale 1.06; veil 50–62% (86–90% on phones)anything with glass; glass over a flat colour is invisible
Glass.glass (bars, pills)24px blur, saturate 1.3, 160° shine, 1px edge, glass 60–62%sticky top bar, floating controls
Page sheet.glass-sheet40px blur and 32px radius from 64rem; none on phonesthe content column of an app
Brand rail.glass-rail--gm-rail at 90%, 24px blur, tokens remapped insideside nav, phone tab bar, a brand-coloured sheet
Card.cardsurface 92% (84% from 64rem), 16px radius, hairline, low shadowcontent blocks; never nested
Press.pressable, .pressable-rowscale .97 (rows .985) in 90ms cubic-bezier(0.2,0,0,1); colours 160msevery button, link row, tile
Card hover.card-lift−2px and deeper shadow, 450ms --ease-smooth, both ways, mouse onlydashboard tiles, chart cards
Link card.card-link + .pressable−1px, deeper shadowa card that is one big link
Arrow nudge.nudge / .nudge-back + .nudge-icon2px, 200ms"See all →", "← Back"
Buttons.btn .btn-primary/-secondary/-ghost/-danger + .pressable44px pills; pending: .spin icon + disabledall actions
Field.field (also on <textarea>)44px, 16px text, hairline firms on hover, firmer fill on focus (150ms)inputs, selects, message boxes
Switch.switch (role="switch")knob 320ms --ease-spring, track 200mson/off settings
Segmented control.seg with a .slide-marker inside44px pills, 16px labels; the chosen one takes aria-selected, aria-pressed or aria-currenttabs, filters, Monthly/Yearly, product variants
Focus ringbuilt in under data-gm2px accent outline, 2px offset, follows each element's radiusevery control
Sliding marker.slide-marker + slideMarker() (React: layoutId)spring, response .32s, no bounceactive nav item, tabs, segmented control
Disclosure.chevron, details[open] > .reveal, .rise-inchevron turns 200ms; content rises 8px in 220ms (a nested detail row: 200ms)accordions, expandable rows, a status line that changes
Page risedata-rise, data-rise-group20px, 800ms --ease-smooth, 70ms apart, ≤6 steps, nested row left→right; tab panels 560ms / 50msevery page; the first screen of a long page
Scroll risedata-rise + data-rise-view, riseOnView()the page rise, started when the block scrolls into viewsections below the fold
Dialogany modal <dialog> under data-gmrise 8px + scale .98 in 220ms; brand-tinted scrim + 2px blur; the page behind stops scrollingmodals, ⌘K palette
Popover.popoverthe dialog's pop in 180ms; 24px blurdate picker, dropdown menu
Bottom sheet<dialog class="sheet">from the bottom edge, 360ms --ease-sheetphone "More" menu, pickers
Save pill.save-dock[data-open][data-done] > .save-pill.glassup 380ms, down 240ms ease-in; "Saved." holds 2.75s, then sinks over 450msedit forms
Count-upcountUp() / CountUp900ms cubic ease-outstat figures
Chart motion.grow-y, .grow-x, .grow-x-live, .fade-in, .fade-in-slowsee belowcharts, progress meters, top-N lists
Value change.value-infade 200ms (an overlay on a tile: 160ms)a preview figure that just changed
Live.live-dot, .row-in2.4s ping; new row drops 10px in 320mslive feeds
Skeleton, spinner.skeleton, .spinpulse 2s; spin 1sloading
Theme swapswapLook()view-transition cross-fadelight/dark, wallpaper picker
Opening.opening markup + OPENING_HEAD_SCRIPT + playOpening()logo writes in 800ms → flies to the page logo 650ms → page opens in a circle 900ms; about 2.4s; any key or press skipsan app's entrance, once per session

Chart motion values:

  • Columns grow over 500ms, each starting min(24, 250/n) ms after the previous one.
  • Meters fill over 700ms. .grow-x-live takes its value as transform: scaleX(v) on a full-width bar, so it also eases to a new value.
  • Value labels fade in over 300ms, after a 300ms delay.
  • Donut segments fade in over 600ms, 90ms apart.
  • Ranked rows use .rise-in at 260ms, 40ms apart (at most 10 rows), and each row's meter starts 120ms after its row.

Why it is built this way

These are the lessons behind the values. Keep them.

Glass

  • Blur goes on ::before, never on the element. A backdrop-filter makes the element the containing block of its position: fixed children, so a fixed save bar inside <main> would scroll away. For the same reason, .glass sets no position: each element sets relative, sticky or fixed itself.
  • Glass needs a wallpaper. Put a gradient, a big faint logo, a pre-tinted pattern or a blurred photo behind it. Over a flat colour, glass looks like a grey box.
  • Text never sits on bare glass. Cards stay near-solid (92%, 84% on the sheet), so text holds 4.5:1 over every wallpaper. Phones have no sheet, so a photo wallpaper gets a firm veil (86–90%).
  • Use pattern tiles, not a CSS mask. A repeating mask under glass left marks on text in Chrome. Use one pre-tinted tile image per theme.

Motion

  • Card motion uses --ease-smooth, both ways. A fast-start curve (--ease-out-soft) did most of a 2px lift in the first ~50ms and read as a snap. Small things that arrive (dialogs, rows, status text) keep --ease-out-soft.
  • The page rise is 20px over 800ms. A first try at 8px over 260ms went unnoticed.
  • The rise rules have zero specificity (:where). An element's own animation (a skeleton's pulse) wins, and so does the curtain's pause.
  • Hover is never a glow. Lights under the pointer were tried in five colours and all removed. A card only deepens its shadow and lifts at most 2px. Hover is for the mouse only (@media (hover: hover)), so a tap never leaves anything lit.
  • Exits are faster than entries. For example, the save pill comes up in 380ms and goes down in 240ms ease-in.
  • Use animation-fill-mode: backwards and animate only transform and opacity. Once done, no transform is left on a block, because a leftover transform also traps fixed children. Never animate layout properties (the marker's width is the one exception, kept small).
  • Run once on mount. A CSS animation on mount never replays on a re-render. A tab panel that comes back from display: none replays on purpose.
  • Below the fold, wait for the scroll. Otherwise the rise plays where no one sees it. Only JS sets the waiting state, so without JS (or under reduced motion) nothing is ever left hidden. A block counts as seen when any pixel of it is on screen, so even a short footer at the very end rises. In print, nothing waits.

Reduced settings

  • Reduced motion: one global rule cuts everything to 1ms, and hover lifts stay put. The "Saved." linger is the exception: it stays instead of vanishing, and infinite loops stop.
  • Reduced transparency: the glass becomes the solid page colour, the rail becomes solid brand, and dialogs, popovers and the scrim lose their blur. Cards stay near-solid as they are.

The opening

  • It plays once per browsing session, on a fresh navigation. It never plays on a reload, on Back, on the site's other pages, or under reduced motion.
  • A single-page app that should greet every new visit can drop the head script's two sessionStorage calls. An app can also replay it after sign-in (react.md).
  • Any key or press ends it, because a work tool must not hold people hostage.
  • The page's rise waits behind the curtain, so the cards come up inside the circle. Count-ups wait too: hold the figures at 0 under the curtain, then count as it opens (demo.html).
  • Without view transitions, the curtain fades instead.
  • With no visible target it gives up after 10s and fades. If the .opening markup is missing, it clears at once.

Check (all must pass)

  • Contrast. Run node contrast.mjs with the brand's values. Every text step must be at least 4.5:1: on a card, on the page sheet and on the veil, over the worst photo pixel, in both themes, and on the rail.
  • Widths. Look at phone (390), tablet (820) and desktop (1440), in light and dark, in a background browser tab. Fixed bars stay fixed inside the glass sheet, and nothing scrolls sideways.
  • Reduced motion. Emulate prefers-reduced-motion: reduce. Nothing travels, "Saved." stays, the opening doesn't play.
  • Reduced transparency. Emulate prefers-reduced-transparency: reduce. There is no blur anywhere.
  • Opening. While the curtain is up, the page's cards are paused at their start. They rise inside the circle.
  • Scroll rise. A data-rise-view block below the fold is paused (its chart motion too) until it scrolls in, then rises. The last block on the page rises at the end of the scroll. With JS off it shows on load.
    • In tests, scroll in steps: a jump skips the blocks in between.
    • Take full-page screenshots after a scroll pass.
    • Under reduced motion data-risen is never set, because nothing waits.
  • Focus. Tab through the page: every control shows the accent ring.
  • Timing. Grep the project's copy for ms, cubic-bezier and linear(. Every value matches glass-ui.css.

Skills associés