Get started easily with our Icon Button component based on HTML and styled with Tailwind CSS.
These types of buttons provide a visually intuitive way to interact with an application or website. The use of icons can help save space on the user interface and make it easier for users to recognize and understand the action associated with the button. Think about the trash bin icon for deleting items, a pencil icon for editing content, or a magnifying glass icon for search action.
Below we showcased examples of icon buttons that you can use for you Material Tailwind project.
Here's how to implement a simple and responsive icon button component. It can be used for the action of favoriting or liking content, given its heart icon.
Check out how to implement different visual styles and interaction states for your icon button using a combination of utility classes.
In the coded snipped you can see:
• The first button: has a solid slate background (bg-slate-800
), white text, and standard shadow effects. It showcases interactive states like hover, focus, and active, with visual feedback including shadow and opacity changes.
• The second button: introduces a gradient background (bg-gradient-to-tr from-slate-800 to-slate-700
) while maintaining similar size, shape, and interaction states as the first button.
• The third button: features a border (border border-slate-300
) and changes the text color to gray (text-slate-600
), distinguishing it from the previous buttons with a more subtle appearance.
• The fourth button: has a transparent background initially with text colored in slate (text-slate-600
). The hover and active states introduce a background color change (hover:bg-slate-100 active:bg-slate-100
), making the button's response to user interactions more understated compared to the others.
Use this example to create icon buttons in different sizes.
Use this example to create icon buttons with different colors (blue, red, green, and amber) for your Tailwind CSS project.
Use this example to create a rounded icon button element for your Tailwind CSS project. The circular shape is achieved through the rounded-full
class.
Use this example to create icon buttons with link element. These buttons are designed to provide users with clickable elements that also serve as links, integrating functionality with navigation within a webpage.
You can turn on/off the ripple effect for the icon button component by changing data-ripple-light
or data-ripple-dark
data attributes to true/false
. The effect starts from the point of contact (e.g., where the user clicks or taps) and spreads outwards in a circular manner, fading away smoothly.
Implement social media buttons with our icon button component example.
In the example below, each button represents a different social media platform through the use of Font Awesome icons and distinct background colors associated with each platform.
The icon button component needs a required script file for ripple effect to work, you just need to add the below script file to the bottom of your html file.
<!-- from node_modules -->
<script src="node_modules/@material-tailwind/html@latest/scripts/ripple.js"></script>
<!-- from cdn -->
<script src="https://unpkg.com/@material-tailwind/html@latest/scripts/ripple.js"></script>
Check out more icon button component examples from Material Tailwind Blocks.