
Pseudo Elements
SkillAudits CSS and JavaScript for pseudo-element and View Transitions API practices: content, positioning and z-index of ::before and ::after, replacing extra DOM nodes, expanding hit targets, naming and cleaning up view-transition-name, and ::backdrop styling. Reports findings as file:line.
name: pseudo-elements
description: Audit CSS for pseudo-element best practices and View Transitions API usage. Use when reviewing hover effects, decorative layers, or page transitions. Outputs file:line findings.
license: MIT
metadata:
author: raphael-salaja
version: "2.0.0"
source: /content/taking-advantage-of-pseudo-elements/index.mdx
Pseudo Elements
Review CSS and JavaScript for pseudo-element best practices and View Transitions API usage.
How It Works
- Read the specified files (or prompt user for files/pattern)
- Check against all rules below
- Output findings in
file:lineformat
Rule Categories
| Priority | Category | Prefix |
|---|---|---|
| 1 | Before/After | pseudo- |
| 2 | View Transitions | transition- |
| 3 | Native Styling | native- |
Rules
Before/After Rules
pseudo-content-required
::before and ::after require content property to render.
Fail:
.button::before {
position: absolute;
background: var(--gray-3);
}
Pass:
.button::before {
content: "";
position: absolute;
background: var(--gray-3);
}
pseudo-over-dom-node
Use pseudo-elements for decorative content instead of extra DOM nodes.
Fail:
<button className={styles.button}>
<span className={styles.background} /> {/* Unnecessary DOM node */}
Click me
</button>
Pass:
<button className={styles.button}>
Click me
</button>
.button::before {
content: "";
/* decorative background */
}
pseudo-position-relative-parent
Parent must have position: relative for absolute pseudo-elements.
Fail:
.button::before {
content: "";
position: absolute;
inset: 0;
}
/* .button has no position */
Pass:
.button {
position: relative;
}
.button::before {
content: "";
position: absolute;
inset: 0;
}
pseudo-z-index-layering
Pseudo-elements need z-index to layer correctly with content.
Fail:
.button::before {
content: "";
position: absolute;
inset: 0;
background: var(--gray-3);
}
/* Covers button text */
Pass:
.button {
position: relative;
z-index: 1;
}
.button::before {
content: "";
position: absolute;
inset: 0;
background: var(--gray-3);
z-index: -1;
}
pseudo-hit-target-expansion
Use negative inset values to expand hit targets without extra markup.
Fail:
<div className={styles.wrapper}> {/* Extra wrapper for hit target */}
<a className={styles.link}>Link</a>
</div>
Pass:
.link {
position: relative;
}
.link::before {
content: "";
position: absolute;
inset: -8px -12px;
}
View Transitions Rules
transition-name-required
Elements participating in view transitions need view-transition-name.
Fail:
document.startViewTransition(() => {
// No view-transition-name assigned
targetImg.src = newSrc;
});
Pass:
sourceImg.style.viewTransitionName = "card";
document.startViewTransition(() => {
sourceImg.style.viewTransitionName = "";
targetImg.style.viewTransitionName = "card";
});
transition-name-unique
Each view-transition-name must be unique on the page during transition.
Fail:
.card {
view-transition-name: card;
}
/* Multiple cards with same name */
Pass:
// Assign unique name only to transitioning element
element.style.viewTransitionName = `card-${id}`;
transition-name-cleanup
Remove view-transition-name after transition completes.
Fail:
sourceImg.style.viewTransitionName = "card";
document.startViewTransition(() => {
targetImg.style.viewTransitionName = "card";
});
// sourceImg still has name, causes conflict on next transition
Pass:
sourceImg.style.viewTransitionName = "card";
document.startViewTransition(() => {
sourceImg.style.viewTransitionName = "";
targetImg.style.viewTransitionName = "card";
});
transition-over-js-library
Prefer View Transitions API over JavaScript animation libraries for page transitions.
Fail:
import { motion } from "motion/react";
function ImageLightbox() {
return (
<motion.img layoutId="hero" /> // JS-based shared element transition
);
}
Pass:
function openLightbox(img: HTMLImageElement) {
img.style.viewTransitionName = "hero";
document.startViewTransition(() => {
// Native browser transition
});
}
transition-style-pseudo-elements
Style view transition pseudo-elements for custom animations.
Fail:
document.startViewTransition(() => { /* ... */ });
// Uses default crossfade
Pass:
::view-transition-group(card) {
animation-duration: 300ms;
animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
}
Native Styling Rules
native-backdrop-styling
Use ::backdrop pseudo-element for dialog/popover backgrounds.
Fail:
<>
<div className={styles.overlay} onClick={close} />
<dialog className={styles.dialog}>{children}</dialog>
</>
Pass:
dialog::backdrop {
background: var(--black-a6);
backdrop-filter: blur(4px);
}
native-placeholder-styling
Use ::placeholder for input placeholder styling, not wrapper elements.
Fail:
<div className={styles.inputWrapper}>
{!value && <span className={styles.placeholder}>Enter text...</span>}
<input value={value} />
</div>
Pass:
input::placeholder {
color: var(--gray-9);
opacity: 1;
}
native-selection-styling
Use ::selection for text selection styling.
Pass:
::selection {
background: var(--blue-a5);
color: var(--gray-12);
}
Output Format
When reviewing files, output findings as:
file:line - [rule-id] description of issue
Example:
components/button/styles.module.css:12 - [pseudo-content-required] ::before missing content property
components/lightbox/index.tsx:45 - [transition-over-js-library] Using motion layoutId instead of View Transitions API
Summary Table
After findings, output a summary:
| Rule | Count | Severity |
|---|---|---|
pseudo-content-required | 2 | HIGH |
pseudo-over-dom-node | 1 | MEDIUM |
transition-name-cleanup | 1 | MEDIUM |
References
Recursos relacionados

Transitions Polish
SkillPolishes existing motion against the transitions.dev token scale for duration, distance, scale, blur and easing, matching each value by what the motion does rather than the nearest number, with rules for open/close asymmetry, hover in and out, stagger and intent delays.
Jakubantalik/transitions.dev5.4k
12 Principles of Animation
SkillAudits animation code against Disney's 12 principles adapted for the web, checking timing, easing, physics and staging rules such as user-initiated motion under 300ms and ease-out entrances, and reports findings as file:line.
raphaelsalaja/skill41
Marquee Loop
SkillBuilds seamless infinite marquees for logos, testimonials, screenshots or tags by duplicating the item sequence and translating the track from 0 to -50%, with stable widths, faded edges, optional hover pause and reduced-motion handling.
MengTo/Skills6.8k
Animation On Scroll
SkillAdds scroll-reveal animations that fire when elements enter the viewport, using an IntersectionObserver snippet plus keyframes and a Tailwind arbitrary animation class; tune threshold, rootMargin, duration, delay and play-once behavior.
MengTo/Skills6.8k
Refine Live
SkillIn-chat fallback for the transitions.dev Timeline Inspector's Refine button: the agent long-polls a local relay and answers jobs with motion-token tweaks or a full transition recipe swap, and applies accepted changes. Idle polling costs credits, so the persistent CLI mode is preferred.
Jakubantalik/transitions.dev5.4k
Transitions.dev
SkillProvides twelve drop-in CSS transitions, including card resize, number pop-in, badges, dropdowns, modals, panel reveals, page slides, icon swaps, success checks and error shakes, configured through shared CSS custom properties with no framework dependency and reduced-motion guards.
Jakubantalik/transitions-dev46