JSFiddle - React, Tailwind, and code Playground

by PantelisChin

HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="styles.css">
    <script src="script.js" defer></script>
    <title>Clickable Pointer Example</title>
</head>
<body>
    <div class="pointer" id="pointer">
        <div class="pointer-tip" id="pointer-tip"></div>
    </div>
</body>
</html>

CSS

body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
}

.pointer {
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 20px solid transparent;
    position: relative;
}

.pointer-tip {
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 20px solid red; /* Color the tip */
    position: absolute;
    top: 0;
    left: 0;
}

.pointer:hover .pointer-tip {
    background-color: green; /* Change the color on hover */
    cursor: pointer; /* Change the cursor on hover */
}

JavaScript

document.getElementById('pointer-tip').addEventListener('click', function () {
    alert('Tip clicked!'); // You can replace this with your desired action
});