{"id":84,"date":"2026-10-18T17:53:18","date_gmt":"2026-10-18T17:53:18","guid":{"rendered":"https:\/\/refracttools.com\/blog\/?p=84"},"modified":"2026-10-18T17:53:18","modified_gmt":"2026-10-18T17:53:18","slug":"css-button-hover-effects","status":"publish","type":"post","link":"https:\/\/refracttools.com\/blog\/css-techniques\/css-button-hover-effects\/","title":{"rendered":"CSS button hover effects that feel good (and stay accessible)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Good CSS button hover effects are quick (around 0.2\u20130.5 seconds), animate only <code>transform<\/code>, <code>opacity<\/code> or shadows, run on keyboard focus as well as hover, and switch off for people who prefer reduced motion. Most of the effects that feel polished use a pseudo-element: a layer drawn with <code>::before<\/code> or <code>::after<\/code> that slides, fades or sweeps across the button.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This guide gives you four effects to copy, explains the technique behind each, and covers the accessibility details that are easy to miss.<\/p>\n\n\n\n<div class=\"wp-block-group is-style-refract-takeaways is-layout-constrained wp-block-group-is-layout-constrained\">\n<h3 class=\"wp-block-heading\">Key takeaways<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Animate <code>transform<\/code> and <code>opacity<\/code> for smooth effects; avoid animating width, height or padding.<\/li>\n\n\n<li>Always pair <code>:hover<\/code> with <code>:focus-visible<\/code>, and never remove the focus outline without replacing it.<\/li>\n\n\n<li>Wrap motion in <code>@media (prefers-reduced-motion: reduce)<\/code> so it can be switched off.<\/li>\n\n\n<li>Keep buttons at least 24 \u00d7 24 CSS pixels to meet WCAG 2.2&#8217;s minimum target size; larger is better.<\/li>\n\n\n<li>Hover doesn&#8217;t exist on touch screens, so the button must look clickable without the effect.<\/li>\n<\/ul>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">The technique behind most hover effects<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A button can only have one background, but its <code>::before<\/code> and <code>::after<\/code> pseudo-elements give you two extra layers to animate. Position one absolutely over the button, hide it with a transform, and move it into view on hover. Three supporting lines keep it tidy:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>position: relative<\/code> on the button, so the layer is positioned against it.<\/li>\n\n\n<li><code>overflow: hidden<\/code>, so the layer doesn&#8217;t spill outside the rounded corners.<\/li>\n\n\n<li><code>isolation: isolate<\/code>, which lets a layer with <code>z-index: -1<\/code> sit behind the label but in front of the button&#8217;s background.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Which effect suits which button?<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><div class=\"table-scroll\" tabindex=\"0\" role=\"region\" aria-label=\"Scrollable table\"><table><thead><tr><th>Button<\/th><th>Good fit<\/th><th>Why<\/th><\/tr><\/thead><tbody><tr><td>Main call to action<\/td><td>Shine sweep, fill slide<\/td><td>Noticeable without moving the layout<\/td><\/tr><tr><td>Secondary actions<\/td><td>Lift, underline<\/td><td>Quiet feedback that doesn&#8217;t compete<\/td><\/tr><tr><td>Dark or image backgrounds<\/td><td>Glass, glow, animated border<\/td><td>Stand out against busy or dark areas<\/td><\/tr><tr><td>Forms and dense UIs<\/td><td>Colour change only<\/td><td>Fast, predictable and easy to read<\/td><\/tr><\/tbody><\/table><\/div><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Use one hover style per type of button across the site. Mixing several effects on one page makes the interface feel inconsistent.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Effect 1: shine sweep<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A diagonal band of light slides across the button. It works on any colour and draws the eye to a main call to action.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.btn-shine {\n  position: relative;\n  overflow: hidden;\n}\n.btn-shine::before {\n  content: \"\";\n  position: absolute;\n  inset: 0;\n  background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, .45) 50%, transparent 70%);\n  transform: translateX(-120%);\n  transition: transform 0.5s cubic-bezier(.2, .8, .2, 1);\n  pointer-events: none;\n}\n.btn-shine:hover::before,\n.btn-shine:focus-visible::before {\n  transform: translateX(120%);\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Effect 2: fill slide<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A second colour fills the button from the left. Scaling a layer is smoother than animating its width.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.btn-fill {\n  position: relative;\n  overflow: hidden;\n  isolation: isolate;\n}\n.btn-fill::before {\n  content: \"\";\n  position: absolute;\n  inset: 0;\n  z-index: -1;\n  background: #16c79a;\n  transform: scaleX(0);\n  transform-origin: left;\n  transition: transform 0.35s ease;\n}\n.btn-fill:hover::before,\n.btn-fill:focus-visible::before {\n  transform: scaleX(1);\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Effect 3: animated gradient border<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A gradient border rotates around the button. Normally gradients can&#8217;t be animated, but registering a custom property with <code>@property<\/code> lets the browser animate its angle. <code>@property<\/code> has worked in all major browsers since July 2024; older ones show a static gradient border.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@property --angle {\n  syntax: \"&lt;angle&gt;\";\n  initial-value: 0deg;\n  inherits: false;\n}\n.btn-border {\n  border: 2px solid transparent;\n  border-radius: 12px;\n  background:\n    linear-gradient(#0b1020, #0b1020) padding-box,\n    conic-gradient(from var(--angle), #5ce1c6, #7a5cff, #ff6fb1, #5ce1c6) border-box;\n}\n.btn-border:hover,\n.btn-border:focus-visible {\n  animation: spin-border 3s linear infinite;\n}\n@keyframes spin-border {\n  to { --angle: 360deg; }\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Effect 4: lift<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The simplest effect, and often the best for secondary buttons: the button rises slightly and its shadow deepens.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.btn-lift {\n  transition: transform 0.2s ease, box-shadow 0.2s ease;\n}\n.btn-lift:hover,\n.btn-lift:focus-visible {\n  transform: translateY(-2px);\n  box-shadow: 0 10px 24px rgba(15, 23, 42, .25);\n}\n.btn-lift:active {\n  transform: translateY(0);\n}<\/code><\/pre>\n\n\n<aside class=\"tool-card tool-card--inline\"><span class=\"swatch\" style=\"background:linear-gradient(120deg,#2f4bff 40%,#9fb0ff 50%,#2f4bff 60%)\" aria-hidden=\"true\"><\/span><div class=\"tool-card__body\"><p class=\"tool-card__eyebrow\">Free tool<\/p><p class=\"tool-card__name\">Button hover effects generator<\/p><p class=\"tool-card__blurb\">Shine, fill, glow and animated-border button effects for any page builder.<\/p><\/div><a class=\"btn primary\" href=\"https:\/\/refracttools.com\/button-hover-effects\/\">Try it free <span aria-hidden=\"true\">\u2192<\/span><\/a><\/aside>\n\n\n\n<h2 class=\"wp-block-heading\">Make hover effects accessible<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><div class=\"table-scroll\" tabindex=\"0\" role=\"region\" aria-label=\"Scrollable table\"><table><thead><tr><th>Requirement<\/th><th>Why<\/th><th>How<\/th><\/tr><\/thead><tbody><tr><td>Works with the keyboard<\/td><td>Keyboard users never hover<\/td><td>Add <code>:focus-visible<\/code> wherever you use <code>:hover<\/code><\/td><\/tr><tr><td>Visible focus<\/td><td>People need to see where they are<\/td><td>Keep the outline, or replace it with an equally clear one<\/td><\/tr><tr><td>Reduced motion<\/td><td>Movement can cause dizziness or nausea<\/td><td>Turn transitions and animations off in a <code>prefers-reduced-motion<\/code> query<\/td><\/tr><tr><td>Target size<\/td><td>Small targets are hard to hit<\/td><td>At least 24 \u00d7 24 CSS pixels (WCAG 2.2, SC 2.5.8, AA); aim for 44 \u00d7 44 on touch<\/td><\/tr><tr><td>Readable in every state<\/td><td>Effects can lower contrast mid-animation<\/td><td>Check the label on both the start and end colours<\/td><\/tr><\/tbody><\/table><\/div><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>@media (prefers-reduced-motion: reduce) {\n  .btn-shine::before,\n  .btn-fill::before,\n  .btn-lift {\n    transition: none;\n  }\n  .btn-border:hover,\n  .btn-border:focus-visible {\n    animation: none;\n  }\n}<\/code><\/pre>\n\n\n\n<div class=\"wp-block-group is-style-refract-callout is-layout-constrained wp-block-group-is-layout-constrained\">\n<p class=\"wp-block-paragraph\"><strong>Tip:<\/strong> On phones, a tap can leave a hover style stuck on until the person taps elsewhere. Wrapping purely decorative hover styles in <code>@media (hover: hover)<\/code> applies them only on devices that can actually hover.<\/p>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Common mistakes<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Animating layout properties.<\/strong> Transitions on width, height, padding or margin make the browser recalculate the layout every frame. Use transforms instead.<\/li>\n\n\n<li><strong>Effects that are too slow.<\/strong> Anything over about half a second feels laggy on a control people click often.<\/li>\n\n\n<li><strong>Removing the focus outline<\/strong> with <code>outline: none<\/code> and nothing to replace it.<\/li>\n\n\n<li><strong>Hiding the label.<\/strong> Effects that slide text away or fade it out make the button harder to read just as someone is about to click.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Build your own button<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <a href=\"https:\/\/refracttools.com\/button-hover-effects\/\">button hover effects generator<\/a> has ten effects, including all four above, ready to style with your colours, radius, size and speed. Every effect includes <code>:focus-visible<\/code> and reduced-motion support, and if you use WordPress, Elementor, Divi, Bricks or Breakdance, choose it under <strong>Paste into<\/strong> to get code that targets your builder&#8217;s own button. There are builder walkthroughs for <a href=\"https:\/\/refracttools.com\/blog\/css-techniques\/divi-button-hover-effects\/\">Divi<\/a> and <a href=\"https:\/\/refracttools.com\/blog\/css-techniques\/glassmorphism-elementor\/\">Elementor<\/a> on the Journal. For shadow-based effects, the <a href=\"https:\/\/refracttools.com\/box-shadow-generator\/\">box shadow generator<\/a> makes layered shadows that suit the lift effect.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Sources: <a href=\"https:\/\/w3c.github.io\/wcag\/understanding\/target-size-minimum.html\" rel=\"noopener\" target=\"_blank\">W3C: Understanding SC 2.5.8 Target Size (Minimum)<\/a>, <a href=\"https:\/\/developer.mozilla.org\/docs\/Web\/CSS\/Reference\/At-rules\/@property\" rel=\"noopener\" target=\"_blank\">MDN: @property<\/a>.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Four CSS button hover effects to copy (shine, fill, animated border and lift), how the pseudo-element technique works, and the accessibility details most snippets miss.<\/p>\n","protected":false},"author":1,"featured_media":83,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_refract_tool":"button-hover-effects","footnotes":""},"categories":[8],"tags":[20,52,41,4],"class_list":["post-84","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-css-techniques","tag-accessibility","tag-animation","tag-buttons","tag-css-generators"],"_links":{"self":[{"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/posts\/84","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/comments?post=84"}],"version-history":[{"count":1,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/posts\/84\/revisions"}],"predecessor-version":[{"id":119,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/posts\/84\/revisions\/119"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/media\/83"}],"wp:attachment":[{"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/media?parent=84"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/categories?post=84"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/tags?post=84"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}