Back to Ag Grid

Website CSS & Styling

external/ag-shared/prompts/skills/website-css/SKILL.md

100.0.02.8 KB
Original Source

Website CSS & Styling

This skill provides the CSS architecture, design system, and styling patterns for AG product websites.

Critical Rules

These rules apply to every SCSS/CSS file edit:

  1. Always import the design system: @use 'design-system' as *; at the top of SCSS files
  2. Use semantic variables (--color-bg-primary) — never raw colours (--color-gray-50) or hardcoded hex values
  3. Dark mode uses data-dark-mode: Use #{$selector-darkmode} & in SCSS or [data-dark-mode='true'] in CSS. Never use prefers-color-scheme
  4. Prefer standard utility classes over custom styles (layout, typography, colour classes)
  5. SCSS modules for components: Use .module.scss files with @use 'design-system' as *
  6. Test both light and dark modes for any visual changes

Sub-Documents

Load based on what you need:

DocumentPurposeWhen to Load
colour-palette.mdGrey, brand, warning, and special colour variablesChoosing colours or checking values
design-tokens.mdSpacing, breakpoints, typography, layout, radius, shadowsUsing spacing, responsive breakpoints, or typography tokens
utility-classes.mdLayout grid, typography, colour, and interaction utility classesUsing or choosing standard classes
dark-mode.mdDark mode patterns, SCSS/CSS/JS approaches, theme-aware componentsImplementing dark mode support

Design System Location

external/ag-website-shared/src/design-system/
FilePurpose
_root.scssAll CSS custom properties (colours, typography, layout, shadows)
core/_variables.scssSCSS variables (spacing, selectors, transitions)
core/_breakpoints.scssResponsive breakpoint values
_layout.scssLayout utility classes
_typography.scssTypography utility classes
_color.scssColour utility classes
_interactions.scssInteractive state classes
_base.scssBase element styles

Creating Custom Page Styles

Only create custom styles when standard classes don't meet your needs. Create SCSS modules in packages/<website-package>/src/pages-styles/:

scss
// my-page.module.scss
@use 'design-system' as *;

.heroSection {
    padding-top: $spacing-size-16;
    background-color: var(--color-bg-site-header);

    // Dark mode support
    #{$selector-darkmode} & {
        background-color: var(--color-bg-secondary);
    }

    // Responsive
    @media screen and (min-width: $breakpoint-hero-large) {
        padding-top: $spacing-size-24;
    }
}

Using Styles in Astro

astro
---
import styles from '@pages-styles/my-page.module.scss';
import classnames from 'classnames';
---

<div class={styles.pageContainer}>
    <section class:list={[styles.heroSection, 'layout-max-width-small']}>
        <h1 class="text-2xl">Title</h1>
    </section>
</div>