Outline Slide Button
Outline button where the fill slides in from the left on hover.
<button class="relative px-6 py-3 rounded-xl border-2 border-indigo-600 text-indigo-600 font-semibold text-sm overflow-hidden group hover:text-white transition-colors duration-300"> <span class="absolute inset-0 bg-indigo-600 -translate-x-full group-hover:translate-x-0 transition-transform duration-300"></span> <span class="relative">Slide in</span> </button>
Free to use in personal and commercial projects. No attribution required.
Variants
Same component, different looks. Preview each one live and copy the code you like.
Rose
Rose fill for destructive or high energy actions like delete.
Slide from right
Fill sweeps from the right, a nice mirror for RTL layouts or variety.
Dark
White on dark version for footers, hero sections, and dark mode.
About this outline slide button
The outline slide button starts as a ghost: just a border and colored text. On hover, a solid fill slides in from the left, inverting the button. It is the refined hover for secondary actions, nav CTAs, and anywhere a solid button would be too heavy.
This slide button uses an absolute fill span translated -100% off left, sliding to 0 on group-hover. The text color transitions from indigo to white simultaneously. The 300ms duration keeps it snappy.
Slide direction matters. Left-to-right feels natural for LTR languages (progress, forward). For a back or cancel action, slide right-to-left. Match the motion to the meaning.
Secondary actions live in an awkward middle: a solid button would compete with the primary CTA, but a plain text link feels unclickable and gets skipped. The outline slide button resolves the tension with a two-state personality. At rest it is a quiet ghost that does not steal attention; on hover it floods with color and becomes unmistakably a button. Interfaces can offer more actions without raising their voice.
The fill is an absolute inset-0 bg-indigo-600 span parked at -translate-x-full, sliding to group-hover:translate-x-0 with transition-transform duration-300. The label sits in a relative span above the fill, and the button's own text color transitions to hover:text-white in the same 300ms so the inversion lands together. The button's overflow-hidden keeps the sliding fill clipped to the rounded border.
Aim the motion at the meaning: left-to-right for forward actions like Continue, right-to-left (starting from translate-x-full) for Back. For a different feel, grow the fill vertically with scale-y-0 to scale-y-100 and origin-bottom, like a rising tide. Keep the border-2 and fill in the same hue so the resting outline previews the arriving fill.
The mistake is making the slide too slow. Past about 500ms, the fill stops feeling like a response and starts feeling like progress: users wonder if the button is loading something and hesitate to click. A hover effect must complete before the user's patience does. Keep it at 200 to 300 milliseconds so the fill arrives while the cursor is still deciding.
Where to use it
- ✓ Secondary CTAs
- ✓ Navigation actions
- ✓ Card footers
- ✓ Form secondary buttons
Customization tips
Change the slide direction with translate-x-full for right-to-left. Use scale-y instead of translate-x for a fill that grows vertically. Match the border and fill colors.
Design notes
When to use
Use it for secondary actions, nav CTAs, and card footers where a solid button would feel too heavy. Starting as a ghost outline and filling on hover gives quiet interactivity that does not compete with the primary CTA. The left to right slide suits forward actions in left to right languages.
What to avoid
Do not use it as the primary action; a ghost button whispers where the main CTA should speak. Do not slide the fill in from the right for a forward action in left to right layouts, the motion should match the meaning.
Accessibility
The text color flips from indigo to white as the fill arrives, so check contrast at both ends of the transition. Keep it a real button element so keyboard users get focus and activation for free.
Frequently asked questions
How do I make a fill slide in on hover?
Place an absolute background span inside an overflow-hidden button, translated off-screen. On group-hover, translate it to 0. Transition the text color at the same time.
Slide vs fade for button hovers?
Slides feel directional and energetic; fades feel calm. Use slides for forward actions, fades for subtle state changes.
Does the sliding fill work on mobile?
Hover does not exist on touch. The button still works as a tappable outline button; the slide is a desktop enhancement.
How do I make the fill slide in from the right instead of the left?
The fill layer is positioned with a scale or translate transform anchored to one side. Set the transform origin to the right edge and the fill grows from right to left. This element anchors the fill to the left, so flipping the origin flips the direction.
Can the sliding fill be a gradient instead of a solid color?
Yes. Replace the fill layer's solid background with a gradient class like bg-gradient-to-r from-indigo-500 to-purple-500. The slide animation is on the layer itself, so any background you put on it travels along. Just make sure the text color still contrasts against the gradient.
Why does my sliding fill cover the button text?
The fill layer is stacking above the text. Give the text position relative and a higher z-index than the fill layer, or put the fill at a negative z-index behind the text. This element keeps the label on top with the relative class so the fill slides underneath the text.