What padding makes buttons feel comfortable to click?▾
A horizontal padding of 20–28px and vertical padding of 10–14px works for most standard buttons. This produces a tap target taller than 44px (Apple's recommended minimum) at standard 16px font sizes. Increase padding for primary CTAs; reduce it for secondary or compact buttons.
Should buttons have border-radius or stay sharp?▾
Fully sharp corners (0px) work for boxy editorial and brutalist designs. Slightly rounded (4–8px) reads as professional and approachable in most SaaS products. Pill-shaped (9999px) skews friendly and modern, used widely in consumer apps. Match your overall design system's rounding scale.
How do I add a focus ring for keyboard accessibility?▾
Add a :focus-visible rule with outline: 2px solid or box-shadow: 0 0 0 3px to provide a visible keyboard focus indicator. Use :focus-visible rather than :focus to avoid showing the ring on mouse clicks, which improves the visual experience without sacrificing accessibility.
What is the minimum tap target size for mobile buttons?▾
44×44px is Apple's recommendation; Google's Material Design specifies 48×48dp. WCAG 2.5.5 (AAA) recommends 44×44 CSS pixels. The button's visual size can be smaller if you extend the hit area with padding or a ::after pseudo-element.
Can I animate the hover transition smoothly?▾
Yes. Add transition: background 0.15s ease, box-shadow 0.15s ease, color 0.15s ease to the base .btn rule. The browser interpolates between the default and hover values over the specified duration, producing a smooth visual response.
How do I create a disabled button state?▾
Set opacity: 0.5 and pointer-events: none on .btn:disabled, .btn[disabled]. The opacity communicates unavailability and pointer-events prevents interaction. Always also set cursor: not-allowed to reinforce the disabled state visually.
Should I use button or a tag for navigation?▾
Use <button> for actions that do not change the URL (submitting forms, opening modals, triggering JavaScript). Use <a href> for navigation that changes the URL. Misusing these elements breaks screen reader announcements and keyboard navigation expectations.
Why does my button shrink when wrapped in flex?▾
Flex containers set align-items: stretch by default, which stretches items to the container's cross-axis height. A button inside a flex row can appear to lose its natural height. Add align-self: flex-start or align-items: center to the flex container to prevent unexpected stretching.