Theme System Documentation
Architecture Overview
The styling is split into base structure (layout) and themes (visual styling):
Base Files (Structure Only)
vanilla-grid.css- Grid component layout, injected by<vn-grid>itselfstyles.css- App structure (grids, spacing, layout)
Theme Files (Visual Styling)
../_common/themes/app-{name}.css- The app theme the plain-JS samples share: page background, container, header, theme selector, loading overlay. Seesamples/_common/README.mdthemes/app-{name}.css(this folder) - The overlay for this app's own markup: tabs, the<header>and<footer>elements, controls, the person detail panel. It loads after the shared filevn-grid-{name}.css- Grid colors, fonts, shadows, borders. Shipped by the component insrc/vanilla-grid/themes/and loaded by<vn-grid>from itsthemeattribute — this app ships no grid CSS of its own
Available Themes
1. Default Theme (Purple Gradient)
Classic purple gradient design with vibrant colors:
- Colors: Purple gradients (#667eea, #764ba2)
- Style: Modern, vibrant, gradients
- Files:
themes/app-default.css
2. Google Material Theme
Inspired by Google Material Design:
- Colors: Google Blue (#1a73e8), clean neutral surfaces
- Style: Modern, clean, subtle elevation
- Typography: Roboto
- Files:
themes/app-material.css
3. SAP Fiori Theme
Based on SAP Fiori Design System:
- Colors: Fiori Blue (#0a6ed1), neutral grays
- Style: Clean, professional, enterprise
- Typography: '72' font family (SAP's typeface)
- Features:
- Alternating row backgrounds
- Minimal borders
- Subtle shadows
- High information density
- Files:
themes/app-fiori.css
4. IBM Carbon Theme
Based on IBM Carbon Design System:
- Colors: IBM Blue (#0f62fe), dark text (#161616)
- Style: Sharp, industrial, minimal
- Typography: 'IBM Plex Sans' font family
- Features:
- Dark headers (#161616)
- No rounded corners (sharp edges)
- No row striping (hover only)
- Elevation shadows
- High contrast
- Files:
themes/app-carbon.css
5. IBM Carbon Dark Theme
Based on IBM Carbon Design System (Dark Mode):
- Colors: IBM Blue 50 (#78a9ff), Gray 100 background (#161616)
- Style: Dark mode, high contrast, minimal
- Typography: 'IBM Plex Sans' font family
- Features:
- Dark backgrounds (#161616, #262626)
- Light text (#f4f4f4, #c6c6c6)
- No rounded corners (sharp edges)
- Dark row striping (hover only)
- Subtle shadows
- WCAG AA compliant contrast
- Files:
themes/app-carbon-dark.css
6. Glow UI Theme (Light)
Inspired by Glow UI:
- Colors: Indigo (#6366f1), neutral grays, soft elevation
- Style: Modern, soft 12px corners, subtle shadows
- Typography: 'Inter' font family
- Files:
themes/app-glow.css
7. Glow UI Dark Theme
Inspired by Glow UI (Dark Mode):
- Colors: Indigo 400 (#818cf8), neutral 900/950 surfaces (#0a0a0a / #171717)
- Style: Dark mode, soft 12px corners
- Typography: 'Inter' font family
- Files:
themes/app-glow-dark.css
8. Microsoft Fluent 2 Theme
Based on Microsoft Fluent 2:
- Colors: Communication blue (#0f6cbd), neutral surfaces
- Style: Compact 4px corners, Fluent depth shadows
- Typography: 'Segoe UI Variable' font family
- Files:
themes/app-fluent.css
9. Default Dark Theme
The dark twin of the Default theme:
- Colors: Dark purple gradient page (#1e1b4b → #2e1065), indigo-navy surfaces (#1a1b2e), light indigo accent (#a3b1ff)
- Style: The Default theme's rounded corners and pill tabs; the active tab keeps a saturated purple gradient (#4f5bd5 → #6d28d9)
- Features:
- The grid header stays a flat purple (#4f5bd5, white text)
- Native checkboxes rendered in dark mode
- Files:
themes/app-default-dark.css
10. Microsoft Fluent 2 Dark Theme
Based on the Microsoft Fluent 2 web dark theme tokens:
- Colors: Brand foreground (#479ef5), neutral dark surfaces (#141414 page, #292929 container, #1f1f1f header)
- Style: Compact 4px corners, Fluent depth shadows
- Typography: 'Segoe UI Variable' font family
- Files:
themes/app-fluent-dark.css
11. SAP Fiori Dark Theme
The dark twin of the SAP Fiori theme, based on the SAP Quartz Dark theme tokens:
- Colors: Brand (#91c8f6), dark list surfaces (#1c2228 page, #29313a container, #232931 header)
- Style: The SAP Fiori theme's square corners and tab underline
- Typography: '72' font family (SAP's typeface)
- Features:
- Native checkboxes rendered in dark mode
- Files:
themes/app-fiori-dark.css
12. Google Material Dark Theme
The dark twin of the Google Material theme, using the dark values of the same Google product palette:
- Colors: Google Blue 300 (#8ab4f8), Grey 900 surfaces (#202124 page, #292a2d container and header)
- Style: The Google Material theme's rounded corners and tinted active tab
- Typography: Roboto
- Features:
- Native checkboxes rendered in dark mode
- Files:
themes/app-material-dark.css
13. Apple Theme
Based on Apple's Human Interface Guidelines:
- Colors: System blue (#007aff), grouped background (#f2f2f7 page, #ffffff container, #f9f9fb header), hairline separators
- Style: 10px container corners, 8px controls, blue tab underline
- Typography: SF Pro (
-apple-system) font family - Files:
themes/app-apple.css
14. Apple Dark Theme
The dark twin of the Apple theme, using Apple's dark-appearance system colors:
- Colors: System blue (#0a84ff), black page, elevated surfaces (#1c1c1e container, #2c2c2e header and tabs)
- Style: The Apple theme's corners and tab underline
- Typography: SF Pro (
-apple-system) font family - Features:
- Native checkboxes rendered in dark mode
- Files:
themes/app-apple-dark.css
How to Switch Themes
Via the <vn-grid> Web Component
Grid themes are now managed by the <vn-grid> element. Set the theme attribute declaratively or switch at runtime:
<vn-grid id="peopleGrid" theme="material">
...
</vn-grid>
// Switch at runtime
document.getElementById('peopleGrid').setTheme('carbon-dark');
The app-level theme CSS is still loaded via two <link> tags in index.html,
the shared theme first, then this app's overlay:
<link id="appThemeLink" rel="stylesheet" href="../_common/themes/app-default.css">
<link id="appThemeOverlayLink" rel="stylesheet" href="themes/app-default.css">
Dynamic Theme Switching (JavaScript)
switchTheme(themeName) in modules/theme.js swaps the
two app theme <link href>s to ../_common/themes/app-<name>.css and
themes/app-<name>.css, and calls setTheme(name) +
refresh() on every <vn-grid> on the page, so one name drives both layers.
Creating New Themes
Step 1: Copy Templates
Copy the shared app-theme template, then this app's overlay template:
cp ../_common/themes/TEMPLATE-app-theme.css ../_common/themes/app-mytheme.css
cp themes/TEMPLATE-app-theme.css themes/app-mytheme.css
The shared file is used by every plain-JS sample, so northwind-customers-js
needs its overlay too (see samples/_common/README.md).
The grid needs a theme under the same name: either one of the fifteen built-ins,
or a custom one started from src/vanilla-grid/themes/TEMPLATE-vn-grid-theme.css
and registered with VanillaGridElement.registerTheme('mytheme', '<path>').
Step 2: Customize Colors
Edit your new theme files, focusing on:
- Primary colors (headers, buttons, highlights)
- Background colors (body, containers, rows)
- Border colors and styles
- Text colors and font families
- Shadow effects
Step 3: Test Theme
Add an <option value="mytheme"> to the #themeSelector dropdown in
index.html and pick it — switchTheme() loads both layers.
Design System Guidelines
SAP Fiori
- Primary: #0a6ed1 (Fiori Blue)
- Neutrals: #32363a (text), #6a6d70 (muted), #fafafa (backgrounds)
- Borders: 1px solid, minimal
- Shadows: Subtle, rare
- Border Radius: 0-0.25rem (mostly square)
- Typography: '72', Helvetica Neue
- Row Striping: Yes (alternating backgrounds)
SAP Fiori Dark
- Primary: #91c8f6 (Quartz Dark brand)
- Neutrals: #fafafa (text), #d3d7d9 (muted), #1c2228 / #29313a (backgrounds)
- Borders: 1px solid #3e4a58
- Shadows: Subtle, rare
- Border Radius: 0-0.25rem (mostly square)
- Typography: '72', Helvetica Neue
- Row Striping: Yes (alternating backgrounds)
IBM Carbon
- Primary: #0f62fe (IBM Blue)
- Neutrals: #161616 (text), #525252 (muted), #f4f4f4 (backgrounds)
- Borders: 1px solid #e0e0e0
- Shadows: Box shadows for elevation (0 2px 6px rgba(0,0,0,0.2))
- Border Radius: 0 (sharp corners)
- Typography: IBM Plex Sans
- Row Striping: No (hover only)
- Header: Dark (#161616) with light text
IBM Carbon Dark
- Primary: #78a9ff (IBM Blue 50 - adjusted for dark mode)
- Neutrals: #f4f4f4 (text), #c6c6c6 (secondary), #161616 (background)
- Surface: #262626 (Gray 90), #393939 (Gray 80)
- Borders: 1px solid #393939 (Gray 80)
- Shadows: Box shadows for elevation (0 2px 6px rgba(0,0,0,0.8))
- Border Radius: 0 (sharp corners)
- Typography: IBM Plex Sans
- Row Striping: No (hover only)
- Header: Dark gray (#262626) with light text
- Hover: #262626 (Gray 90) for body rows
Google Material
- Primary: #1a73e8 (Google Blue 600)
- Neutrals: #202124 (text), #5f6368 (muted), #f6f8fc / #ffffff (backgrounds)
- Borders: 1px solid #dadce0
- Shadows: Subtle grey elevation
- Border Radius: 8-10px (containers), 16px (chips)
- Typography: Roboto
- Row Striping: Yes (alternating backgrounds)
Google Material Dark
- Primary: #8ab4f8 (Google Blue 300)
- Neutrals: #e8eaed (text), #9aa0a6 (muted), #202124 / #292a2d (backgrounds)
- Borders: 1px solid #5f6368
- Shadows: Black, subtle; elevation shown by lighter surfaces
- Border Radius: 8-10px (containers), 16px (chips)
- Typography: Roboto
- Row Striping: Yes (alternating backgrounds)
Theme Validation Checklist
When creating a new theme, ensure you style:
Grid Components
Grid styling is owned by the component's theme file, not this app — see the
required token set in src/vanilla-grid/themes/TEMPLATE-vn-grid-theme.css.
App Components
-
body- Background, font family -
.container- Background, shadow, border -
.tabs- Background, borders -
.tab-button- Colors, borders, radius -
.tab-button.active- Active state styling -
header- Background, text color - Form controls - Borders, backgrounds, focus states
- Buttons - Colors, hover, active states
-
.status- Info, success, error states -
footer- Background, text color
Best Practices
- Keep base files unchanged - Only edit theme files
- Use consistent spacing - Match design system grid (4px, 8px, etc.)
- Test accessibility - Ensure contrast ratios meet WCAG AA standards
- Mobile responsive - Test on small screens
- Browser compatibility - Test gradients, shadows, fonts
- Performance - Avoid heavy box-shadows on many elements
Troubleshooting
Theme not applying
- Check file paths in
<link>tags - Verify the CSS files exist in
../_common/themes/and in thisthemes/folder - Check browser console for 404 errors
- Clear browser cache
Partial styling
- Ensure the app theme name matches a grid theme the
<vn-grid>can resolve - Check CSS specificity (theme styles should override base)
- Verify no
!importantrules in base files
Conflicting styles
- Load base files before theme files
- Keep only one theme active at a time
- Use browser DevTools to inspect applied styles