Skip to content
IndexRequest a UIAboutContact

Ghost Button Fill Slide

An outlined button whose fill slides in from the left, bottom or corner on hover and keyboard focus.

Open alone ↗

AI prompt

PROMPT: PASTE INTO YOUR AI CODING TOOL
Clean UI mockup showing the same outlined button in three states in a row: resting with a dark border and dark text on white, half filled with a dark colour sweeping from left to right with the text turning white where covered, and fully filled dark with white text, the label Learn more with a small arrow, light theme, flat modern style. Negative: gradients, heavy shadows, clutter, text errors. Reduced motion: static design.

About this pattern

Definition

A ghost button is an outlined secondary action. A sliding fill on hover adds a clear, tactile response without moving the layout. It is built by animating the size or position of a background gradient, so the button keeps its shape while colour sweeps through it.

Purpose & UX principles

  • Paint a solid colour as a background image sized zero by default and grow it on hover and focus-visible.
  • Direction is set by background-position and which axis grows.
  • Switch the text colour at the same moment so contrast stays high throughout.
  • Keep the transition between 200 and 300 ms.

Interaction states

  • Direction buttons and three live buttons to hover, focus or press.

Motion specification

  • The fill slides in 250ms.
  • Reduced motion: the colour changes instantly.

Responsive behaviour

  • Fill colour and text colour must both meet contrast in every state.
  • Do not animate on touch hover because it can stick after a tap; use active instead.

Code

HTML
<div class="bx"><div class="pre" id="pre" role="group" aria-label="Direction"><button data-p="0" aria-pressed="true">From left</button><button data-p="1" aria-pressed="false">From bottom</button><button data-p="2" aria-pressed="false">From corner</button></div><div class="row" id="row"><button class="gb" type="button">Learn more →</button><button class="gb" type="button">View plans</button><button class="gb" type="button">Contact</button></div></div>

Related patterns

Primary & Secondary Button

↗
Primary & Secondary ButtonButtons & Actions

Press Feedback

↗
Press FeedbackButtons & Actions

Magnetic Button

↗
Magnetic ButtonButtons & Actions