Secondary Action Button Template
This template provides a subtle yet clear button for alternative user actions.
It is designed to complement a primary button without competing for attention, making it perfect for options like viewing details or canceling a process.

About the Secondary Action Button
A secondary action button, often styled as an "outline" or "ghost" button, represents a secondary choice for the user. While the primary button is bold and draws the eye, the secondary button has a lower visual weight. It gives users an alternative path without distracting them from the main goal.
Features
- Outline (Ghost) Style: Features a transparent background and a colored border, which is visually unobtrusive.
- Interactive Hover Effect: The button background fills with color on hover, providing clear visual feedback that it's an interactive element.
- Fully Responsive: Adapts smoothly to different screen sizes, taking up the full width on smaller mobile devices for easier tapping.
- Accessible by Design: A clear
:focus-visible
state ensures keyboard users can easily see which element is active. - Customizable via CSS Variables: Easily adjust colors and other properties by changing the values in the CSS custom properties block.
Code Breakdown
The CSS for this component uses a transparent background-color
and a solid border
for its default state. When a user hovers or focuses on the button, a transition
smoothly animates the background fill and changes the text color
to maintain contrast. The :focus-visible
pseudo-class applies a high-contrast outline
around the button, ensuring it stands out for keyboard navigation.
Code
Here is the self-contained code for the secondary action button template.