12-principles-of-anima…
Audit animation code against Disney's 12 principles adapted for web. Use when reviewing motion, implementing animations, or…
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.
$ npx -y skills add raphaelsalaja/skill --skill pseudo-elements --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/pseudo-elementsContext preview
The summary Claude sees to decide when to auto-load this skill.
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.
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
Review CSS and JavaScript for pseudo-element best practices and View Transitions API usage.
1. Read the specified files (or prompt user for files/pattern) 2. Check against all rules below 3. Output findings in `file:line` format
| Priority | Category | Prefix | |----------|----------|--------| | 1 | Before/After | `pseudo-` | | 2 | View Transitions | `transition-` | | 3 | Native Styling | `native-` |
::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);
}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 */
}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-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;
}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;
}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";
});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}`;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";
});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
});
}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);
}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);
}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;
}Use ::selection for text selection styling.
**Pass:**
::selection {
background: var(--blue-a5);
color: var(--gray-12);
}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 layo
A skill file based on the articles written on userinterface.wiki. Designed for designers and engineers to help them build better user interfaces.
Audit animation code against Disney's 12 principles adapted for web. Use when reviewing motion, implementing animations, or…
Audit Web Audio API code for sound synthesis best practices. Use when reviewing procedural audio, implementing UI sounds, or…
Audit Motion/Framer Motion code for AnimatePresence best practices. Use when reviewing exit animations, modals, or presence…
Build icon components where any icon morphs into any other through SVG line transformation. Use when asked to "create morphing…
Audit UI code for audio feedback best practices. Use when reviewing sound implementation, checking audio UX decisions, or…
Audit animation code for correct timing function selection. Use when reviewing motion implementations, debugging animations that…