/playwright:computed-stylesfrom playwright
Extracts and compares computed CSS styles between baseline and dev/Storybook URLs using Playwright MCP evaluate calls. Pairs with visual-diff skill to pinpoint exact property mismatches for Tailwind fixes.
Ships in playwright. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Use Playwright MCP's evaluate to extract getComputedStyle() values from a baseline page and a current page, compare them property-by-property, and fix the differences with Tailwind classes.
visual-diff skill has identified pixel differences between two pagesvisual-diff first).vscode/mcp.jsonStorybook renders stories inside an iframe. You must access elements through it:
// Inside mcp_playwright_browser_evaluate
const iframe = document.querySelector('#storybook-preview-iframe');
const doc = iframe.contentDocument;
const cs = doc.defaultView.getComputedStyle.bind(doc.defaultView);
const element = doc.querySelector('nav');
const styles = cs(element);
For production or dev server pages, access elements directly:
const cs = window.getComputedStyle.bind(window);
const element = document.querySelector('nav');
const styles = cs(element);
This project uses Tailwind v4 with a custom theme in src/styles/bitovi-theme.css. Standard utility classes may not map to expected values. For example, text-xl in this project is 1.5rem (24px), not the standard 20px. Always verify with getComputedStyle() after applying Tailwind classes, and use arbitrary values like text-[20px] when standard classes don't produce the right output.
Tailwind v4 uses CSS layers, so class order in the HTML doesn't determine specificity the way it did in v3. If you apply both lg:text-teal-950 and lg:text-teal-600 to the same element, whichever comes later in the generated CSS wins, not whichever is last in the class attribute. To conditionally apply colors, use ternary expressions:
// WRONG: both classes always present, CSS layer order wins
className={`lg:text-teal-950 ${isActive ? 'lg:text-teal-600' : ''}`}
// RIGHT: only one color class at a time
className={isActive ? 'lg:text-teal-600' : 'lg:text-teal-950'}
Based on the visual-diff results, identify the regions with differences and map them to DOM elements. Build a list of element/property pairs to extract.
Common element targets:
| Region | Typical selector | Key properties |
|---|---|---|
| Nav container | nav, nav parent | height, padding, maxWidth, boxShadow, backgroundColor |
| Logo | nav img, nav svg | width, height |
| Nav items | nav ul > li | fontSize, fontWeight, color, lineHeight, margin, fontFamily |
| CTA button | button with CTA text | height, padding, borderRadius, backgroundColor, fontSize |
| Dropdown panel | [id^="dropdown-"] | backgroundColor, borderRadius, overflow, maxWidth |
| Card / list items | li, .card | margin, padding, fontSize, fontWeight, color, lineHeight |
| Headings | h1–h6, [class*="uppercase"] | fontSize, fontWeight, color, letterSpacing, textTransform |
| Links | a | color, fontSize, fontWeight, textDecoration |
Common properties to compare:
fontSize, fontWeight, fontFamily, lineHeight, letterSpacing, textTransform,
color, backgroundColor, borderRadius, boxShadow,
width, height, maxWidth, minHeight,
padding, margin, gap,
display, alignItems, justifyContent, flexDirection,
overflow, opacity
Navigate to the baseline URL and use mcp_playwright_browser_evaluate to extract all target properties in a single call. Return a structured object.
Template for production pages:
// mcp_playwright_browser_evaluate
() => {
const cs = window.getComputedStyle.bind(window);
// Find elements — use text content or structure, not brittle selectors
const nav = document.querySelector('nav');
// ... find other elements ...
return {
nav: {
height: cs(nav).height,
padding: cs(nav).padding,
maxWidth: cs(nav).maxWidth,
},
// ... other elements ...
};
}
Tips for finding elements on production pages:
querySelectorAll + .textContent filtering[class*="nav-icon"]getComputedStyle(el).display !== 'none'element.closest('li'), .parentElementNavigate to the current URL and run the same extraction. For Storybook, use the iframe access pattern.
Template for Storybook:
// mcp_playwright_browser_evaluate
() => {
const iframe = document.querySelector('#storybook-preview-iframe');
const doc = iframe.contentDocument;
const cs = doc.defaultView.getComputedStyle.bind(doc.defaultView);
const nav = doc.querySelector('nav');
// ... find other elements ...
return {
nav: {
height: cs(nav).height,
padding: cs(nav).padding,
maxWidth: cs(nav).maxWidth,
},
// ... other elements ...
};
}
Compare every extracted value. Build a table like:
| Element | Property | Baseline | Current | Match |
|---|---|---|---|---|
| nav | height | 80px | 60px | NO |
| nav | padding | 0px 128px | 0px 32px | NO |
| nav item | fontSize | 20px | 24px | NO |
| nav item | fontWeight | 600 | 600 | YES |
Focus on the mismatches.
For each mismatch, determine the correct Tailwind class. Prefer standard utilities; use arbitrary values when the theme doesn't have an exact match.
| Desired value | Tailwind approach |
|---|---|
| Standard spacing (4px, 8px, 16px...) | p-1, p-2, p-4 etc. |
| Non-standard spacing | p-[13px], m-[38px] |
| Standard colors in theme | text-teal-600, bg-teal-950 |
| Box shadows | shadow-[0_0_24px_-4px_rgb(191,197,198)] |
| Font sizes matching theme | Check bitovi-theme.css @theme block first |
| Font sizes not in theme | text-[20px] |
After applying changes, re-extract computed styles from the current page and confirm the values now match the baseline. This is critical because:
Work through the diff table systematically. After fixing a batch of related properties (e.g., all nav container styles), re-extract and verify before moving to the next batch.
For efficiency, extract all properties in a single evaluate call rather than making many small calls. Here's a pattern for extracting a full nav component:
() => {
const cs = window.getComputedStyle.bind(window);
const props = (el) => !el ? null : ({
fontSize: cs(el).fontSize,
fontWeight: cs(el).fontWeight,
fontFamily: cs(el).fontFamily.split(',')[0].trim(),
color: cs(el).color,
backgroundColor: cs(el).backgroundColor,
lineHeight: cs(el).lineHeight,
letterSpacing: cs(el).letterSpacing,
height: cs(el).height,
width: cs(el).width,
padding: cs(el).padding,
margin: cs(el).margin,
borderRadius: cs(el).borderRadius,
boxShadow: cs(el).boxShadow,
});
const nav = document.querySelector('nav');
// ... find elements ...
return {
nav: props(nav),
// ... other elements ...
};
}
Storybook iframe: Always access through #storybook-preview-iframe. Queries on the top-level document won't find story content.
Multiple matching elements: Production pages often have duplicate elements (mobile vs desktop nav). Filter by display !== 'none' or check for the presence of child elements unique to the visible version.
React state in Storybook: You cannot trigger React state changes via dispatchEvent inside evaluate. Use Storybook story variants (e.g., --services-dropdown-open) or the play function in stories to set the desired state.
Color format differences: rgb(0, 132, 139) and #00848B are the same color. Compare numerically if needed, but getComputedStyle always returns rgb() or rgba() format on both sides.
Subpixel rendering: Values like 37.6406px vs 38px are acceptable matches. Don't chase fractional pixel differences.
Font family strings: getComputedStyle returns the full stack (e.g., Inter, sans-serif). Split on comma and compare only the first family.
No files are created on disk. All data lives in the evaluate return values and the conversation context.
What SKILL.md sets; muted values are Claude Code's defaults
8 skills in this plugin
/debug-e2e-testDebug and fix failing Playwright E2E tests. Use when tests fail, when asked to fix failing tests, or when investigating test failures. Analyzes test output, screenshots, error context, and uses Playwright MCP to identify root causes./debuggingAlways start a fresh browser session after any file change, walk through the full user flow, and monitor for errors before proceeding with further work./discover-visual-statesDiscover all visual states of a component by interactively exploring the production baseline page — not by reading story files. Finds every interactive element (nav items, dropdowns, toggles, buttons) that produces a distinct visual state, records the interactions needed to reach each one, and saves a pixel-perfect.config.json that the pixel-perfect skill uses to replay those same interactions on both production and Storybook. Run this once per component; re-run when the production page changes.npx claudepluginhub bitovi/ai-enablement-prompts --plugin playwrightOther plugins' skills for the same job