JSFiddle - React, Tailwind, and code Playground
by Pankaj Kargirwar
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bulma Input with Clickable Font Awesome Icon</title>
<!-- Include Bulma CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.min.css">
<!-- Include Font Awesome CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css">
<style>
/* Custom CSS for styling */
.icon-container {
position: relative;
}
.icon-container .fa {
position: absolute;
top: 50%;
right: 10px;
transform: translateY(-50%);
}
.icon-container input {
padding-right: 30px; /* Adjust the padding to make space for the icon */
}
.icon-container:hover .fa {
color: #3273dc; /* Change icon color on hover if desired */
}
</style>
</head>
<body>
<section class="section">
<div class="container">
<div class="field">
<label class="label">Username</label>
<div class="control icon-container">
<input class="input" type="text" placeholder="Enter your username">
<span class="fa fa-user" onclick="handleIconClick()"></span>
</div>
</div>
</div>
</section>
<script>
function handleIconClick() {
alert('Icon clicked!');
// Add your custom click handling logic here
}
</script>
</body>
</html>