A site header with a Resources menu that opens a wide panel of links. Each tile lights up and plays its icon when you point at it.
Get the code
This demo also exists as a standalone project —
npm install && npm run dev, no changes needed.
npx giget@latest gh:lordicondev/ui-components/mega-menu#standalone mega-menu
Copies the mega-menu folder of the
standalone branch — where every demo lives
on its own — into ./mega-menu.
How it works
Define the element, put the icon in the markup, set the control's state. Then the parts that make this demo different.
Define the element Built-in triggers only. Apart from three lines for the chevron, this is the whole script.
import { defineElement } from '@lordicon/element';
// Registers <lord-icon> with its built-in triggers. The markup says what each icon does.
defineElement();
import { defineElement } from '@lordicon/element';
// Registers <lord-icon> with its built-in triggers. The markup says what each icon does.
defineElement();
The Resources button The browser opens and closes the panel; the chevron turns with it.
<!-- popovertarget opens and closes the panel. The chevron follows aria-expanded,
which main.ts keeps in step with the panel. -->
<button
class="nav__link nav__trigger"
type="button"
popovertarget="resources"
aria-expanded="false"
>
Resources
<lord-icon
class="nav__chevron"
current-color
src="icons/system-outline-33-chevron-down.json"
loading="interaction"
state="morph-direction"
trigger="follow(aria-expanded)"
target=".nav__trigger"
aria-hidden="true"
>
<img alt="" src="icons/system-outline-33-chevron-down.svg" />
</lord-icon>
</button>
Keep aria-expanded in step One listener writes the panel's state onto the button, where the chevron can follow it.
// The browser opens and closes the panel. The button's aria-expanded is kept in step, and
// the chevron follows it.
const panel = document.querySelector<HTMLElement>('#resources')!;
const trigger = document.querySelector<HTMLElement>('[popovertarget="resources"]')!;
panel.addEventListener('toggle', (event) => {
trigger.setAttribute('aria-expanded', String(event.newState === 'open'));
});
// The browser opens and closes the panel. The button's aria-expanded is kept in step, and
// the chevron follows it.
const panel = document.querySelector('#resources');
const trigger = document.querySelector('[popovertarget="resources"]');
panel.addEventListener('toggle', (event) => {
trigger.setAttribute('aria-expanded', String(event.newState === 'open'));
});
A tile Hovering anywhere on a tile plays its icon.
<!-- The whole tile is a link, and target makes it the icon's hover area. -->
<ul class="tiles">
<li>
<a class="tile" href="#">
<lord-icon
class="tile__icon"
current-color
src="icons/system-outline-3089-bar-chart-vertical.json"
loading="interaction"
trigger="hover"
target=".tile"
aria-hidden="true"
>
<img
alt=""
src="icons/system-outline-3089-bar-chart-vertical.svg"
/>
</lord-icon>
<span class="tile__title">Analytics</span>
<span class="tile__text"
>Real-time insights into how people use your
product</span
>
</a>
</li>
⋯
</ul>
Light up the whole tile The same look for the pointer and the keyboard.
/* The whole tile lights up, from the pointer or the keyboard. The icon keeps its grey. */
.tile:focus-visible {
background: var(--surface-muted);
}
@media (hover: hover) {
.tile:hover {
background: var(--surface-muted);
}
}
.tile__icon {
grid-row: span 2;
width: var(--icon-size-24);
height: var(--icon-size-24);
color: var(--ink-muted);
--icon-filter: var(--filter-ink-muted);
}
Slide down from under the header CSS alone animates the panel in and out, with transform only, so it stays smooth.
/* The sheet slides down from under the header, and back up faster. will-change keeps it
on one layer, so it does not flicker. allow-discrete keeps the panel shown while it
closes. */
.panel {
transition:
overlay 200ms allow-discrete,
display 200ms allow-discrete;
}
.sheet {
translate: 0 -100%;
transition: translate 200ms cubic-bezier(0.4, 0, 1, 1);
will-change: translate;
}
.panel:popover-open .sheet {
translate: 0 0;
transition: translate 340ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
@starting-style {
.panel:popover-open .sheet {
translate: 0 -100%;
}
}
Rows that drop in The tiles keep settling for a moment after the sheet has stopped.
/* The tiles and the card drop in a row at a time as the panel opens. On closing they
leave with the sheet. */
.panel :is(.tiles li, .featured) {
transition:
opacity 360ms ease-out var(--delay),
translate 520ms cubic-bezier(0.2, 0.8, 0.2, 1) var(--delay);
will-change: opacity, translate;
}
@starting-style {
.panel:popover-open :is(.tiles li, .featured) {
opacity: 0;
translate: 0 -10px;
}
}
Source files
The demo's own files, whole, at the paths the export uses.
index.html 263 lines
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Mega menu</title>
<link rel="stylesheet" href="./mega-menu.css" />
<script type="module" src="./main.ts"></script>
</head>
<body>
<header class="header">
<div class="bar">
<a class="logo" href="#"
><img src="./logo.svg" alt="Lordicon" width="132" height="25"
/></a>
<nav class="nav" aria-label="Main">
<a class="nav__link nav__link--extra" href="#">Product</a>
<a class="nav__link nav__link--extra" href="#">Pricing</a>
<!-- popovertarget opens and closes the panel. The chevron follows aria-expanded,
which main.ts keeps in step with the panel. -->
<button
class="nav__link nav__trigger"
type="button"
popovertarget="resources"
aria-expanded="false"
>
Resources
<lord-icon
class="nav__chevron"
current-color
src="icons/system-outline-33-chevron-down.json"
loading="interaction"
state="morph-direction"
trigger="follow(aria-expanded)"
target=".nav__trigger"
aria-hidden="true"
>
<img alt="" src="icons/system-outline-33-chevron-down.svg" />
</lord-icon>
</button>
</nav>
<div class="actions">
<a class="button button--quiet" href="#">Log in</a>
<a class="button button--primary" href="#">Get started</a>
</div>
</div>
<!-- The sheet inside the panel is what slides down. -->
<div class="panel" id="resources" popover>
<div class="sheet">
<div class="panel__inner">
<section class="links" aria-labelledby="resources-label">
<h2 class="links__label" id="resources-label">Resources</h2>
<!-- The whole tile is a link, and target makes it the icon's hover area. -->
<ul class="tiles">
<li>
<a class="tile" href="#">
<lord-icon
class="tile__icon"
current-color
src="icons/system-outline-3089-bar-chart-vertical.json"
loading="interaction"
trigger="hover"
target=".tile"
aria-hidden="true"
>
<img
alt=""
src="icons/system-outline-3089-bar-chart-vertical.svg"
/>
</lord-icon>
<span class="tile__title">Analytics</span>
<span class="tile__text"
>Real-time insights into how people use your
product</span
>
</a>
</li>
<li>
<a class="tile" href="#">
<lord-icon
class="tile__icon"
current-color
src="icons/system-outline-409-wrench.json"
loading="interaction"
trigger="hover"
target=".tile"
aria-hidden="true"
>
<img alt="" src="icons/system-outline-409-wrench.svg" />
</lord-icon>
<span class="tile__title">Automations</span>
<span class="tile__text"
>Build workflows without writing a line of code</span
>
</a>
</li>
<li>
<a class="tile" href="#">
<lord-icon
class="tile__icon"
current-color
src="icons/system-outline-11-link.json"
loading="interaction"
trigger="hover"
target=".tile"
aria-hidden="true"
>
<img alt="" src="icons/system-outline-11-link.svg" />
</lord-icon>
<span class="tile__title">Integrations</span>
<span class="tile__text"
>Connect with 100+ tools you already use</span
>
</a>
</li>
<li>
<a class="tile" href="#">
<lord-icon
class="tile__icon"
current-color
src="icons/system-outline-392-credit-card-back.json"
loading="interaction"
trigger="hover"
target=".tile"
aria-hidden="true"
>
<img
alt=""
src="icons/system-outline-392-credit-card-back.svg"
/>
</lord-icon>
<span class="tile__title">Payments</span>
<span class="tile__text"
>Accept payments in any currency, anywhere</span
>
</a>
</li>
<li>
<a class="tile" href="#">
<lord-icon
class="tile__icon"
current-color
src="icons/system-outline-4481-shield-heart.json"
loading="interaction"
trigger="hover"
target=".tile"
aria-hidden="true"
>
<img
alt=""
src="icons/system-outline-4481-shield-heart.svg"
/>
</lord-icon>
<span class="tile__title">Security</span>
<span class="tile__text"
>Enterprise-grade protection by default</span
>
</a>
</li>
<li>
<a class="tile" href="#">
<lord-icon
class="tile__icon"
current-color
src="icons/system-outline-3973-clipboard-bar-chart.json"
loading="interaction"
trigger="hover"
target=".tile"
aria-hidden="true"
>
<img
alt=""
src="icons/system-outline-3973-clipboard-bar-chart.svg"
/>
</lord-icon>
<span class="tile__title">Reporting</span>
<span class="tile__text"
>Export and share custom reports in seconds</span
>
</a>
</li>
<li>
<a class="tile" href="#">
<lord-icon
class="tile__icon"
current-color
src="icons/system-outline-21-avatar.json"
loading="interaction"
trigger="hover"
target=".tile"
aria-hidden="true"
>
<img alt="" src="icons/system-outline-21-avatar.svg" />
</lord-icon>
<span class="tile__title">Collaboration</span>
<span class="tile__text"
>Work together with your team in real time</span
>
</a>
</li>
<li>
<a class="tile" href="#">
<lord-icon
class="tile__icon"
current-color
src="icons/system-outline-369-code.json"
loading="interaction"
trigger="hover"
target=".tile"
aria-hidden="true"
>
<img alt="" src="icons/system-outline-369-code.svg" />
</lord-icon>
<span class="tile__title">Developer API</span>
<span class="tile__text"
>Flexible endpoints and webhooks for builders</span
>
</a>
</li>
<li>
<a class="tile" href="#">
<lord-icon
class="tile__icon"
current-color
src="icons/system-outline-2501-question-circle.json"
loading="interaction"
trigger="hover"
target=".tile"
aria-hidden="true"
>
<img
alt=""
src="icons/system-outline-2501-question-circle.svg"
/>
</lord-icon>
<span class="tile__title">Support</span>
<span class="tile__text"
>Professional help whenever you need it</span
>
</a>
</li>
</ul>
</section>
<aside class="featured" aria-labelledby="featured-title">
<p class="featured__eyebrow">Featured</p>
<h2 class="featured__title" id="featured-title">Discover what’s new</h2>
<p class="featured__text">
Explore the latest features, updates and resources – all in one
place.
</p>
<a class="button button--primary" href="#">Learn more</a>
</aside>
</div>
</div>
</div>
</header>
</body>
</html>
main.ts 13 lines
import { defineElement } from '@lordicon/element';
// Registers <lord-icon> with its built-in triggers. The markup says what each icon does.
defineElement();
// The browser opens and closes the panel. The button's aria-expanded is kept in step, and
// the chevron follows it.
const panel = document.querySelector<HTMLElement>('#resources')!;
const trigger = document.querySelector<HTMLElement>('[popovertarget="resources"]')!;
panel.addEventListener('toggle', (event) => {
trigger.setAttribute('aria-expanded', String(event.newState === 'open'));
});
import { defineElement } from '@lordicon/element';
// Registers <lord-icon> with its built-in triggers. The markup says what each icon does.
defineElement();
// The browser opens and closes the panel. The button's aria-expanded is kept in step, and
// the chevron follows it.
const panel = document.querySelector('#resources');
const trigger = document.querySelector('[popovertarget="resources"]');
panel.addEventListener('toggle', (event) => {
trigger.setAttribute('aria-expanded', String(event.newState === 'open'));
});
mega-menu.css 354 lines
@import '@shared/styles/index.css';
/* The header's height, so the panel can open right under it. */
:root {
--header-height: 73px;
}
.header {
position: sticky;
top: 0;
border-bottom: 1px solid var(--border-soft);
background: var(--surface);
}
/* Logo and links on the left, the two buttons on the right, 1200px at most. */
.bar {
display: flex;
align-items: center;
gap: var(--space-48);
max-width: calc(1200px + 2 * var(--space-32));
height: calc(var(--header-height) - 1px);
margin: 0 auto;
padding: 0 var(--space-32);
}
.logo {
display: flex;
}
.nav {
display: flex;
gap: var(--space-4);
}
.nav__link {
display: flex;
align-items: center;
gap: var(--space-4);
padding: var(--space-8) var(--space-12);
border: 0;
border-radius: var(--radius-md);
background: none;
color: var(--gray-700);
font-weight: 500;
text-decoration: none;
cursor: pointer;
}
.nav__trigger[aria-expanded='true'] {
background: var(--surface-muted);
}
/* Only under a mouse: on a touch screen :hover stays on after the tap. */
@media (hover: hover) {
.nav__link:hover {
background: var(--surface-muted);
}
}
/* On its own layer, so its animation does not repaint the header. */
.nav__chevron {
width: var(--icon-size-16);
height: var(--icon-size-16);
--icon-filter: var(--filter-ink-soft);
will-change: transform;
}
.actions {
display: flex;
gap: var(--space-8);
margin-left: auto;
}
.button {
padding: var(--space-8) var(--space-12);
border: 1px solid transparent;
border-radius: var(--radius-md);
font-weight: 500;
text-decoration: none;
white-space: nowrap;
}
.button--quiet {
border-color: var(--border);
background: var(--surface);
color: var(--ink);
}
.button--primary {
background: var(--accent);
color: var(--ink-inverse);
box-shadow: var(--shadow-accent);
}
/* Placed like a fixed element: full width, under the header. It only clips the sheet
inside, with room for its shadow, and lets clicks through. */
.panel {
position: fixed;
inset: var(--header-height) 0 auto;
width: auto;
margin: 0;
padding: 0 0 var(--space-48);
overflow: clip;
border: 0;
background: none;
pointer-events: none;
}
.sheet {
max-height: calc(100dvh - var(--header-height));
padding: var(--space-32) var(--space-32) var(--space-48);
overflow-y: auto;
border-bottom: 1px solid var(--border-soft);
background: var(--surface);
box-shadow: 0 12px 24px rgb(155 161 173 / 18%);
pointer-events: auto;
}
/* The sheet slides down from under the header, and back up faster. will-change keeps it
on one layer, so it does not flicker. allow-discrete keeps the panel shown while it
closes. */
.panel {
transition:
overlay 200ms allow-discrete,
display 200ms allow-discrete;
}
.sheet {
translate: 0 -100%;
transition: translate 200ms cubic-bezier(0.4, 0, 1, 1);
will-change: translate;
}
.panel:popover-open .sheet {
translate: 0 0;
transition: translate 340ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
@starting-style {
.panel:popover-open .sheet {
translate: 0 -100%;
}
}
/* The tiles and the card drop in a row at a time as the panel opens. On closing they
leave with the sheet. */
.panel :is(.tiles li, .featured) {
transition:
opacity 360ms ease-out var(--delay),
translate 520ms cubic-bezier(0.2, 0.8, 0.2, 1) var(--delay);
will-change: opacity, translate;
}
@starting-style {
.panel:popover-open :is(.tiles li, .featured) {
opacity: 0;
translate: 0 -10px;
}
}
/* When each row starts. */
.panel {
--delay: 140ms;
}
.featured {
--delay: 170ms;
}
.tiles li:nth-child(n + 4) {
--delay: 230ms;
}
.tiles li:nth-child(n + 7) {
--delay: 320ms;
}
@media (prefers-reduced-motion: reduce) {
.panel,
.sheet,
.panel:popover-open .sheet,
.panel :is(.tiles li, .featured) {
transition: none;
}
}
/* The tiles beside the featured card. */
.panel__inner {
display: grid;
grid-template-columns: 1fr 360px;
gap: var(--space-32);
max-width: 1200px;
margin: 0 auto;
}
.links {
display: flex;
flex-direction: column;
gap: var(--space-8);
}
.links__label {
margin: 0;
padding-left: var(--space-12);
color: var(--ink-muted);
font-size: var(--text-xs);
font-weight: 500;
line-height: var(--leading-xs);
text-transform: uppercase;
}
.tiles {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: var(--space-8);
margin: 0;
padding: 0;
list-style: none;
}
/* Icon on the left, the title and the line under it on the right. */
.tile {
display: grid;
grid-template-columns: auto 1fr;
gap: var(--space-4) var(--space-12);
height: 100%;
padding: var(--space-12);
border-radius: var(--radius-md);
color: var(--ink);
text-decoration: none;
}
/* The whole tile lights up, from the pointer or the keyboard. The icon keeps its grey. */
.tile:focus-visible {
background: var(--surface-muted);
}
@media (hover: hover) {
.tile:hover {
background: var(--surface-muted);
}
}
.tile__icon {
grid-row: span 2;
width: var(--icon-size-24);
height: var(--icon-size-24);
color: var(--ink-muted);
--icon-filter: var(--filter-ink-muted);
}
.tile__title {
font-weight: 600;
}
.tile__text {
color: var(--ink-muted);
font-size: var(--text-sm);
line-height: var(--leading-sm);
}
.featured {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: var(--space-12);
padding: var(--space-24);
border-radius: var(--radius-lg);
background: url('./featured.webp') center / cover;
}
.featured__eyebrow {
display: flex;
align-items: center;
gap: var(--space-8);
margin: 0;
color: var(--accent-ink);
font-size: var(--text-xs);
font-weight: 500;
line-height: var(--leading-xs);
text-transform: uppercase;
}
.featured__eyebrow::before {
content: '';
width: var(--space-8);
height: var(--space-8);
border-radius: var(--radius-pill);
background: var(--accent);
}
.featured__title {
margin: 0;
font-size: var(--text-xl);
font-weight: 600;
line-height: var(--leading-xl);
}
.featured__text {
margin: 0 0 var(--space-12);
color: var(--ink-soft);
font-size: var(--text-sm);
line-height: var(--leading-sm);
}
/* Narrower: two columns of tiles, and the card under them. */
@media (max-width: 1023px) {
.panel__inner {
grid-template-columns: 1fr;
}
.tiles {
grid-template-columns: repeat(2, 1fr);
}
}
/* Below 768px the full header does not fit. It keeps the logo, Resources and Get started. */
@media (max-width: 767px) {
.bar {
gap: var(--space-8);
padding: 0 var(--space-16);
}
/* The logo is the one thing that gives way, so the smallest phones fit too. */
.logo {
min-width: 0;
}
.logo img {
width: 106px;
max-width: 100%;
height: auto;
}
.nav__link--extra,
.button--quiet {
display: none;
}
.nav__trigger {
padding-inline: var(--space-8);
}
}
/* Phones: one column. */
@media (max-width: 639px) {
.sheet {
padding: var(--space-16) var(--space-16) var(--space-32);
}
.tiles {
grid-template-columns: 1fr;
}
}
What it imports 4 shared files
shared/styles/base.css 117 lines
/*
* Fonts, reset and default typography. Nothing control-specific: every demo styles its
* own control. Only the UI face is here; Inter and the mono face are the portal's.
*/
@font-face {
font-family: 'Figtree';
font-style: normal;
font-weight: 300 900;
font-display: swap;
src: url('../fonts/figtree-latin.woff2') format('woff2');
unicode-range:
U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308,
U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
font-family: 'Figtree';
font-style: normal;
font-weight: 300 900;
font-display: swap;
src: url('../fonts/figtree-latin-ext.woff2') format('woff2');
unicode-range:
U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113,
U+2C60-2C7F, U+A720-A7FF;
}
/* Arial with Figtree's measurements, for the moment before Figtree arrives, so the text does
not move when it does. Measured on Figtree at 400 and 500. */
@font-face {
font-family: 'Figtree fallback';
src: local('Arial'), local('Liberation Sans');
size-adjust: 100.3%;
ascent-override: 94.7%;
descent-override: 24.9%;
line-gap-override: 0%;
}
*,
*::before,
*::after {
box-sizing: border-box;
}
/* An author `display` on a component would beat the UA rule for [hidden], and then
`el.hidden = true` would stop working. Settled once here. */
[hidden] {
display: none !important;
}
body {
margin: 0;
background: var(--surface);
color: var(--ink);
--icon-filter: var(--filter-ink);
font-family: var(--font-ui);
font-size: var(--text-base);
line-height: var(--leading-base);
-webkit-font-smoothing: antialiased;
/* No grey flash on tap. Controls show their own :active and :focus-visible. */
-webkit-tap-highlight-color: transparent;
}
button,
input,
textarea,
select {
font: inherit;
color: inherit;
}
/* A second click on a button would otherwise select its label. */
button {
-webkit-user-select: none;
user-select: none;
}
:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
/*
* In the accessibility tree but not on screen: labels and legends that the visual design
* has no room for. Clipped rather than `display: none`, which would remove it from the
* tree too, and it also hides live radio inputs that must stay reachable by keyboard.
*/
.visually-hidden {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
}
/*
* Until the script defines <lord-icon> it is an unknown inline element with no size. These
* rules give it the box it will have, so nothing moves when it is defined.
*/
lord-icon {
display: inline-block;
width: var(--icon-size-32);
height: var(--icon-size-32);
}
/* A placeholder inside the icon fills it until the icon is ready. */
lord-icon:not(:defined) > img {
display: block;
width: 100%;
height: 100%;
}
/* Placeholders are black. Set --icon-filter wherever an icon's colour is set. */
lord-icon > img {
filter: var(--icon-filter);
}
shared/styles/index.css 4 lines
/* The one stylesheet a demo imports. */
@import './palette.css';
@import './tokens.css';
@import './base.css';
shared/styles/palette.css 87 lines
/*
* Generated from the Figma token export.
* Raw values only — roles live in tokens.css. Edit the Figma variables, not this file.
*/
:root {
/* color/ink */
--gray-0: #FFFFFF;
--gray-50: #F7F8FA;
--gray-100: #EEF0F3;
--gray-200: #DEE1E6;
--gray-300: #C3C7D0;
--gray-400: #9BA1AD;
--gray-500: #767C89;
--gray-600: #565C68;
--gray-700: #3D414B;
--gray-800: #282B33;
--gray-900: #16181D;
--gray-950: #0A0B0E;
/* color/signal */
--brand-100: #FFEEE9;
--brand-200: #FFD7CA;
--brand-300: #FFB199;
--brand-400: #FF7D5C;
--brand-500: #FF5A36;
--brand-600: #E8431F;
--brand-700: #C2340F;
/* color/success */
--green-100: #EDF9F1;
--green-300: #A7D9BC;
--green-700: #15803D;
/* color/error */
--red-100: #FDECEC;
--red-300: #F5B5B5;
--red-700: #DC2626;
/* typography/font */
--font-ui-name: 'Figtree';
--font-mono-name: 'JetBrains Mono';
/* typography/size */
--text-xs: 12px;
--text-sm: 14px;
--text-base: 16px;
--text-lg: 20px;
--text-xl: 24px;
--text-2xl: 32px;
--text-3xl: 40px;
/* typography/lineHeight */
--leading-xs: 16px;
--leading-sm: 20px;
--leading-base: 24px;
--leading-lg: 28px;
--leading-xl: 32px;
--leading-2xl: 40px;
--leading-3xl: 48px;
/* spacing (named after the value, the Figma scale is non-linear) */
--space-4: 4px;
--space-8: 8px;
--space-12: 12px;
--space-16: 16px;
--space-24: 24px;
--space-32: 32px;
--space-48: 48px;
--space-64: 64px;
--space-96: 96px;
/* size/icon */
--icon-size-16: 16px;
--icon-size-20: 20px;
--icon-size-24: 24px;
--icon-size-32: 32px;
--icon-size-40: 40px;
--icon-size-48: 48px;
--icon-size-64: 64px;
--icon-size-96: 96px;
/* radius */
--radius-sm: 4px;
--radius-md: 8px;
--radius-lg: 12px;
--radius-pill: 9999px;
}
shared/styles/tokens.css 93 lines
/*
* Design tokens by role. Raw values come from palette.css (generated); which grey is a
* border and which is muted text is decided here, and so would a dark mode be.
*/
:root {
/* Text. `--ink*` is always a colour; `--text-*` is always a size. */
--ink: var(--gray-950);
/* Text that reads as done or in progress, a step lighter than a heading. */
--ink-strong: var(--gray-800);
/* Body copy: a step down from --ink. */
--ink-soft: var(--gray-600);
--ink-muted: var(--gray-500);
--ink-subtle: var(--gray-400);
/* What has not started yet. */
--ink-faint: var(--gray-300);
--ink-inverse: var(--gray-0);
/* Backgrounds */
--surface: var(--gray-0);
--surface-muted: var(--gray-50);
/* A well inside a surface: the filled shape a single icon sits in. */
--surface-sunken: var(--gray-100);
/* Outlines */
--border: var(--gray-200);
/* The edge of a box that already has a fill, such as an input. */
--border-soft: var(--gray-100);
--border-strong: var(--gray-300);
--border-accent: var(--brand-400);
/* Brand accent */
--accent: var(--brand-500);
--accent-strong: var(--brand-600);
--accent-surface: var(--brand-100);
/* The outline of a tinted box, or a small shape on one. */
--accent-border: var(--brand-300);
/* Text or a mark on either of the above. */
--accent-ink: var(--brand-700);
/* Status. Warning rides the brand ramp — that is what the designs use. */
--success: var(--green-700);
--success-surface: var(--green-100);
--success-border: var(--green-300);
--warning: var(--brand-500);
--warning-surface: var(--brand-100);
--warning-border: var(--brand-300);
--danger: var(--red-700);
--danger-surface: var(--red-100);
--danger-border: var(--red-300);
/* Icons. Fed straight into --lord-icon-* by the demos. */
--icon-color: var(--gray-950);
--icon-accent: var(--brand-500);
/* Icon placeholders are black SVGs. Each filter turns black into the colour of the same
name. Made with a CSS filter generator: make a new one when its colour changes. */
--filter-ink: invert(2%) sepia(4%) saturate(4817%) hue-rotate(193deg) brightness(114%)
contrast(96%);
--filter-ink-soft: invert(33%) sepia(18%) saturate(323%) hue-rotate(182deg) brightness(100%)
contrast(90%);
--filter-ink-muted: invert(55%) sepia(23%) saturate(191%) hue-rotate(181deg) brightness(84%)
contrast(89%);
--filter-ink-subtle: invert(70%) sepia(11%) saturate(284%) hue-rotate(181deg) brightness(91%)
contrast(86%);
--filter-ink-faint: invert(76%) sepia(17%) saturate(99%) hue-rotate(184deg) brightness(99%)
contrast(100%);
--filter-ink-inverse: invert(100%);
--filter-accent: invert(49%) sepia(65%) saturate(3508%) hue-rotate(337deg) brightness(106%)
contrast(113%);
--filter-accent-strong: invert(29%) sepia(85%) saturate(1790%) hue-rotate(350deg)
brightness(94%) contrast(93%);
--filter-success: invert(38%) sepia(22%) saturate(2045%) hue-rotate(94deg) brightness(92%)
contrast(84%);
--filter-warning: var(--filter-accent);
--filter-danger: invert(48%) sepia(74%) saturate(7139%) hue-rotate(343deg) brightness(84%)
contrast(105%);
/* Type stacks. The families themselves are in palette.css. */
--font-ui:
var(--font-ui-name), 'Figtree fallback', -apple-system, BlinkMacSystemFont, 'Segoe UI',
Roboto, sans-serif;
--font-mono: var(--font-mono-name), ui-monospace, SFMono-Regular, Menlo, monospace;
/* Side padding of a page. The portal uses the same value, so demo and text line up. */
--gutter: clamp(var(--space-16), 5vw, var(--space-48));
/* A card's halo: no offset, so it reads as lift rather than as a light source. */
--shadow-sm: 0 0 7.5px color-mix(in srgb, var(--gray-400) 20%, transparent);
/* The same halo under a brand-coloured element. */
--shadow-accent: 0 0 7.5px color-mix(in srgb, var(--accent-strong) 40%, transparent);
}
Icons
Hover a row to play its icon. A state marked default plays without a
state attribute. The icons are under the
Lordicon License
Terms, not the MIT licence of the code.
| Preview | Lordicon icon | Animation state |
|---|---|---|
| system-outline-33-chevron-down |
morph-direction
|
|
| system-outline-3089-bar-chart-vertical |
hover-pinch default
|
|
| system-outline-409-wrench |
hover-pinch default
|
|
| system-outline-11-link |
hover-pinch default
|
|
| system-outline-392-credit-card-back |
hover-pinch default
|
|
| system-outline-4481-shield-heart |
hover-pinch default
|
|
| system-outline-3973-clipboard-bar-chart |
hover-pinch default
|
|
| system-outline-21-avatar |
hover-pinch default
|
|
| system-outline-369-code |
hover-pinch default
|
|
| system-outline-2501-question-circle |
hover-pinch default
|
When to use the Mega menu component
Use it on marketing sites and SaaS products with lots of resources, like docs, guides, blog and community. A wide panel shows each destination with a short description, and a featured card promotes your latest content. It keeps the header clean while making deep pages easy to find.
Accessibility
- A nav landmark labelled "Main" holds the top links and the Resources button. Every tile in the panel is one real link.
- The Resources trigger is a native button with
aria-expanded, and the panel closes with Escape. - Panel sections are labelled by their headings.
- Panel transitions switch off with
prefers-reduced-motion.