Skip to content

Animation & Motion

CSS Hover

Free

Implement hover, focus, and rest states in CSS before reaching for a motion library.

Difficulty foundational
Version v1.1

Purpose

Keep simple feedback in CSS so it is reliable and cheap.

Procedure

--- name: css-hover description: Implement hover, focus, and rest states in CSS before reaching for a motion library. ---

CSS Hover

Purpose

Keep simple feedback in CSS so it is reliable and cheap.

Procedure

Start in CSS. A transition on background-color, border-color, or color over 150ms is enough for cards, links, and quiet buttons.

Use :hover and :focus-visible as separate rules. Keyboard users need the focus ring even if they never hover. Do not remove the ring inside the hover rule.

Do not use :hover to reveal the only copy of a label. Tooltips that hide names fail on touch. If a control needs a name, the name is always visible or present as an accessible name.

Avoid transitioning box-shadow from none to a large shadow; it is expensive and shifts the visual weight. A border-color change is the default.

Media query prefers-reduced-motion: set transition-duration to 0ms on that element.

Do not add Framer Motion, GSAP, or Anime.js for this. If a later task needs presence or timeline control, that is a different skill.

Example requests

1. Card hover

Request: The skill card should feel responsive on hover using CSS Hover. No library. Expected: Border or background change only, with a short transition.

Dependencies

None. Work in the repository that is already open. Do not add packages unless the procedure names one.

Compatibility

This document follows the Agent Skills layout (a folder named css-hover containing SKILL.md). Claude Code, Cursor, Codex, and Gemini CLI can load that file from the paths in the Skilling installation guide. GitHub Copilot does not load SKILL.md. Use the Copilot instructions copy, and narrow applyTo before you commit it.

Example prompts

Card hover

The skill card should feel responsive on hover using CSS Hover. No library.

Expected: Border or background change only, with a short transition.

Choose the agent

This skill is installed for one agent at a time. Pick the section you are using.

Related

  • Press Feedback

    Give buttons and rows a pressed state that does not shift layout.

  • Tailwind Discipline

    Use the existing Tailwind tokens and scale. No arbitrary values, no copied utility salads.

  • Motion Rules

    Add motion only to explain a change: 150–250ms, ease-out, and a reduced-motion path.

Reviews

No reviews yet.

    Sign in to review.

    Report a problem

    Inaccurate steps, an unsafe instruction, or a licensing concern.

    Sign in to report.