This guide describes how to work with CSS in WP Rig.
Configuration & Features
Before writing or modifying CSS, you MUST reference the config/config.json.
CSS Preloading: Check dev.styles.preload for files automatically injected into every compiled CSS file (e.g., _custom-media.css). Avoid redundant @import statements for these files.
CSS Structure
Source files are in assets/css/src/ and processed by build-css.js.
All CSS files are built into assets/css/ if they are not prefixed with a _.
Common Style Tasks
Change the header styles
Edit assets/css/src/_header.css
Run npm run dev to rebuild and watch
Header styles are imported via global.css
Add a new CSS partial
Create assets/css/src/_yourfile.css
Import it in the relevant css file (ex. assets/css/src/global.css) with @import "_yourfile.css";
Run npm run dev to rebuild if dev server is not already running
Visual Verification (Ralph Loop)
For visual changes, use Playwright to ensure regressions are avoided:
Baseline: Run npm run test:e2e:screenshot -- SCREENSHOT_NAME="before-change.png" before editing styles.
Edit: Apply your CSS changes.
Verify: Run npm run test:e2e:screenshot -- SCREENSHOT_NAME="after-change.png" and compare the results in tests/e2e/specs/screenshot.spec.ts-snapshots/.
Component Focus: Use SCREENSHOT_SELECTOR to capture only the element you're styling (e.g., .site-header).
Conventions
CSS partials: Source files in assets/css/src/ should be prefixed with an underscore (e.g., _header.css) unless they are intended to be enqueued as standalone files (like content.css).
Conditional styles: Use inc/Styles/Component.php and the wp_rig_css_files filter to load styles only on pages that need them. For blocks, leverage enqueue_block_style() to load styles for specific blocks.
CSS variables: Use CSS variables for theme colors, spacing, and other design tokens. Define them in assets/css/src/_custom-properties.css and use them throughout the theme. For block-based or universal themes, these should be defined in theme.json.
Media queries: Use custom media queries to manage our responsive breakpoints and always reference these instead of statically writing media query values. Define them in assets/css/src/_custom-media.css. Our CSS build process adds these media queries to all CSS files.
CSS nesting: Use CSS nesting to organize styles and avoid deep selectors. Nesting should be used sparingly and only when necessary. Avoid nesting more than 3 levels deep.
CSS specificity: Avoid using high specificity selectors. Use BEM (Block Element Modifier) naming convention to keep selectors short and readable. Use utility classes sparingly and only when necessary. NEVER use !important and instead leverage specificity to override styles.
CSS comments: Use comments to explain complex styles or decisions. Keep comments concise and relevant. Avoid commenting on obvious code.
CSS formatting: Use consistent indentation and spacing. Follow the CSS style guide provided by the project. Avoid unnecessary whitespace and trailing commas.
CSS linting: Use a CSS linter to catch common mistakes and enforce best practices. Configure the linter to match the project's style guide and run it as part of the build process. WP Rig comes with stylelint configured.
CSS animations: Use CSS animations to enhance user experience and create smooth transitions. Keep animations short and avoid using them on elements that are frequently interacted with. Override animations with @prefers-reduced-motion media query to disable animations for users who prefer reduced motion.
CSS performance: Keep header, navigation, global styles and other styles likely to be needed above the fold separate from other styles to improve page load performance. 100% of the CSS should be loaded asynchronously.
1---2name: styles3description: WP Rig Styles & CSS4---5# WP Rig Styles & CSS67This guide describes how to work with CSS in WP Rig.89## Configuration & Features1011Before writing or modifying CSS, you **MUST** reference the `config/config.json`.1213* **CSS Preloading:** Check `dev.styles.preload` for files automatically injected into every compiled CSS file (e.g., `_custom-media.css`). Avoid redundant `@import` statements for these files.1415## CSS Structure1617Source files are in `assets/css/src/` and processed by `build-css.js`.18All CSS files are built into `assets/css/` if they are not prefixed with a `_`.192021## Common Style Tasks2223### Change the header styles24251. Edit `assets/css/src/_header.css`262. Run `npm run dev` to rebuild and watch273. Header styles are imported via `global.css`2829### Add a new CSS partial30311. Create `assets/css/src/_yourfile.css`322. Import it in the relevant css file (ex. `assets/css/src/global.css`) with `@import "_yourfile.css";`333. Run `npm run dev` to rebuild if dev server is not already running3435## Visual Verification (Ralph Loop)3637For visual changes, use Playwright to ensure regressions are avoided:38391. **Baseline**: Run `npm run test:e2e:screenshot -- SCREENSHOT_NAME="before-change.png"` before editing styles.402. **Edit**: Apply your CSS changes.413. **Verify**: Run `npm run test:e2e:screenshot -- SCREENSHOT_NAME="after-change.png"` and compare the results in `tests/e2e/specs/screenshot.spec.ts-snapshots/`.424. **Component Focus**: Use `SCREENSHOT_SELECTOR` to capture only the element you're styling (e.g., `.site-header`).4344## Conventions4546- **CSS partials**: Source files in `assets/css/src/` should be prefixed with an underscore (e.g., `_header.css`) unless they are intended to be enqueued as standalone files (like `content.css`).47- **Conditional styles**: Use `inc/Styles/Component.php` and the `wp_rig_css_files` filter to load styles only on pages that need them. For blocks, leverage enqueue_block_style() to load styles for specific blocks.48- **CSS variables**: Use CSS variables for theme colors, spacing, and other design tokens. Define them in `assets/css/src/_custom-properties.css` and use them throughout the theme. For block-based or universal themes, these should be defined in theme.json.49- **Media queries**: Use custom media queries to manage our responsive breakpoints and always reference these instead of statically writing media query values. Define them in `assets/css/src/_custom-media.css`. Our CSS build process adds these media queries to all CSS files.50- **CSS nesting**: Use CSS nesting to organize styles and avoid deep selectors. Nesting should be used sparingly and only when necessary. Avoid nesting more than 3 levels deep.51- **CSS specificity**: Avoid using high specificity selectors. Use BEM (Block Element Modifier) naming convention to keep selectors short and readable. Use utility classes sparingly and only when necessary. NEVER use !important and instead leverage specificity to override styles.52- **CSS comments**: Use comments to explain complex styles or decisions. Keep comments concise and relevant. Avoid commenting on obvious code.53- **CSS formatting**: Use consistent indentation and spacing. Follow the CSS style guide provided by the project. Avoid unnecessary whitespace and trailing commas.54- **CSS linting**: Use a CSS linter to catch common mistakes and enforce best practices. Configure the linter to match the project's style guide and run it as part of the build process. WP Rig comes with stylelint configured.55- **CSS animations**: Use CSS animations to enhance user experience and create smooth transitions. Keep animations short and avoid using them on elements that are frequently interacted with. Override animations with @prefers-reduced-motion media query to disable animations for users who prefer reduced motion.56- **CSS performance**: Keep header, navigation, global styles and other styles likely to be needed above the fold separate from other styles to improve page load performance. 100% of the CSS should be loaded asynchronously.
Run npx skillmds@latest add comeonoliver/styles in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
WP Rig Styles & CSS It is listed under Web & Frontend on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
ComeOnOliver (@comeonoliver) published this skill. Their other Agent Skills are listed on their SkillMD profile.