Admin Design Tokens
CSS custom properties (--adm-*) for the Cartly admin panel. Use these tokens in embedded apps and App Bridge extensions to match the admin's visual language across light and dark modes.
Overview
The Cartly admin panel (v1.16+) uses a token-based design system. All colours, spacing, typography, and border values are expressed as CSS custom properties prefixed with --adm-. These tokens are defined on the .cartly-admin class and cascade to all children — including embedded app iframes that receive the token map via postMessage.
The token set supports dark mode (default) and light mode. The active mode is stored in localStorage under the key cartly-admin-theme and applied as a data-theme attribute on <html>.
--adm-* Token Reference
Colours — Background
| Token | Dark value | Usage |
|---|---|---|
--adm-bg-canvas | #0a0a0a | Outermost page background |
--adm-bg-surface | #111111 | Cards, panels, sidebars |
--adm-bg-elevated | #1a1a1a | Modals, dropdowns, popovers |
--adm-bg-subtle | #1f1f1f | Hover states, stripes |
Colours — Text
| Token | Usage |
|---|---|
--adm-text-primary | Body copy, labels |
--adm-text-secondary | Meta text, descriptions |
--adm-text-tertiary | Placeholders, disabled |
--adm-text-inverse | Text on accent/danger fills |
Colours — Semantic
| Token | Usage |
|---|---|
--adm-accent | Primary action buttons, links |
--adm-accent-hover | Hover state for accent |
--adm-accent-fg | Text on accent background |
--adm-danger | Destructive actions, errors |
--adm-danger-hover | Hover state for danger |
--adm-warning | Warnings, amber badges |
--adm-success | Confirmations, green badges |
--adm-border | Dividers, card outlines |
--adm-border-subtle | Light separators inside cards |
Spacing
| Token | Value |
|---|---|
--adm-space-1 | 4px |
--adm-space-2 | 8px |
--adm-space-3 | 12px |
--adm-space-4 | 16px |
--adm-space-6 | 24px |
--adm-space-8 | 32px |
Typography
| Token | Value |
|---|---|
--adm-text-xs | 11px |
--adm-text-sm | 13px |
--adm-text-base | 14px |
--adm-text-lg | 16px |
--adm-font-normal | 400 |
--adm-font-medium | 500 |
--adm-font-semibold | 600 |
Border Radius
| Token | Value |
|---|---|
--adm-radius-sm | 4px |
--adm-radius-md | 6px |
--adm-radius-lg | 8px |
--adm-radius-xl | 12px |
--adm-radius-full | 9999px |
/* Use --adm-* tokens to match the Cartly admin visual language */
.my-app-sidebar {
background: var(--adm-bg-surface);
border: 1px solid var(--adm-border);
border-radius: var(--adm-radius-md);
color: var(--adm-text-primary);
}
.my-app-button {
background: var(--adm-accent);
color: var(--adm-accent-fg);
padding: var(--adm-space-2) var(--adm-space-4);
border-radius: var(--adm-radius-sm);
font-size: var(--adm-text-sm);
font-weight: var(--adm-font-medium);
}
.my-app-button:hover {
background: var(--adm-accent-hover);
}
.my-app-danger-zone {
border-color: var(--adm-danger);
color: var(--adm-danger);
}cartly-admin Wrapper
Critical: the --adm-* tokens are scoped to the .cartly-admin CSS class. Any element that uses these tokens must be a descendant of an element with this class. Without the wrapper, the custom properties resolve to initial (empty string in most browsers) and the UI will render unstyled.
All admin routes in the Cartly admin panel are wrapped in <div class="cartly-admin"> in frontend/app/routes/admin.tsx. If your embedded app renders in a separate context (e.g. a full-screen app frame or a custom iframe), you must add the wrapper class yourself.
<!-- CORRECT: wrap admin content in .cartly-admin -->
<!-- Without this class, --adm-* tokens resolve to initial (undefined). -->
<div class="cartly-admin">
<div class="my-embedded-panel">
<!-- tokens work here -->
</div>
</div>
<!-- In React (embedded app iframe via App Bridge): -->
import { useEffect } from 'react';
export function AppPanel({ children }) {
// The host frame sets data-theme="dark"|"light" on the cartly-admin
// wrapper based on the merchant's preference. Your iframe inherits
// the CSS variables via the postMessage theme token push — apply
// them to your root element.
useEffect(() => {
// cartly-bridge.js calls this when theme changes
window.CartlyBridge?.onThemeChange((tokens) => {
const root = document.documentElement;
Object.entries(tokens).forEach(([k, v]) => root.style.setProperty(k, v));
});
}, []);
return <div className="cartly-admin">{children}</div>;
}Theme Bridge
The admin supports dark and light modes. The active theme is stored in localStorage (key: cartly-admin-theme) and applied as data-theme="dark" | "light" on <html>.
A pre-paint inline script in <head> reads localStorage and sets the attribute before React hydrates — preventing a flash-of-wrong-theme. A post-mount useEffect in AdminThemeBridge.tsx then re-applies and keeps it in sync with user preference changes.
When the merchant changes theme in the admin topbar, the new preference is written to localStorage and the attribute is toggled immediately via the bridge component — no page reload.
// Theme bridge — how Cartly admin handles dark/light mode.
//
// Problem: React hydrates on the server with class="light" baked in.
// After hydration React sets the class per JSX — but by then the page
// has already painted with the wrong tokens, causing a flash.
//
// Solution: two-phase approach
// Phase 1 — pre-paint script in <head> reads localStorage and sets
// data-theme on <html> BEFORE React loads.
// Phase 2 — post-mount useEffect in AdminThemeBridge.tsx re-applies
// the theme attribute and persists changes to localStorage.
//
// Source: frontend/app/components/admin/AdminThemeBridge.tsx
// frontend/app/root.tsx (inline script in <head>)
// Pre-paint script (inlined in HTML <head>, runs synchronously):
(function() {
try {
var t = localStorage.getItem('cartly-admin-theme') || 'dark';
document.documentElement.setAttribute('data-theme', t);
} catch(e) {}
})();
// Post-mount hook (in AdminThemeBridge component):
useEffect(() => {
const saved = localStorage.getItem('cartly-admin-theme') ?? 'dark';
document.documentElement.setAttribute('data-theme', saved);
}, []);Embedded Apps
Apps embedded via App Bridge (iframe) receive the current --adm-* token map as a postMessage payload of type CARTLY_THEME_TOKENS on load and on every theme change. Apply the received tokens to your iframe's root element to stay in sync with the host admin panel:
window.addEventListener('message', (e) => {
if (e.data?.type !== 'CARTLY_THEME_TOKENS') return;
const root = document.documentElement;
Object.entries(e.data.tokens).forEach(([k, v]) => {
root.style.setProperty(k, v);
});
});For full-screen app routes (routes that render outside the standard admin layout), wrap your content in .cartly-admin and set data-theme yourself based on the received tokens or the localStorage value.
See App Bridge documentation for the full postMessage protocol.