Tailwind CSS Button Collection
This collection features custom-designed Tailwind CSS buttons created specifically for modern web interfaces. Each button has been carefully crafted using Tailwind's utility classes to ensure consistent styling, responsive behavior, and accessibility.
Disabled Button
<!-- Primary Disabled -->
<button
type="button"
class="px-4 py-2 bg-blue-500 text-white font-semibold rounded-md shadow-sm opacity-50 cursor-not-allowed"
disabled
>
Disabled Button
</button>
<!-- Alt Disabled -->
<button
type="button"
class="px-4 py-2 bg-gray-300 text-gray-500 font-semibold rounded-md cursor-not-allowed"
disabled
>
Disabled Alt
</button>
Loading Button
<!-- Loading with text -->
<button
type="button"
class="inline-flex items-center px-4 py-2 bg-blue-500 text-white font-semibold rounded-md shadow-sm opacity-75 cursor-not-allowed"
disabled
>
<svg class="animate-spin -ml-1 mr-3 h-5 w-5 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
Processing...
</button>
<!-- Loading icon only -->
<button
type="button"
class="inline-flex items-center justify-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 opacity-75 cursor-wait"
disabled
>
<svg class="animate-spin h-5 w-5 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
</button>
Submit Button
<!-- Simple Submit -->
<button
type="submit"
class="px-6 py-2 bg-green-600 hover:bg-green-700 text-white font-semibold rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500 transition duration-150 ease-in-out"
>
Submit Form
</button>
<!-- Submit with Icon -->
<button
type="submit"
class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition duration-150 ease-in-out"
>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 mr-2 -ml-1">
<path stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5" />
</svg>
Confirm
</button>
Reset Button
<!-- Simple Reset -->
<button
type="reset"
class="px-4 py-2 bg-gray-200 hover:bg-gray-300 text-gray-800 font-semibold rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-400 transition duration-150 ease-in-out"
>
Reset
</button>
<!-- Reset with Icon -->
<button
type="reset"
class="inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md shadow-sm text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 transition duration-150 ease-in-out"
>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 mr-2 -ml-1">
<path stroke-linecap="round" stroke-linejoin="round" d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99" />
</svg>
Clear Form
</button>
Navigation Button
Often used for previous/next steps, pagination, or back actions.
<!-- Back Button -->
<button type="button" class="inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 mr-2 -ml-1">
<path stroke-linecap="round" stroke-linejoin="round" d="M10.5 19.5L3 12m0 0l7.5-7.5M3 12h18" />
</svg>
Back
</button>
<!-- Next Button -->
<button type="button" class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
Next
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 ml-2 -mr-1">
<path stroke-linecap="round" stroke-linejoin="round" d="M13.5 4.5L21 12m0 0l-7.5 7.5M21 12H3" />
</svg>
</button>
<!-- Previous Icon Button -->
<button type="button" class="p-2 border border-gray-300 rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
<span class="sr-only">Previous</span>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5">
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 19.5L8.25 12l7.5-7.5" />
</svg>
</button>
<!-- Next Icon Button -->
<button type="button" class="p-2 border border-gray-300 rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
<span class="sr-only">Next</span>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5">
<path stroke-linecap="round" stroke-linejoin="round" d="M8.25 4.5l7.5 7.5-7.5 7.5" />
</svg>
</button>
CTA Button (Call To Action)
Designed to stand out and encourage user interaction.
<!-- Gradient CTA -->
<button
type="button"
class="px-8 py-3 bg-gradient-to-r from-purple-600 to-pink-600 hover:from-purple-700 hover:to-pink-700 text-white text-lg font-bold rounded-lg shadow-lg transform hover:scale-105 transition duration-300 ease-in-out focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-pink-500"
>
Get Started Now
</button>
<!-- Solid CTA with Icon -->
<button
type="button"
class="inline-flex items-center px-6 py-3 border border-transparent text-base font-medium rounded-md shadow-sm text-white bg-emerald-600 hover:bg-emerald-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-emerald-500 transition duration-150 ease-in-out"
>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6 mr-2">
<path stroke-linecap="round" stroke-linejoin="round" d="M2.25 18.75a60.07 60.07 0 0115.797 2.101c.727.198 1.453-.342 1.453-1.096V18.75M3.75 4.5v.75A.75.75 0 013 6h-.75m0 0v-.375c0-.621.504-1.125 1.125-1.125H20.25M2.25 6v9m18-10.5v.75c0 .414.336.75.75.75h.75m-1.5-1.5h.375c.621 0 1.125.504 1.125 1.125v9.75c0 .621-.504 1.125-1.125 1.125h-.375m1.5-1.5H21a.75.75 0 00-.75.75v.75m0 0H3.75m0 0h-.375a1.125 1.125 0 01-1.125-1.125V15m1.5 1.5v-.75A.75.75 0 003 15h-.75M15 10.5a3 3 0 11-6 0 3 3 0 016 0zm3 0h.008v.008H18V10.5zm-12 0h.008v.008H6V10.5z" />
</svg>
Sign Up Free
</button>
Download Button
<!-- Primary Download -->
<button
type="button"
class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-cyan-600 hover:bg-cyan-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-cyan-500"
>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 mr-2 -ml-1">
<path stroke-linecap="round" stroke-linejoin="round" d="M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5M16.5 12L12 16.5m0 0L7.5 12m4.5 4.5V3" />
</svg>
Download File
</button>
<!-- Secondary Download -->
<button
type="button"
class="inline-flex items-center px-3 py-2 border border-gray-300 shadow-sm text-sm leading-4 font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-4 h-4 mr-1.5">
<path stroke-linecap="round" stroke-linejoin="round" d="M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5M16.5 12L12 16.5m0 0L7.5 12m4.5 4.5V3" />
</svg>
Export PDF
</button>
Upload Button
Often used to trigger file selection inputs.
<!-- Input styled as button (Recommended for accessibility) -->
<label class="inline-flex items-center px-4 py-2 bg-white border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 hover:bg-gray-50 focus-within:outline-none focus-within:ring-2 focus-within:ring-offset-2 focus-within:ring-indigo-500 cursor-pointer">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 mr-2 -ml-1 text-gray-400">
<path stroke-linecap="round" stroke-linejoin="round" d="M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5" />
</svg>
<span>Upload a file</span>
<input type="file" class="sr-only">
</label>
<!-- Standard Button (might need JS to trigger hidden input) -->
<button
type="button"
class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 mr-2 -ml-1">
<path stroke-linecap="round" stroke-linejoin="round" d="M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5" />
</svg>
Choose Files
</button>
Close/Dismiss Button
Typically an icon-only button for closing modals, alerts, etc.
<!-- Icon Only (Circular) -->
<button type="button" class="p-1 rounded-full text-gray-400 hover:text-gray-600 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
<span class="sr-only">Close</span>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
<!-- Icon Only (Square) -->
<button type="button" class="p-2 rounded-md text-gray-500 bg-white hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-red-500">
<span class="sr-only">Dismiss</span>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" class="w-5 h-5">
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
<!-- Text + Icon -->
<button type="button" class="inline-flex items-center px-3 py-1.5 border border-transparent text-xs font-medium rounded shadow-sm text-white bg-red-600 hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500">
Dismiss
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" class="w-4 h-4 ml-1.5 -mr-0.5">
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
Expand/Collapse Button
Used for accordions, sidebars, etc. Requires JS to toggle state/icon.
<!-- Expand Button (e.g., Accordion Header) -->
<button type="button" class="inline-flex items-center justify-between w-full px-4 py-2 text-sm font-medium text-left text-gray-700 bg-gray-100 rounded-lg hover:bg-gray-200 focus:outline-none focus-visible:ring focus-visible:ring-purple-500 focus-visible:ring-opacity-75">
<span>Show Details</span>
<!-- Expand Icon (e.g., Chevron Down) -->
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 text-gray-500">
<path stroke-linecap="round" stroke-linejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5" />
</svg>
<!-- Collapse Icon (e.g., Chevron Up) - Use JS to swap -->
<!--
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 text-gray-500">
<path stroke-linecap="round" stroke-linejoin="round" d="M4.5 15.75l7.5-7.5 7.5 7.5" />
</svg>
-->
</button>
<!-- Collapse Icon Button -->
<button type="button" class="inline-flex items-center p-2 rounded-md text-gray-500 hover:text-gray-700 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-indigo-500">
<span class="sr-only">Collapse section</span>
<!-- Collapse Icon (e.g., Chevron Up) -->
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M4.5 15.75l7.5-7.5 7.5 7.5" />
</svg>
</button>
Dropdown Button
Button that triggers a dropdown menu. Requires JS for menu visibility.
<!-- Dropdown Container -->
<div class="relative inline-block text-left"> <!-- JS needed to toggle visibility of dropdown menu -->
<!-- Dropdown Toggle Button -->
<button type="button" class="inline-flex justify-center w-full rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" id="options-menu-button" aria-expanded="true" aria-haspopup="true">
Options
<!-- Chevron down icon -->
<svg class="-mr-1 ml-2 h-5 w-5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
<path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" />
</svg>
</button>
<!--
Dropdown menu, show/hide based on menu state.
Entering: "transition ease-out duration-100"
From: "transform opacity-0 scale-95"
To: "transform opacity-100 scale-100"
Leaving: "transition ease-in duration-75"
From: "transform opacity-100 scale-100"
To: "transform opacity-0 scale-95"
-->
<div class="origin-top-right absolute right-0 mt-2 w-56 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none hidden" role="menu" aria-orientation="vertical" aria-labelledby="options-menu-button" tabindex="-1">
<div class="py-1" role="none">
<!-- Active: "bg-gray-100 text-gray-900", Not Active: "text-gray-700" -->
<a href="#" class="text-gray-700 block px-4 py-2 text-sm hover:bg-gray-100" role="menuitem" tabindex="-1" id="options-menu-item-0">Account settings</a>
<a href="#" class="text-gray-700 block px-4 py-2 text-sm hover:bg-gray-100" role="menuitem" tabindex="-1" id="options-menu-item-1">Support</a>
<a href="#" class="text-gray-700 block px-4 py-2 text-sm hover:bg-gray-100" role="menuitem" tabindex="-1" id="options-menu-item-2">License</a>
</div>
</div>
</div>
Split Button
Combines a primary action with a dropdown for secondary actions.
<!-- Standard Split Button -->
<div class="relative inline-flex shadow-sm rounded-md">
<!-- Main Action Button -->
<button type="button" class="relative inline-flex items-center px-4 py-2 rounded-l-md border border-gray-300 bg-white text-sm font-medium text-gray-700 hover:bg-gray-50 focus:z-10 focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500">
Save
</button>
<!-- Dropdown Toggle Part -->
<div class="-ml-px relative block"> <!-- JS needed for dropdown -->
<button type="button" class="relative inline-flex items-center px-2 py-2 rounded-r-md border border-gray-300 bg-white text-sm font-medium text-gray-500 hover:bg-gray-50 focus:z-10 focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500" id="split-button-menu-button" aria-expanded="true" aria-haspopup="true">
<span class="sr-only">Open options</span>
<svg class="h-5 w-5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
<path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" />
</svg>
</button>
<!-- Dropdown menu (Hidden by default) -->
<div class="origin-top-right absolute right-0 mt-2 w-56 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none hidden" role="menu" aria-orientation="vertical" aria-labelledby="split-button-menu-button" tabindex="-1">
<div class="py-1" role="none">
<a href="#" class="text-gray-700 block px-4 py-2 text-sm hover:bg-gray-100" role="menuitem" tabindex="-1">Save and close</a>
<a href="#" class="text-gray-700 block px-4 py-2 text-sm hover:bg-gray-100" role="menuitem" tabindex="-1">Save as draft</a>
</div>
</div>
</div>
</div>
<!-- Primary Color Split Button -->
<div class="relative inline-flex shadow-sm rounded-md">
<button type="button" class="relative inline-flex items-center px-4 py-2 rounded-l-md border border-indigo-600 bg-indigo-600 text-sm font-medium text-white hover:bg-indigo-700 focus:z-10 focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500">
Publish
</button>
<div class="-ml-px relative block"> <!-- JS needed for dropdown -->
<button type="button" class="relative inline-flex items-center px-2 py-2 rounded-r-md border border-indigo-600 bg-indigo-600 text-sm font-medium text-indigo-100 hover:bg-indigo-700 focus:z-10 focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500" id="split-button-primary-menu-button" aria-expanded="true" aria-haspopup="true">
<span class="sr-only">Open options</span>
<svg class="h-5 w-5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
<path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" />
</svg>
</button>
<!-- Dropdown menu (Hidden) -->
<div class="origin-top-right absolute right-0 mt-2 w-56 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none hidden" role="menu" aria-orientation="vertical" aria-labelledby="split-button-primary-menu-button" tabindex="-1">
<div class="py-1" role="none">
<a href="#" class="text-gray-700 block px-4 py-2 text-sm hover:bg-gray-100" role="menuitem" tabindex="-1">Schedule publish...</a>
<a href="#" class="text-gray-700 block px-4 py-2 text-sm hover:bg-gray-100" role="menuitem" tabindex="-1">Unpublish</a>
</div>
</div>
</div>
</div>
Tab Button
Used within a tab navigation system. Requires JS to handle active state and content switching.
<!-- Tab Navigation Container -->
<div class="border-b border-gray-200">
<nav class="-mb-px flex space-x-8" aria-label="Tabs">
<!-- Active Tab Button -->
<!-- Use JS to toggle classes based on active tab -->
<!-- Current: "border-indigo-500 text-indigo-600", Default: "border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300" -->
<button class="border-indigo-500 text-indigo-600 whitespace-nowrap py-3 px-1 border-b-2 font-medium text-sm" aria-current="page">
My Account
</button>
<!-- Inactive Tab Button -->
<button class="border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 whitespace-nowrap py-3 px-1 border-b-2 font-medium text-sm">
Company
</button>
<!-- Another Inactive Tab Button -->
<button class="border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 whitespace-nowrap py-3 px-1 border-b-2 font-medium text-sm">
Team Members
</button>
<!-- Yet Another Inactive Tab Button -->
<button class="border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 whitespace-nowrap py-3 px-1 border-b-2 font-medium text-sm">
Billing
</button>
</nav>
</div>
<!-- Associated Tab Content Panels (place content below the nav) -->
<!-- Use JS to show/hide these based on the active tab -->
<div class="mt-4">
<!-- Content for "My Account" (visible by default if it's the active tab) -->
<div class="">
Account details go here...
</div>
<!-- Content for "Company" (hidden by default) -->
<div class="hidden">
Company details go here...
</div>
<!-- Content for "Team Members" (hidden by default) -->
<div class="hidden">
Team Members list goes here...
</div>
<!-- Content for "Billing" (hidden by default) -->
<div class="hidden">
Billing information goes here...
</div>
</div>
Segmented Control Button
Group of connected buttons where only one can be active. Requires JS for state management.
<!-- Segmented Control Container -->
<span class="relative z-0 inline-flex shadow-sm rounded-md">
<!-- Use JS to manage active state (e.g., toggle bg-white/text-gray-700 with bg-indigo-600/text-white) -->
<!-- Inactive Segment -->
<button type="button" class="relative inline-flex items-center px-4 py-2 rounded-l-md border border-gray-300 bg-white text-sm font-medium text-gray-700 hover:bg-gray-50 focus:z-10 focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500">
Week
</button>
<!-- Active Segment Example -->
<button type="button" class="-ml-px relative inline-flex items-center px-4 py-2 border border-gray-300 bg-indigo-600 text-sm font-medium text-white focus:z-10 focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500">
Month
</button>
<!-- Inactive Segment -->
<button type="button" class="-ml-px relative inline-flex items-center px-4 py-2 rounded-r-md border border-gray-300 bg-white text-sm font-medium text-gray-700 hover:bg-gray-50 focus:z-10 focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500">
Year
</button>
</span>
Like/Favorite Button
Icon-based buttons to express preference. Requires JS to toggle active state (icon fill/color).
<!-- Use JS to toggle between inactive/active states/classes -->
<!-- Heart Icon - Inactive State -->
<button type="button" class="inline-flex items-center p-2 border border-transparent rounded-full shadow-sm text-gray-400 bg-white hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-pink-500">
<span class="sr-only">Favorite</span>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M21 8.25c0-2.485-2.099-4.5-4.688-4.5-1.935 0-3.597 1.126-4.312 2.733-.715-1.607-2.377-2.733-4.313-2.733C5.1 3.75 3 5.765 3 8.25c0 7.22 9 12 9 12s9-4.78 9-12z" />
</svg>
</button>
<!-- Heart Icon - Active State -->
<button type="button" class="inline-flex items-center p-2 border border-transparent rounded-full shadow-sm text-pink-600 bg-pink-100 hover:bg-pink-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-pink-500">
<span class="sr-only">Unfavorite</span>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-6 h-6">
<path d="M11.645 20.91l-.007-.003-.022-.012a15.247 15.247 0 01-.383-.218 25.18 25.18 0 01-4.244-3.17C4.688 15.36 2.25 12.174 2.25 8.25 2.25 5.322 4.714 3 7.688 3A5.5 5.5 0 0112 5.052 5.5 5.5 0 0116.313 3c2.973 0 5.437 2.322 5.437 5.25 0 3.925-2.438 7.111-4.739 9.256a25.175 25.175 0 01-4.244 3.17 15.247 15.247 0 01-.383.218l-.022.012-.007.004-.004.001a.752.752 0 01-.704 0l-.004-.001z" />
</svg>
</button>
<!-- Thumbs Up - Inactive State -->
<button type="button" class="inline-flex items-center px-3 py-2 border border-gray-300 shadow-sm text-sm leading-4 font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 mr-1.5 -ml-0.5 text-gray-400">
<path stroke-linecap="round" stroke-linejoin="round" d="M6.633 10.5c.806 0 1.533-.446 2.031-1.08a9.041 9.041 0 012.861-2.4c.723-.384 1.35-.956 1.653-1.715a4.498 4.498 0 00.322-1.672V3a.75.75 0 01.75-.75A2.25 2.25 0 0118 4.5v1.546A9.037 9.037 0 0117.07 9.48l1.064 4.256M6.633 10.5H3.75a.75.75 0 00-.75.75v11.25a.75.75 0 00.75.75h3.75a.75.75 0 00.75-.75V11.25a.75.75 0 00-.75-.75zM10.378 15l-.217 1.087a1.5 1.5 0 001.43 1.848h5.38a1.5 1.5 0 001.43-1.848l-.217-1.087M10.378 15h4.804" />
</svg>
Like
</button>
<!-- Thumbs Up - Active State -->
<button type="button" class="inline-flex items-center px-3 py-2 border border-indigo-500 shadow-sm text-sm leading-4 font-medium rounded-md text-indigo-700 bg-indigo-100 hover:bg-indigo-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-5 h-5 mr-1.5 -ml-0.5 text-indigo-600">
<path fill-rule="evenodd" d="M10.788 3.21c.448-1.077 1.976-1.077 2.424 0l2.082 5.007 5.404.433c1.164.093 1.636 1.545.749 2.305l-4.117 3.527 1.257 5.273c.271 1.136-.964 2.033-1.96 1.425L12 18.354l-4.615 2.735c-.996.608-2.231-.29-1.96-1.425l1.257-5.273-4.117-3.527c-.887-.76-.415-2.212.749-2.305l5.404-.433 2.082-5.006z" clip-rule="evenodd" /> <!-- Placeholder: Using Star, replace with solid thumb if needed -->
</svg>
Liked
</button>
Share Button
Button to initiate sharing content. Often opens a share menu/dialog (JS required).
<!-- Share Button with Text -->
<button type="button" class="inline-flex items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 mr-2 -ml-1 text-gray-400">
<path stroke-linecap="round" stroke-linejoin="round" d="M7.217 10.907a2.25 2.25 0 100 2.186m0-2.186c.18.324.283.696.283 1.093s-.103.77-.283 1.093m0-2.186l9.566-5.314m-9.566 7.5l9.566 5.314m0 0a2.25 2.25 0 103.935 2.186 2.25 2.25 0 00-3.935-2.186zm0-12.814a2.25 2.25 0 103.933-2.185 2.25 2.25 0 00-3.933 2.185z" />
</svg>
Share
</button>
<!-- Share Icon Button -->
<button type="button" class="p-2 rounded-full text-gray-500 bg-white hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
<span class="sr-only">Share</span>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M7.217 10.907a2.25 2.25 0 100 2.186m0-2.186c.18.324.283.696.283 1.093s-.103.77-.283 1.093m0-2.186l9.566-5.314m-9.566 7.5l9.566 5.314m0 0a2.25 2.25 0 103.935 2.186 2.25 2.25 0 00-3.935-2.186zm0-12.814a2.25 2.25 0 103.933-2.185 2.25 2.25 0 00-3.933 2.185z" />
</svg>
</button>
Social Media Button
Buttons for linking or sharing to social platforms, often using brand colors and icons.
<!-- Twitter Share Button -->
<button type="button" class="inline-flex items-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-[#1DA1F2] hover:bg-[#0c85d0] focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-[#1DA1F2]">
<svg class="w-5 h-5 mr-2 -ml-1" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true">
<path d="M23.953 4.57a10 10 0 01-2.825.775 4.958 4.958 0 002.163-2.723c-.951.555-2.005.959-3.127 1.184a4.92 4.92 0 00-8.384 4.482C7.69 8.095 4.067 6.13 1.64 3.162a4.822 4.822 0 00-.666 2.475c0 1.71.87 3.213 2.188 4.096a4.904 4.904 0 01-2.228-.616v.06a4.923 4.923 0 003.946 4.827 4.996 4.996 0 01-2.212.085 4.936 4.936 0 004.604 3.417 9.867 9.867 0 01-6.102 2.105c-.39 0-.779-.023-1.17-.067a13.995 13.995 0 007.557 2.209c9.053 0 13.998-7.496 13.998-13.985 0-.21 0-.42-.015-.63A9.935 9.935 0 0024 4.59z" />
</svg>
Share on Twitter
</button>
<!-- Facebook Share Button (Icon Only) -->
<button type="button" class="inline-flex justify-center p-2 border border-transparent rounded-md shadow-sm text-white bg-[#1877F2] hover:bg-[#166fe5] focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-[#1877F2]">
<span class="sr-only">Share on Facebook</span>
<svg class="w-5 h-5" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true">
<path fill-rule="evenodd" d="M22 12c0-5.523-4.477-10-10-10S2 6.477 2 12c0 4.991 3.657 9.128 8.438 9.878v-6.987h-2.54V12h2.54V9.797c0-2.506 1.492-3.89 3.777-3.89 1.094 0 2.238.195 2.238.195v2.46h-1.26c-1.243 0-1.63.771-1.63 1.562V12h2.773l-.443 2.89h-2.33v6.988C18.343 21.128 22 16.991 22 12z" clip-rule="evenodd" />
</svg>
</button>
<!-- GitHub Link Button (Icon Only) -->
<button type="button" class="inline-flex justify-center p-2 border border-transparent rounded-md shadow-sm text-gray-700 bg-gray-100 hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500">
<span class="sr-only">View on GitHub</span>
<svg class="w-5 h-5" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true">
<path fill-rule="evenodd" d="M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z" clip-rule="evenodd" />
</svg>
</button>
Pagination Button
Buttons used in pagination controls (Prev, Next, Page Numbers).
<!-- Pagination Container -->
<nav class="relative z-0 inline-flex rounded-md shadow-sm -space-x-px" aria-label="Pagination">
<!-- Previous Button -->
<button class="relative inline-flex items-center px-2 py-2 rounded-l-md border border-gray-300 bg-white text-sm font-medium text-gray-500 hover:bg-gray-50">
<span class="sr-only">Previous</span>
<svg class="h-5 w-5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
<path fill-rule="evenodd" d="M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z" clip-rule="evenodd" />
</svg>
</button>
<!-- Page Number Buttons -->
<!-- Use JS/backend logic to generate page numbers and set active state -->
<!-- Active Page: "z-10 bg-indigo-50 border-indigo-500 text-indigo-600", Default: "bg-white border-gray-300 text-gray-500 hover:bg-gray-50" -->
<button aria-current="page" class="z-10 bg-indigo-50 border-indigo-500 text-indigo-600 relative inline-flex items-center px-4 py-2 border text-sm font-medium"> 1 </button>
<button class="bg-white border-gray-300 text-gray-500 hover:bg-gray-50 relative inline-flex items-center px-4 py-2 border text-sm font-medium"> 2 </button>
<!-- Use 'hidden md:inline-flex' for responsive collapsing -->
<button class="bg-white border-gray-300 text-gray-500 hover:bg-gray-50 hidden md:inline-flex relative items-center px-4 py-2 border text-sm font-medium"> 3 </button>
<span class="relative inline-flex items-center px-4 py-2 border border-gray-300 bg-white text-sm font-medium text-gray-700"> ... </span>
<button class="bg-white border-gray-300 text-gray-500 hover:bg-gray-50 hidden md:inline-flex relative items-center px-4 py-2 border text-sm font-medium"> 8 </button>
<button class="bg-white border-gray-300 text-gray-500 hover:bg-gray-50 relative inline-flex items-center px-4 py-2 border text-sm font-medium"> 9 </button>
<button class="bg-white border-gray-300 text-gray-500 hover:bg-gray-50 relative inline-flex items-center px-4 py-2 border text-sm font-medium"> 10 </button>
<!-- Next Button -->
<button class="relative inline-flex items-center px-2 py-2 rounded-r-md border border-gray-300 bg-white text-sm font-medium text-gray-500 hover:bg-gray-50">
<span class="sr-only">Next</span>
<svg class="h-5 w-5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
<path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd" />
</svg>
</button>
</nav>
Stepper Button (+/-)
Small buttons for incrementing or decrementing a value (e.g., quantity).
<!-- Stepper Control (requires JS for functionality) -->
<div class="flex items-center space-x-2">
<!-- Decrease Button -->
<button
type="button"
class="p-1.5 border border-gray-300 rounded-md text-gray-600 hover:bg-gray-100 focus:outline-none focus:ring-1 focus:ring-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed"
aria-label="Decrease quantity"
<!-- Add disabled attribute via JS when quantity is at minimum -->
>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" class="w-4 h-4">
<path stroke-linecap="round" stroke-linejoin="round" d="M19.5 12h-15" />
</svg>
</button>
<!-- Quantity Display -->
<span class="text-lg font-medium text-gray-900 w-8 text-center">1</span> <!-- Update value via JS -->
<!-- Increase Button -->
<button
type="button"
class="p-1.5 border border-gray-300 rounded-md text-gray-600 hover:bg-gray-100 focus:outline-none focus:ring-1 focus:ring-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed"
aria-label="Increase quantity"
<!-- Add disabled attribute via JS when quantity is at maximum -->
>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" class="w-4 h-4">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
</svg>
</button>
</div>
Sticky/Fixed Position Button
Button that stays fixed in the viewport (e.g., Chat, Help, Scroll to Top). Preview shows potential placement.
This button would be fixed to the bottom right of the browser window.
<!-- Fixed Position Button (e.g., Bottom Right) -->
<!-- Place this button usually near the end of the body or outside main scrolling containers -->
<button
type="button"
class="fixed bottom-6 right-6 inline-flex items-center p-3 border border-transparent rounded-full shadow-lg text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 z-50 transition-opacity duration-300"
<!-- Add JS for conditional visibility (e.g., show on scroll) -->
>
<!-- Example: Chat Icon -->
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M8.625 12a.375.375 0 11-.75 0 .375.375 0 01.75 0zm0 0H8.25m4.125 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zm0 0H12m4.125 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zm0 0h-.375M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
<!-- Optional Text (shown on larger screens) -->
<span class="ml-2 hidden sm:inline">Chat</span>
</button>
Scroll to Top Button
A fixed button, usually appearing after scrolling down, to quickly return to the top. Requires JS.
This button would be fixed and appear/disappear with JS based on scroll position.
<!-- Scroll to Top Button -->
<!-- Use JS to toggle visibility (e.g., add/remove 'hidden' or control opacity/transform) based on scroll position -->
<!-- Use JS to handle the scroll-to-top action on click -->
<button
type="button"
id="scrollToTopBtn" <!-- Example ID for JS -->
class="fixed bottom-5 right-5 p-3 border border-transparent rounded-full shadow-md text-gray-600 bg-white hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 z-40 transition-opacity duration-300 opacity-0 hidden" <!-- Start hidden/transparent -->
>
<span class="sr-only">Scroll to top</span>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M4.5 15.75l7.5-7.5 7.5 7.5" />
</svg>
</button>
<!-- Example JS (Conceptual) -->
<!--
<script>
const btn = document.getElementById('scrollToTopBtn');
window.onscroll = function() {
if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
btn.classList.remove('hidden', 'opacity-0');
btn.classList.add('opacity-80'); // Or set opacity directly
} else {
btn.classList.add('hidden', 'opacity-0'); // Hide smoothly or instantly
}
};
btn.onclick = function() {
window.scrollTo({ top: 0, behavior: 'smooth' });
};
</script>
-->
Custom Shape Button
Buttons with non-standard shapes. Pill shapes are easy with `rounded-full`.
<!-- Pill Shape Button -->
<button type="button" class="px-6 py-2 bg-teal-500 hover:bg-teal-600 text-white font-semibold rounded-full shadow-md focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-teal-400">
Pill Button
</button>
<!-- Angled/Skewed Button (using transform) -->
<button type="button" class="px-6 py-2 bg-orange-500 hover:bg-orange-600 text-white font-semibold rounded-md shadow-md transform -skew-x-12 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-orange-400">
<!-- Counter-skew the text inside -->
<span class="inline-block transform skew-x-12">Skewed Text</span>
</button>
<!-- Note: More complex shapes might require SVG or clip-path (which isn't a standard Tailwind utility but can be added via custom CSS/plugins) -->
Themed/Branded Button
Uses CSS variables or custom theme colors defined in your Tailwind config.
<!-- Define CSS Variables (e.g., in your global CSS or a style tag) -->
<style>
:root {
--brand-primary: #6366f1; /* Example: indigo-500 */
--brand-primary-hover: #4f46e5; /* Example: indigo-600 */
--brand-secondary: #ec4899; /* Example: pink-500 */
--brand-secondary-hover: #db2777; /* Example: pink-600 */
--brand-text-light: #ffffff;
/* Add focus ring variable if needed */
--brand-primary-focus-ring: rgba(99, 102, 241, 0.4);
--brand-secondary-focus-ring: rgba(236, 72, 153, 0.4);
}
</style>
<!-- Button using CSS Variables -->
<!-- Note: Inline styles/JS used here for demo. Ideally, create custom Tailwind classes or utility classes -->
<button
type="button"
class="px-5 py-2.5 font-medium rounded-lg shadow-md focus:outline-none focus:ring-4 transition duration-150"
style="background-color: var(--brand-primary); color: var(--brand-text-light); border-color: var(--brand-primary); box-shadow: 0 0 0 3px var(--brand-primary-focus-ring);"
onmouseover="this.style.backgroundColor='var(--brand-primary-hover)'"
onmouseout="this.style.backgroundColor='var(--brand-primary)'"
onfocus="this.style.boxShadow='0 0 0 4px var(--brand-primary-focus-ring)'"
onblur="this.style.boxShadow='0 0 0 3px var(--brand-primary-focus-ring)'" <!-- Reset shadow slightly on blur -->
>
Primary Brand
</button>
<button
type="button"
class="px-5 py-2.5 font-medium rounded-lg shadow-md focus:outline-none focus:ring-4 transition duration-150"
style="background-color: var(--brand-secondary); color: var(--brand-text-light); border-color: var(--brand-secondary); box-shadow: 0 0 0 3px var(--brand-secondary-focus-ring);"
onmouseover="this.style.backgroundColor='var(--brand-secondary-hover)'"
onmouseout="this.style.backgroundColor='var(--brand-secondary)'"
onfocus="this.style.boxShadow='0 0 0 4px var(--brand-secondary-focus-ring)'"
onblur="this.style.boxShadow='0 0 0 3px var(--brand-secondary-focus-ring)'"
>
Secondary Brand
</button>
<!-- Better Approach: Define these colors in your tailwind.config.js theme extension -->
<!--
module.exports = {
theme: {
extend: {
colors: {
'brand-primary': 'var(--brand-primary)', // Use variable
'brand-primary-hover': 'var(--brand-primary-hover)',
'brand-secondary': 'var(--brand-secondary)',
'brand-secondary-hover': 'var(--brand-secondary-hover)',
// OR define directly
// 'brand-primary': '#6366f1',
// 'brand-primary-hover': '#4f46e5',
},
ringColor: { // Optional: for focus rings
'brand-primary': 'var(--brand-primary-focus-ring)',
'brand-secondary': 'var(--brand-secondary-focus-ring)',
}
},
},
plugins: [],
}
-->
<!-- Then use classes like: bg-brand-primary hover:bg-brand-primary-hover focus:ring-brand-primary -->
Animated Button
Buttons with subtle animations on hover or click using Tailwind's transition and transform utilities.
<!-- Grow on Hover -->
<button
type="button"
class="px-6 py-3 bg-purple-600 hover:bg-purple-700 text-white font-semibold rounded-lg shadow-md transform hover:scale-105 transition duration-300 ease-in-out focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-purple-500"
>
Hover Me (Grow)
</button>
<!-- Shrink on Click (Active State) -->
<button
type="button"
class="px-6 py-3 bg-green-500 hover:bg-green-600 text-white font-semibold rounded-lg shadow-md active:scale-95 transition duration-150 ease-in-out focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500"
>
Click Me (Shrink)
</button>
<!-- Move Up on Hover -->
<button
type="button"
class="px-6 py-3 bg-yellow-500 hover:bg-yellow-600 text-gray-800 font-semibold rounded-lg shadow-md transform hover:-translate-y-1 transition duration-300 ease-in-out focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-yellow-400"
>
Hover Me (Up)
</button>
Contextual Button
Buttons whose text and/or style indicate a specific action within a context (Save, Delete, Archive).
<!-- Save Changes Button -->
<button type="button" class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 mr-2 -ml-1">
<path stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5" />
</svg>
Save Changes
</button>
<!-- Archive Button -->
<button type="button" class="inline-flex items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 mr-2 -ml-1 text-gray-400">
<path stroke-linecap="round" stroke-linejoin="round" d="M20.25 7.5l-.625 10.632a2.25 2.25 0 01-2.247 2.118H6.622a2.25 2.25 0 01-2.247-2.118L3.75 7.5M10.5 11.25h3M12 17.25h.008" />
</svg>
Archive Post
</button>
<!-- Delete Button -->
<button type="button" class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-red-600 hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 mr-2 -ml-1">
<path stroke-linecap="round" stroke-linejoin="round" d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0" />
</svg>
Delete Account
</button>
<!-- View Details Button -->
<button type="button" class="inline-flex items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 mr-2 -ml-1 text-gray-400">
<path stroke-linecap="round" stroke-linejoin="round" d="M2.036 12.322a1.012 1.012 0 010-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178z" />
<path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
</svg>
View Details
</button>
Responsive Button
Button that changes size or hides text on smaller screens. (Resize your browser to see effects).
<!-- Responsive Size and Text Visibility -->
<button
type="button"
class="inline-flex items-center justify-center px-3 py-2 sm:px-4 sm:py-2 md:px-6 md:py-3 border border-transparent text-xs sm:text-sm font-medium rounded-md shadow-sm text-white bg-gradient-to-r from-cyan-500 to-blue-500 hover:from-cyan-600 hover:to-blue-600 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"
>
<!-- Responsive Icon Size -->
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-4 h-4 sm:w-5 sm:h-5 mr-1 sm:mr-2">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 18v-5.25m0 0a6.01 6.01 0 001.5-.189m-1.5.189a6.01 6.01 0 01-1.5-.189m3.75 7.478a12.06 12.06 0 01-4.5 0m3.75 2.354a15.057 15.057 0 01-4.5 0m3.75-2.354V18M4.125 15.06L3.75 15a12.01 12.01 0 00-1.41 4.87m1.41-4.87L3.75 15m0 0v2.25m0 0a11.96 11.96 0 002.691 6.747m0 0a11.96 11.96 0 002.692-6.747M3.75 17.25h16.5M19.875 15.06l.375.06a12.01 12.01 0 011.41 4.87m-1.41-4.87L20.25 15m0 0v2.25m0 0a11.96 11.96 0 01-2.692 6.747m0 0a11.96 11.96 0 01-2.691-6.747M20.25 17.25H3.75M16.125 6a1.49 1.49 0 01-1.024.503 1.487 1.487 0 01-1.024-.503M12 6a1.49 1.49 0 01-1.024.503 1.487 1.487 0 01-1.024-.503M7.875 6a1.49 1.49 0 01-1.024.503 1.487 1.487 0 01-1.024-.503m13.5 4.135V9.75a1.5 1.5 0 00-1.5-1.5H3.75a1.5 1.5 0 00-1.5 1.5v.385" />
</svg>
<!-- Show longer text on larger screens -->
<span class="hidden sm:inline">Launch Rocket</span>
<!-- Show shorter text on smaller screens -->
<span class="sm:hidden">Launch</span>
</button>
<!-- Icon Only on Small Screens, Icon + Text on Medium+ -->
<button type="button" class="inline-flex items-center p-2 md:px-4 md:py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
<!-- Icon always visible, margin adjusts -->
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 md:mr-2">
<path stroke-linecap="round" stroke-linejoin="round" d="M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L10.582 16.07a4.5 4.5 0 01-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 011.13-1.897l8.932-8.931zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0115.75 21H5.25A2.25 2.25 0 013 18.75V8.25A2.25 2.25 0 015.25 6H10" />
</svg>
<!-- Text hidden on small screens (default), shown on medium and up -->
<span class="hidden md:inline">Edit Profile</span>
</button>
FAQ on Tailwind CSS Buttons
How do I create basic buttons with Tailwind CSS?
Create buttons by combining Tailwind utility classes: px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600. This approach gives you complete control over button styling with Tailwind. Adam Wathan and the Tailwind Labs team designed this utility-first system to make custom buttons in Tailwind straightforward without writing custom CSS.
What are the different button styles available in Tailwind?
Tailwind doesn't provide pre-built button components but lets you create various styles:
- Solid buttons with background colors
- Outline buttons using border utilities
- Ghost buttons with transparent backgrounds
- Icon buttons combining SVG elements
- Gradient buttons using gradient utilities
This button design system approach prioritizes flexibility over pre-made components.
How do I add hover effects to Tailwind buttons?
Add hover effects using Tailwind's state variants with the hover: prefix: hover:bg-blue-700 hover:shadow-lg. These button hover effects create interactive buttons Tailwind users expect. Additional states include focus:, active:, and disabled: for complete button states management in your web interface buttons.
Can I create different button sizes in Tailwind CSS?
Yes! Control button size Tailwind CSS by adjusting padding, font size, and border-radius:
- Small:
px-2 py-1 text-sm rounded-sm - Medium:
px-4 py-2 text-base rounded - Large:
px-6 py-3 text-lg rounded-lg
This sizing system works perfectly with responsive web buttons across device sizes.
How do I create button groups in Tailwind?
Use the flex utility with negative margins for Tailwind button groups:
<div class="flex -space-x-1">
<button class="border px-4 py-2 relative">Left</button>
<button class="border px-4 py-2 relative">Middle</button>
<button class="border px-4 py-2 relative">Right</button>
</div>
This technique is popular in web component buttons for pagination, toolbars, and segmented controls.
How do I make Tailwind buttons accessible?
Focus on accessibility by:
- Adding proper focus styles with
focus:ring - Using sufficient color contrast (4.5:1 minimum)
- Including descriptive text or aria-labels for icon buttons
- Ensuring keyboard navigability
Follow WCAG guidelines to make accessible Tailwind buttons for all users. Frontend Masters has great resources on this topic.
Can I animate Tailwind buttons?
Yes! Use transition utilities for animated buttons in Tailwind:
<button class="transition-all duration-300 ease-in-out transform hover:scale-105">
Animated Button
</button>
These subtle animations enhance button micro-interactions without requiring custom CSS or JavaScript libraries like Vue.js or React.
How do I create dark mode buttons in Tailwind?
Use Tailwind's dark mode variant to create buttons that adapt between light and dark modes:
<button class="bg-blue-500 text-white dark:bg-blue-700">Button</button>
This creates consistent dark mode buttons that respect user preferences. Test in both modes using Tailwind Play or tools like Figma.
What's the best way to add icons to Tailwind buttons?
Use SVG icons inside flex containers for alignment:
<button class="flex items-center px-4 py-2 bg-green-500 text-white rounded">
<svg class="w-4 h-4 mr-2"><!-- Icon paths --></svg>
Button Text
</button>
This approach for Tailwind button icons works well with icon libraries and user interface buttons in modern web apps.
How can I customize Tailwind buttons beyond default styles?
Extend Tailwind's theme in your config file to add custom button variants:
// tailwind.config.js
module.exports = {
theme: {
extend: {
colors: {
brand: '#ff5733',
}
}
}
}
Use the JIT compiler for more efficient development. Adam Wathan often demonstrates advanced button customization Tailwind techniques in tutorials.