Pill-Shaped Button Template
Add a touch of modern, friendly style to your interface with this soft, pill-shaped button.
This button's fully rounded corners create a capsule-like shape that is contemporary and approachable, ideal for actions in user-centric applications.
About the Pill-Shaped Button
The pill-shaped button is a simple but effective variation of the standard button. Its defining characteristic is a large border-radius that creates fully rounded ends, regardless of the button's width. This design is often perceived as more modern and less formal than buttons with sharp corners, contributing to a softer overall aesthetic for a web page or application.
Features
- Fully Rounded Shape: Achieved with a high
border-radiusvalue that ensures a perfect pill shape for any text length. - Subtle Hover Animation: A slight lift and shadow increase on hover provide pleasant feedback without being distracting.
- Easy to Customize: All core styles like color and padding can be easily adjusted using the provided CSS custom properties.
- CSS-Only and Accessible: The entire effect is created with pure HTML and CSS, and it includes a clear focus state for full accessibility.
Code Breakdown
The key to this button's shape is the CSS rule border-radius: 999px;. Using a very large, fixed pixel value (larger than half the button's height will ever be) is a robust way to ensure the ends are always perfectly semicircular. The rest of the styling is straightforward, providing a solid background color, text color, and smooth transitions for the hover and focus states.
Code
Here is the complete code for the pill-shaped button.