Mouse tilt
3D Mouse Tilt Effect. Creates a 3D tilt effect that follows the mouse cursor.
Preview
Code
<a
class="bg-background border border-black-100 dark:border-black-500 rounded-12px no-underline transition-all overflow-hidden hover:shadow-lg flex flex-col min-w-[200px] max-w-[300px]"
data-tilt="">
<div class="aspect-[30/25] h-full w-full bg-black-50 dark:bg-black-800 max-w-[300px]">
<img
class="h-full w-full object-cover"
alt="card caption"
loading="lazy"
src="/assets/images/home/card-image.jpg">
</img>
</div>
<div class="flex flex-col p-16px gap-16px my-auto whitespace-nowrap">
<div class="flex flex-col gap-4px">
<p class="text-h8">
Title
</p>
<p class="text-p2">
Subtitle
</p>
</div>
<div class="flex flex-wrap gap-16px items-center text-black-700 dark:text-black-200">
<div class="flex gap-12px items-center">
<div class="flex rounded-full items-center justify-center bg-accent-100 overflow-hidden w-32px h-32px">
<img
src="/assets/images/shared/avatar.png"
class="object-cover w-full h-full"
loading="lazy"
alt="avatar">
</img>
</div>
<p class="text-p2">
Kaida
</p>
</div>
<div class="h-12px w-[1px] bg-black-200">
</div>
<p class="text-p3">
Sep 6, 2024
</p>
</div>
</div>
</a>
Glare
You can use data-tilt-glare to add glare effect.
Preview
Code
<a
class="bg-background border border-black-100 dark:border-black-500 rounded-12px no-underline transition-all overflow-hidden hover:shadow-lg flex flex-col min-w-[200px] max-w-[300px]"
data-tilt=""
data-tilt-glare="true">
<div class="aspect-[30/25] h-full w-full bg-black-50 dark:bg-black-800 max-w-[300px]">
<img
class="h-full w-full object-cover"
alt="card caption"
loading="lazy"
src="/assets/images/home/card-image.jpg">
</img>
</div>
<div class="flex flex-col p-16px gap-16px my-auto whitespace-nowrap">
<div class="flex flex-col gap-4px">
<p class="text-h8">
Title
</p>
<p class="text-p2">
Subtitle
</p>
</div>
<div class="flex flex-wrap gap-16px items-center text-black-700 dark:text-black-200">
<div class="flex gap-12px items-center">
<div class="flex rounded-full items-center justify-center bg-accent-100 overflow-hidden w-32px h-32px">
<img
src="/assets/images/shared/avatar.png"
class="object-cover w-full h-full"
loading="lazy"
alt="avatar">
</img>
</div>
<p class="text-p2">
Kaida
</p>
</div>
<div class="h-12px w-[1px] bg-black-200">
</div>
<p class="text-p3">
Sep 6, 2024
</p>
</div>
</div>
</a>
With target
You can use data-tilt-target for child tilt effect with container mouse hover.
Preview
Code
<div
data-tilt=""
data-tilt-target=".tilt-target"
class="grid w-full border border-black-100 p-24px justify-center relative">
<a class="bg-background border border-black-100 dark:border-black-500 rounded-12px no-underline transition-all overflow-hidden hover:shadow-lg flex flex-col min-w-[200px] max-w-[300px] tilt-target z-[2]">
<div class="aspect-[30/25] h-full w-full bg-black-50 dark:bg-black-800 max-w-[300px]">
<img
class="h-full w-full object-cover"
alt="card caption"
loading="lazy"
src="/assets/images/home/card-image.jpg">
</img>
</div>
<div class="flex flex-col p-16px gap-16px my-auto whitespace-nowrap">
<div class="flex flex-col gap-4px">
<p class="text-h8">
Title
</p>
<p class="text-p2">
Subtitle
</p>
</div>
<div class="flex flex-wrap gap-16px items-center text-black-700 dark:text-black-200">
<div class="flex gap-12px items-center">
<div class="flex rounded-full items-center justify-center bg-accent-100 overflow-hidden w-32px h-32px">
<img
src="/assets/images/shared/avatar.png"
class="object-cover w-full h-full"
loading="lazy"
alt="avatar">
</img>
</div>
<p class="text-p2">
Kaida
</p>
</div>
<div class="h-12px w-[1px] bg-black-200">
</div>
<p class="text-p3">
Sep 6, 2024
</p>
</div>
</div>
</a>
<p class="absolute inset-[50%] -translate-[50%] z-[3] w-full h-max text-center text-h1 uppercase tracking-[.5rem] lg:tracking-[2rem]">
hover me
</p>
</div>
Self prevent
You can use data-tilt-self-prevent to block tilt effect when hovering over the tilt target. When enabled, the element stops moving when you hover over it.
Preview
Code
<div
data-tilt=""
data-tilt-target=".tilt-target"
data-tilt-self-prevent="true"
class="grid w-full border border-black-100 p-24px justify-center relative">
<a class="bg-background border border-black-100 dark:border-black-500 rounded-12px no-underline transition-all overflow-hidden hover:shadow-lg flex flex-col min-w-[200px] max-w-[300px] tilt-target z-[2]">
<div class="aspect-[30/25] h-full w-full bg-black-50 dark:bg-black-800 max-w-[300px]">
<img
class="h-full w-full object-cover"
alt="card caption"
loading="lazy"
src="/assets/images/home/card-image.jpg">
</img>
</div>
<div class="flex flex-col p-16px gap-16px my-auto whitespace-nowrap">
<div class="flex flex-col gap-4px">
<p class="text-h8">
Title
</p>
<p class="text-p2">
Subtitle
</p>
</div>
<div class="flex flex-wrap gap-16px items-center text-black-700 dark:text-black-200">
<div class="flex gap-12px items-center">
<div class="flex rounded-full items-center justify-center bg-accent-100 overflow-hidden w-32px h-32px">
<img
src="/assets/images/shared/avatar.png"
class="object-cover w-full h-full"
loading="lazy"
alt="avatar">
</img>
</div>
<p class="text-p2">
Kaida
</p>
</div>
<div class="h-12px w-[1px] bg-black-200">
</div>
<p class="text-p3">
Sep 6, 2024
</p>
</div>
</div>
</a>
<p class="absolute inset-[50%] -translate-[50%] z-[3] w-full h-max text-center text-h1 uppercase tracking-[.5rem] lg:tracking-[2rem]">
hover me
</p>
</div>
See our real usage from the "Launching soon" page:
Preview
Code
<div class="grid scale-[0.2] sm:scale-[0.4]">
<div
class="grid overflow-hidden min-w-[1600px] min-h-[920px]"
data-controller="mouse-tilt"
data-tilt=""
data-tilt-target="#form-tilt"
data-tilt-self-prevent="true">
<div class="grid p-24px lg:p-32px max-w-[1440px] mx-auto w-full relative launching-soon-page">
<div class="grid z-1 relative">
<button
class="grid relative rounded-full w-32px h-32px p-4px items-center justify-center text-foreground back-button z-2"
type="button">
<svg
width="24"
height="24"
viewbox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg">
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M14.7071 5.29289C15.0976 5.68342 15.0976 6.31658 14.7071 6.70711L9.41421 12L14.7071 17.2929C15.0976 17.6834 15.0976 18.3166 14.7071 18.7071C14.3166 19.0976 13.6834 19.0976 13.2929 18.7071L7.29289 12.7071C6.90237 12.3166 6.90237 11.6834 7.29289 11.2929L13.2929 5.29289C13.6834 4.90237 14.3166 4.90237 14.7071 5.29289Z"
fill="currentColor">
</path>
</svg>
</button>
<div
class="flex flex-col p-16px sm:py-24px lg:py-64px sm:px-32px lg:px-96px bg-background rounded-32px border border-black-100 dark:border-black-700 max-w-[652px] w-full absolute left-[50%] top-[50%] -translate-[50%] items-center z-1"
id="form-tilt">
<a
href="/"
class="flex text-u1 font-semibold gap-8px items-center py-4px sm:p-8px text-foreground! no-underline logo ">
<svg
width="24"
height="24"
viewbox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg">
<rect
width="24"
height="24"
rx="2"
fill="black">
</rect>
<path
d="M9.18014 20.625C7.94299 13.8881 7.93689 10.1401 9.18014 3.5"
stroke="white"
stroke-width="4">
</path>
<path
d="M12.5 14.5L18.9952 18.25"
stroke="white"
stroke-width="4.5">
</path>
<circle
cx="15.25"
cy="8.25"
r="3.25"
fill="white">
</circle>
</svg>
<span class="logo-text">
Kaida
</span>
</a>
<div class="flex flex-col gap-24px w-full">
<div class="grid self-center [&>svg]:max-w-full relative">
<svg
width="460"
height="100"
viewbox="0 0 460 100"
fill="none"
xmlns="http://www.w3.org/2000/svg">
<path
d="M2.92882 92.0972C2.29972 92.038 1.79644 91.9381 1.41898 91.7976C1.04617 91.7458 0.587162 91.572 0.0419402 91.2761C0.0279601 86.2391 0.0139801 81.2059 0 76.1763C0.0699003 69.7709 0.142131 63.3545 0.216691 56.9269C0.244651 55.8249 0.272611 53.8167 0.300571 50.9025C0.328531 48.0105 0.372802 44.6118 0.433382 40.7065C0.461342 36.8233 0.503282 32.759 0.559202 28.5134C0.615122 24.401 0.673373 20.5215 0.733953 16.875C0.761913 13.2212 0.803853 10.2367 0.859773 7.92162C1.638 7.30032 2.94513 7.1302 4.78118 7.41126C6.64985 7.76629 9.08937 8.99041 12.0997 11.0836C11.9832 20.0555 11.8691 29.1384 11.7572 38.3322C11.7246 41.9195 11.6803 45.2516 11.6244 48.3285C11.5685 51.509 11.5102 54.9003 11.4497 58.5024C11.3658 62.1193 11.2656 66.3648 11.1491 71.2391C15.0076 71.5793 18.8661 71.9122 22.7246 72.2376C24.0154 72.356 25.0756 72.7295 25.905 73.3582C25.905 74.5342 25.8911 75.7547 25.8631 77.0194C25.8351 78.2916 25.7629 79.9522 25.6464 82.001C25.4973 85.7362 25.3435 89.4714 25.1851 93.2066C25.0686 93.1992 24.6655 93.177 23.9758 93.1401C23.3187 93.1031 22.459 93.055 21.3965 92.9958C20.334 92.9367 19.1434 92.8738 17.8246 92.8072C16.5058 92.7333 15.1567 92.6593 13.7773 92.5853C12.37 92.5114 10.9953 92.4374 9.65323 92.3634C8.30182 92.2895 7.03663 92.2155 5.85764 92.1415C4.71128 92.0676 3.735 92.0528 2.92882 92.0972ZM50.1604 95.0705C49.8715 95.0558 49.5709 95.0003 49.2587 94.9041C48.9745 94.7932 48.6739 94.6859 48.357 94.5824C48.0961 93.1918 47.8794 91.7976 47.7069 90.3997C47.5345 89.0905 47.3621 87.5964 47.1897 85.9174C47.0452 85.8139 46.6864 85.7362 46.1132 85.6844C45.5447 85.6253 44.8573 85.5106 44.0512 85.3405C43.2496 85.2665 42.4481 85.1889 41.6466 85.1075C40.8451 85.0261 40.1297 84.9078 39.5006 84.7525C38.8995 84.6933 38.4824 84.6489 38.2494 84.6193C38.049 86.3353 37.8766 87.7813 37.7322 88.9574C37.5644 90.0446 37.3664 91.5905 37.138 93.5949C36.4204 93.8242 35.9031 93.9278 35.5862 93.9056C35.4418 93.8982 35.1435 93.7909 34.6915 93.5838C34.2302 93.4729 33.6849 93.2547 33.0558 92.9293C32.4221 92.7074 31.7627 92.4855 31.0777 92.2636C30.4159 91.9307 29.7985 91.6534 29.2253 91.4315C28.6521 91.2096 28.2071 90.984 27.8902 90.7547C28.263 88.2029 29.2649 81.1948 30.8959 69.7302C32.5316 58.5763 34.7567 43.739 37.5714 25.2183C39.0859 25.6103 40.7472 25.9912 42.5553 26.361C44.3587 26.6199 46.2344 27.1598 48.1823 27.9808C48.6716 28.188 49.1446 28.4283 49.6012 28.702C50.0579 28.9757 50.503 29.4121 50.9363 30.0112C50.9363 30.0851 51.0785 31.1354 51.3627 33.1621C51.619 35.1517 51.9755 37.7553 52.4322 40.9728C52.8889 44.279 53.4015 47.8811 53.97 51.779C54.5432 55.7435 55.1187 59.7672 55.6965 63.85C56.293 67.9329 56.8639 71.8271 57.4091 75.5328C57.9543 79.3124 58.4296 82.5705 58.8351 85.3072C59.0634 87.0528 59.2917 88.5025 59.5201 89.6563C59.7531 90.8102 59.9558 91.9196 60.1282 92.9847C58.2362 93.362 56.6891 93.6874 55.4868 93.9611C54.2845 94.2347 53.3386 94.4344 52.6489 94.5602C51.9639 94.6859 51.4489 94.7821 51.1041 94.8486C50.5589 95.004 50.2443 95.0779 50.1604 95.0705ZM40.5282 67.4003C42.1312 67.7184 43.7343 68.0327 45.3373 68.3434C44.9645 64.7487 44.6057 61.1577 44.2609 57.5704C43.8927 53.8574 43.5222 49.8374 43.1494 45.5105C42.5763 50.9913 42.073 55.407 41.6396 58.7576C41.1829 62.1377 40.8124 65.0187 40.5282 67.4003ZM79.1341 97.0787C77.7314 97.0195 76.3031 96.8087 74.8492 96.4463C73.358 96.1578 71.925 95.5217 70.5503 94.538C69.1756 93.606 67.9454 92.1304 66.8596 90.1112C65.7692 88.129 64.9094 85.444 64.2803 82.0564C63.6512 78.7132 63.3366 74.5416 63.3366 69.5416C63.3366 68.9869 63.3366 68.3952 63.3366 67.7665C63.3366 67.2043 63.3366 66.6089 63.3366 65.9802C63.3646 61.7272 63.3926 57.4817 63.4205 53.2435C63.4764 49.1311 63.5044 45.6732 63.5044 42.8699C63.5417 40.1628 63.6162 37.7923 63.7281 35.7582C66.1606 36.3573 68.5931 36.9454 71.0257 37.5223C72.5868 38.0622 74.1456 38.5504 75.702 38.9868C75.674 39.9853 75.6601 40.9949 75.6601 42.0157C75.6601 43.029 75.6601 44.0053 75.6601 44.9446C75.497 53.2879 75.3362 61.6829 75.1777 70.1296C75.1777 71.9862 75.2919 73.7095 75.5203 75.2998C75.7812 76.9048 76.2099 78.3027 76.8064 79.4936C77.4122 80.5956 78.286 81.2169 79.4277 81.3575C80.7698 81.5202 81.8556 80.5069 82.685 78.3175C83.5378 76.1652 83.9945 72.9699 84.0551 68.7317C84.139 62.2598 84.2275 55.8175 84.3207 49.4047C84.3487 47.4003 84.3766 45.3995 84.4046 43.4025C85.4344 43.6688 86.5062 43.9128 87.62 44.1347C88.7104 44.4158 89.9547 44.7043 91.3527 45.0001C92.7227 45.3552 94.2955 45.7694 96.0709 46.2427C96.0709 47.0268 96.0709 47.8071 96.0709 48.5837C96.0989 49.4417 96.1106 50.2923 96.1059 51.1355C96.0779 52.8885 96.0476 54.8374 96.015 56.9824C95.9591 59.1274 95.9172 61.2835 95.8892 63.4506C95.8333 65.6696 95.775 67.6999 95.7144 69.5416C95.6585 71.4573 95.6026 73.0401 95.5467 74.2902C95.4861 75.5476 95.4279 76.3094 95.3719 76.5757C95.0038 80.0002 94.419 82.8885 93.6174 85.2406C92.8206 87.6223 91.8629 89.5971 90.7445 91.1652C89.6355 92.7702 88.4215 93.9907 87.1027 94.8265C85.8212 95.6918 84.4931 96.3094 83.1184 96.6793C81.7484 96.9899 80.4203 97.1231 79.1341 97.0787ZM120.941 98.3989C117.213 91.069 113.488 83.5986 109.764 75.9876C109.708 79.7007 109.667 82.7406 109.639 85.1075C109.611 87.4818 109.583 89.3642 109.555 90.7547C109.555 92.1452 109.555 93.1512 109.555 93.7725C109.555 94.4086 109.555 94.856 109.555 95.1149C108.786 95.4552 107.889 95.7621 106.864 96.0358C105.862 96.3168 104.79 96.5979 103.648 96.879C102.534 97.1009 101.463 97.1933 100.433 97.1563C100.377 96.2836 100.335 95.3553 100.307 94.3716C100.246 93.4396 100.216 92.4448 100.216 91.3871C100.3 86.3427 100.384 81.0542 100.468 75.5217C100.556 69.9891 100.642 64.5675 100.726 59.2568C100.731 55.7583 100.733 52.2635 100.733 48.7723C105.151 49.1274 109.564 49.4713 113.972 49.8041C114.056 50.0704 114.327 50.7953 114.783 51.9787C115.207 53.1473 115.748 54.5749 116.405 56.2613C117.062 57.9329 117.761 59.6969 118.502 61.5534C119.21 63.3804 119.907 65.137 120.592 66.8234C121.249 68.4506 121.806 69.8486 122.263 71.0172C122.267 66.5571 122.27 62.1082 122.27 57.6703C122.298 56.8789 122.325 56.1429 122.353 55.4624C122.386 54.7302 122.447 54.0867 122.535 53.532C124.711 53.7834 126.892 54.0312 129.078 54.2753C129.446 54.3641 129.816 54.4232 130.189 54.4528C130.585 54.5416 130.97 54.6266 131.343 54.708C131.399 55.4328 131.44 56.2058 131.468 57.0268C131.496 57.8626 131.51 58.7465 131.51 59.6784C131.454 60.7583 131.41 62.1969 131.378 63.9943C131.373 65.8212 131.371 67.4484 131.371 68.8759C131.371 71.0801 131.357 73.4876 131.329 76.0986C131.329 78.7243 131.315 81.2428 131.287 83.6541C131.277 85.873 131.266 88.1068 131.252 90.3553C131.252 91.2577 131.266 92.1378 131.294 92.9958C131.322 93.8538 131.366 94.6563 131.427 95.4034C131.114 95.5069 130.755 95.6068 130.35 95.7029C129.926 95.7473 129.371 95.8435 128.686 95.9914C127.973 96.1911 127.004 96.4463 125.779 96.7569C124.553 97.1268 122.941 97.6741 120.941 98.3989ZM152.117 99.1534C150.491 99.1164 148.881 98.8649 147.287 98.3989C145.688 97.9256 144.193 97.1785 142.799 96.1578C141.373 95.1149 140.117 93.717 139.032 91.964C137.946 90.2406 137.091 88.1179 136.466 85.5957C135.837 83.1178 135.523 80.2036 135.523 76.853C135.523 73.7391 135.823 71.0912 136.424 68.9092C136.993 66.6829 137.792 64.8559 138.822 63.4284C139.875 62.0823 141.073 61.032 142.415 60.2775C143.752 59.4713 145.176 58.9499 146.686 58.7132C148.228 58.4173 149.782 58.3027 151.348 58.3692C152.14 58.4062 152.923 58.4913 153.697 58.6244C154.209 58.7132 154.706 58.8204 155.186 58.9462C155.67 59.0275 156.141 59.1533 156.598 59.3234C156.598 63.2879 156.595 67.2524 156.591 71.2169C155.989 71.0394 155.365 70.8656 154.717 70.6955C154.032 70.5106 153.317 70.3737 152.571 70.285C151.551 70.1518 150.614 70.3072 149.761 70.7509C148.932 71.1651 148.275 71.9603 147.79 73.1363C147.338 74.2754 147.112 75.8545 147.112 77.8737C147.112 80.174 147.338 82.0269 147.79 83.4322C148.247 84.7783 148.89 85.7658 149.719 86.3945C150.54 87.0232 151.462 87.4226 152.487 87.5927C152.972 87.6223 153.599 87.5557 154.368 87.393C155.165 87.2377 155.906 87.0528 156.591 86.8383C156.595 90.8176 156.598 94.8191 156.598 98.8427C155.801 98.9833 155.018 99.072 154.249 99.109C153.452 99.1534 152.741 99.1682 152.117 99.1534ZM165.349 98.7762C164.496 98.7096 163.744 98.643 163.091 98.5765C163.091 96.9492 163.103 95.1445 163.126 93.1622C163.154 91.2022 163.182 89.2976 163.21 87.4485C163.238 86.694 163.252 86.2207 163.252 86.0284C163.35 81.5831 163.448 77.1674 163.546 72.7813C163.606 71.4277 163.665 69.9817 163.72 68.4432C163.776 66.9492 163.863 65.1444 163.979 63.029C164.012 62.5335 164.042 62.0342 164.07 61.5312C164.41 61.2872 164.895 61.1836 165.524 61.2206C166.176 61.2132 166.917 61.2391 167.747 61.2983C168.595 61.3574 169.445 61.4166 170.298 61.4758C171.179 61.5423 171.976 61.5941 172.689 61.6311C173.374 61.6607 173.886 61.6977 174.226 61.742C174.236 65.9358 174.147 70.1259 173.961 74.3123C176.65 74.5268 179.338 74.7302 182.027 74.9225C182.027 74.8264 182.041 74.4344 182.069 73.7465C182.102 73.0512 182.132 72.2006 182.16 71.1947C182.188 70.2258 182.216 69.1977 182.244 68.1104C182.272 67.0527 182.3 66.0912 182.328 65.2258C182.328 64.3012 182.328 63.6318 182.328 63.2176C182.668 63.1659 183.066 63.1326 183.523 63.1178C183.952 63.1178 184.322 63.1326 184.635 63.1622C187.505 63.3027 190.376 63.4173 193.246 63.5061C193.246 63.6023 193.232 64.0312 193.204 64.7931C193.176 65.5919 193.148 66.5978 193.12 67.8108C193.093 69.0239 193.048 70.3219 192.988 71.7051C192.932 73.0956 192.887 74.4455 192.855 75.7547C192.799 77.0194 192.757 78.1289 192.729 79.0831C192.729 80.0372 192.729 80.6733 192.729 80.9913C192.701 81.5831 192.687 82.1304 192.687 82.6334C192.659 83.1881 192.631 84.0387 192.603 85.1852C192.575 86.3316 192.545 87.9699 192.512 90.1001C192.484 92.2525 192.445 95.0557 192.394 98.5099C192.249 98.5025 191.921 98.521 191.408 98.5654C190.872 98.558 190.234 98.5728 189.493 98.6097C188.756 98.6023 187.962 98.6171 187.109 98.6541C186.284 98.6467 185.49 98.6615 184.725 98.6985C183.952 98.6911 183.295 98.7096 182.754 98.754C182.19 98.7466 181.822 98.7429 181.65 98.7429C181.65 98.2547 181.65 97.5483 181.65 96.6238C181.678 95.6622 181.703 94.6267 181.727 93.5173C181.727 92.3708 181.741 91.2687 181.769 90.2111C181.797 89.1238 181.827 88.2251 181.86 87.515C179.185 87.4041 176.51 87.2894 173.835 87.1711C173.709 90.8324 173.583 94.5232 173.458 98.2436C170.755 98.4211 168.052 98.5986 165.349 98.7762ZM199.803 99.4197C199.724 98.7096 199.67 97.981 199.642 97.234C199.61 96.4796 199.593 95.6844 199.593 94.8486C199.677 89.7007 199.763 84.6045 199.852 79.5601C199.931 77.0083 199.999 74.7117 200.055 72.6703C200.115 70.6215 200.148 68.8242 200.152 67.2783C200.152 66.694 200.138 66.2465 200.111 65.9358C200.334 65.7805 200.59 65.6622 200.879 65.5808C201.159 65.5068 201.569 65.4181 202.11 65.3145C202.646 65.248 203.412 65.1481 204.409 65.015C205.379 64.8744 206.658 64.6821 208.247 64.4381C208.671 64.4529 209.111 64.4676 209.568 64.4824C209.987 64.4972 210.411 64.5083 210.84 64.5157C210.896 65.1296 210.938 65.8101 210.966 66.5572C210.994 67.2598 211.008 68.0032 211.008 68.7872C210.924 70.7694 210.868 72.5742 210.84 74.2014C210.812 75.873 210.782 77.5483 210.749 79.2273C210.721 80.8767 210.665 82.7295 210.582 84.7857C210.521 88.4914 210.465 92.2266 210.414 95.9914C210.386 96.6867 210.372 97.1711 210.372 97.4448C209.915 97.8664 209.461 98.0994 209.009 98.1438C208.552 98.2325 208.07 98.2991 207.562 98.3435C206.877 98.3361 206.054 98.4248 205.094 98.6097C204.097 98.7429 203.133 98.9241 202.201 99.1534C201.259 99.3383 200.46 99.4271 199.803 99.4197ZM236.64 99.8191C232.922 94.4049 229.203 89.0609 225.484 83.7872C225.456 86.4795 225.428 88.6837 225.4 90.3997C225.377 92.1304 225.349 93.4988 225.317 94.5047C225.317 95.518 225.317 96.254 225.317 96.7125C225.317 97.4522 225.317 97.8701 225.317 97.9663C224.552 98.0624 223.658 98.2251 222.632 98.4544C221.612 98.6837 220.549 98.9167 219.445 99.1534C218.331 99.3383 217.266 99.4308 216.25 99.4308C216.19 98.8168 216.146 98.1623 216.118 97.467C216.062 96.8235 216.034 96.1319 216.034 95.3923C216.118 91.879 216.204 88.2066 216.292 84.3752C216.376 80.5587 216.46 76.8234 216.544 73.1696C216.544 70.7583 216.546 68.3471 216.551 65.9358C220.931 65.3589 225.314 64.7376 229.699 64.0719C229.788 64.2494 230.058 64.7302 230.51 65.5142C230.939 66.2909 231.479 67.2413 232.132 68.3656C232.78 69.4898 233.476 70.6807 234.222 71.9381C234.93 73.2029 235.625 74.4196 236.305 75.5882C236.957 76.7273 237.512 77.7147 237.969 78.5505C237.969 75.1112 237.966 71.6829 237.962 68.2657C237.989 67.6518 238.017 67.0786 238.045 66.546C238.073 65.9765 238.132 65.4662 238.22 65.015C240.387 64.7339 242.559 64.4417 244.735 64.1385C245.103 64.1163 245.471 64.0756 245.839 64.0165C246.235 63.9869 246.62 63.961 246.993 63.9388C247.049 64.5157 247.09 65.137 247.118 65.8027C247.146 66.4684 247.163 67.1821 247.167 67.944C247.111 68.8316 247.07 70.0113 247.042 71.4832C247.042 72.9625 247.042 74.2828 247.042 75.444C247.042 77.2339 247.028 79.1903 247 81.3131C247 83.4433 246.983 85.4921 246.951 87.4596C246.937 89.2791 246.923 91.106 246.909 92.9404C246.909 93.68 246.923 94.4012 246.951 95.1038C246.983 95.7991 247.028 96.4537 247.083 97.0676C246.767 97.1711 246.41 97.271 246.014 97.3671C245.585 97.4115 245.031 97.5114 244.35 97.6667C243.642 97.8516 242.675 98.092 241.45 98.3878C240.229 98.7207 238.626 99.1978 236.64 99.8191ZM265.964 99.5861C263.946 99.6083 262.04 99.2643 260.246 98.5543C258.484 97.8146 256.909 96.7126 255.52 95.2481C254.127 93.7614 253.034 91.8827 252.242 89.6119C251.473 87.4078 251.089 84.7488 251.089 81.6348C251.089 78.8686 251.401 76.4314 252.025 74.3234C252.682 72.2154 253.591 70.4255 254.752 68.9536C255.889 67.4299 257.212 66.1762 258.722 65.1925C260.25 64.1496 261.895 63.336 263.657 62.7517C265.39 62.2117 267.182 61.8382 269.032 61.6311C269.545 61.5645 270.158 61.5127 270.871 61.4758C271.607 61.4758 272.376 61.5017 273.177 61.5534C274.002 61.5904 274.785 61.6607 275.526 61.7642C276.262 61.8604 276.901 61.9676 277.441 62.086C277.446 65.6659 277.448 69.2569 277.448 72.8589C277.024 72.7036 276.411 72.5446 275.61 72.3819C274.818 72.2117 273.951 72.0786 273.01 71.9825C272.073 71.8789 271.15 71.8678 270.241 71.9492C269.384 72.0231 268.515 72.2376 267.634 72.5927C266.753 72.8959 265.943 73.3767 265.202 74.035C264.489 74.6859 263.908 75.5623 263.461 76.6644C263.032 77.7591 262.818 79.12 262.818 80.7473C262.813 83.6023 263.265 85.7214 264.174 87.1045C265.087 88.4951 266.283 89.1645 267.76 89.1127C268.841 89.0683 269.696 88.6726 270.325 87.9255C270.978 87.1193 271.446 86.2724 271.73 85.3849C270.537 85.4514 269.344 85.5106 268.151 85.5624C268.221 83.1363 268.291 80.7177 268.361 78.3064C268.445 78.3434 268.757 78.3434 269.298 78.3064C269.838 78.2694 270.521 78.2214 271.346 78.1622C272.143 78.1104 272.984 78.0734 273.869 78.0513C274.778 77.9847 275.645 77.9181 276.47 77.8515C277.266 77.8368 277.949 77.8035 278.518 77.7517C279.058 77.7591 279.37 77.7813 279.454 77.8183C279.454 84.5343 279.452 91.3168 279.447 98.166C278.711 98.2251 278.184 98.2843 277.868 98.3435C277.527 98.3509 277.245 98.3804 277.022 98.4322C276.621 96.6867 276.351 94.9189 276.211 93.129C275.754 94.0905 275.128 94.9781 274.331 95.7917C273.534 96.6053 272.665 97.2932 271.723 97.8553C270.759 98.4248 269.778 98.839 268.781 99.0979C267.783 99.4086 266.844 99.5713 265.964 99.5861ZM312.895 99.2089C311.641 99.2384 310.288 99.1053 308.834 98.8094C307.38 98.5728 305.898 98.2103 304.388 97.7222C302.911 97.2414 301.475 96.5794 300.082 95.7362C300.31 93.9389 300.553 92.2414 300.809 90.6437C301.037 89.0609 301.28 87.4041 301.536 85.6733C303.074 86.0801 304.467 86.4758 305.716 86.8605C306.942 87.2968 308.226 87.6297 309.568 87.859C310.877 88.0439 312.357 88.0846 314.006 87.981C314.351 87.9588 314.694 87.9108 315.034 87.8368C315.407 87.7037 315.721 87.5224 315.977 87.2931C316.234 85.9396 316.234 85.2184 315.977 85.1297C313.983 84.6489 312.228 84.2532 310.714 83.9425C309.237 83.5949 307.86 83.1622 306.583 82.6445C305.297 82.1785 304.157 81.5054 303.165 80.6252C302.195 79.7598 301.441 78.6245 300.9 77.2192C300.359 75.836 300.089 74.0868 300.089 71.9714C300.084 69.7154 300.38 67.7887 300.977 66.191C301.606 64.586 302.445 63.262 303.493 62.2191C304.546 61.1688 305.744 60.2849 307.086 59.5675C308.447 58.8796 309.868 58.3286 311.35 57.9144C312.832 57.5002 314.3 57.1599 315.754 56.8937C316.639 56.7235 317.581 56.6422 318.578 56.6496C319.598 56.657 320.596 56.7494 321.569 56.9269C322.567 57.0971 323.478 57.3448 324.303 57.6703C325.132 57.9366 325.775 58.2398 326.232 58.58C325.92 61.0801 325.649 63.1622 325.421 64.8264C325.193 66.4906 324.922 67.9662 324.61 69.2532C323.245 68.7058 321.891 68.2953 320.549 68.0217C319.239 67.7406 318.028 67.552 316.914 67.4558C315.805 67.4114 314.88 67.4447 314.139 67.5557C313.766 67.6074 313.34 67.6925 312.86 67.8108C312.347 67.9366 311.905 68.1511 311.532 68.4543C311.159 68.765 310.973 69.1977 310.973 69.7524C310.973 70.2702 311.229 70.5993 311.741 70.7398C312.226 70.873 312.941 71.0357 313.887 71.228C315.164 71.4351 316.457 71.6607 317.767 71.9048C319.081 72.1489 320.351 72.4595 321.576 72.8368C322.774 73.2805 323.855 73.9277 324.82 74.7783C325.766 75.5845 326.523 76.731 327.092 78.2177C327.66 79.6526 327.944 81.4906 327.944 83.7317C327.944 86.5942 327.574 89.0091 326.833 90.9766C326.092 92.981 325.051 94.5787 323.708 95.7695C322.366 96.9307 320.784 97.7813 318.962 98.3213C317.108 98.8686 315.085 99.1645 312.895 99.2089ZM348.6 98.1105C347.118 98.1623 345.608 97.9589 344.07 97.5003C342.5 97.1304 340.988 96.4574 339.534 95.481C338.103 94.5417 336.805 93.2177 335.64 91.5091C334.499 89.8819 333.588 87.7961 332.907 85.2517C332.255 82.7887 331.929 79.8301 331.929 76.376C331.929 73.1141 332.241 70.2258 332.865 67.711C333.494 65.1814 334.336 62.944 335.389 60.9987C336.442 59.0238 337.595 57.3227 338.849 55.8951C340.13 54.4454 341.428 53.2065 342.742 52.1784C344.024 51.2095 345.235 50.4328 346.377 49.8485C347.519 49.242 348.476 48.8352 349.25 48.6281C350.844 48.1843 352.454 47.9439 354.08 47.9069C355.739 47.87 357.326 48.1769 358.84 48.8278C360.327 49.4935 361.671 50.5919 362.874 52.1229C364.043 53.6984 364.987 55.8434 365.704 58.5579C366.39 61.3315 366.732 64.7894 366.732 68.9314C366.732 73.495 366.359 77.4447 365.614 80.7805C364.873 84.072 363.873 86.8494 362.615 89.1127C361.361 91.3242 359.947 93.0994 358.372 94.4381C356.769 95.6881 355.14 96.6016 353.486 97.1785C351.799 97.7554 350.17 98.0661 348.6 98.1105ZM349.299 84.6637C351.042 84.3678 352.396 83.1622 353.36 81.0468C354.306 78.8945 354.779 75.6733 354.779 71.3833C354.779 68.6762 354.551 66.5867 354.094 65.1148C353.665 63.6429 353.05 62.6814 352.249 62.2302C351.452 61.7272 350.527 61.5867 349.474 61.8086C347.787 62.1562 346.442 63.3841 345.44 65.4921C344.443 67.5705 343.945 70.4847 343.945 74.2347C343.945 78.1992 344.432 81.0061 345.405 82.6556C346.375 84.2754 347.673 84.9448 349.299 84.6637ZM387.227 96.7125C385.764 96.7717 384.244 96.5313 382.669 95.9914C381.127 95.5476 379.629 94.7451 378.175 93.5838C376.716 92.4522 375.416 90.8619 374.274 88.8131C373.133 86.8605 372.219 84.3568 371.534 81.302C370.849 78.336 370.507 74.7598 370.507 70.5734C370.507 66.6163 370.835 63.0993 371.492 60.0224C372.117 56.938 372.958 54.1902 374.016 51.779C375.069 49.3382 376.224 47.2228 377.483 45.4328C378.774 43.6207 380.074 42.0711 381.383 40.7841C382.674 39.5489 383.89 38.5541 385.032 37.7997C386.178 37.0156 387.122 36.4831 387.863 36.202C389.466 35.6103 391.097 35.2664 392.756 35.1702C394.415 35.0741 395.99 35.4032 397.481 36.1576C398.996 36.9269 400.354 38.2361 401.556 40.0852C402.735 42.0083 403.667 44.6414 404.352 47.9846C405.07 51.3944 405.429 55.6621 405.429 60.7879C405.429 66.4314 405.058 71.3094 404.317 75.4218C403.567 79.4825 402.563 82.9034 401.305 85.6844C400.042 88.3915 398.609 90.5661 397.006 92.2081C395.431 93.7318 393.8 94.8486 392.113 95.5587C390.426 96.2614 388.797 96.646 387.227 96.7125ZM387.954 80.3479C389.701 79.9706 391.048 78.4803 391.994 75.8767C392.963 73.2288 393.448 69.2643 393.448 63.9832C393.448 60.6548 393.222 58.0882 392.77 56.2834C392.309 54.4935 391.691 53.3249 390.918 52.7775C390.116 52.1784 389.186 52.0305 388.129 52.3337C386.437 52.8071 385.095 54.3456 384.102 56.9491C383.1 59.5231 382.599 63.103 382.599 67.6888C382.599 72.5261 383.084 75.9433 384.053 77.9403C385.027 79.9078 386.327 80.7103 387.954 80.3479ZM430.432 94.7488C426.699 84.0313 422.962 73.6319 419.22 63.5505C419.164 68.9647 419.122 73.3841 419.094 76.8087C419.062 80.2258 419.031 82.9292 419.003 84.9189C419.003 86.9011 419.003 88.336 419.003 89.2236C419.003 90.126 419.003 90.7584 419.003 91.1208C418.225 91.7125 417.321 92.2562 416.291 92.7517C415.289 93.2547 414.229 93.7577 413.111 94.2606C411.969 94.6674 410.881 94.8967 409.847 94.9485C409.786 93.8316 409.742 92.6371 409.714 91.3649C409.662 90.1741 409.637 88.8908 409.637 87.515C409.721 80.9322 409.807 74.0054 409.895 66.7347C409.979 59.3974 410.066 52.2043 410.154 45.1555C410.154 40.6066 410.152 36.0023 410.147 31.3425C414.569 28.3248 418.994 25.2146 423.421 22.0119C423.51 22.3299 423.785 23.1916 424.246 24.597C424.675 26.0319 425.22 27.7885 425.882 29.867C426.539 31.9823 427.242 34.2383 427.993 36.6347C428.71 39.083 429.412 41.4572 430.097 43.7575C430.758 46.0356 431.318 48.0142 431.774 49.6932C431.774 42.2597 431.772 34.8707 431.767 27.526C431.795 26.202 431.823 24.9705 431.851 23.8314C431.884 22.5962 431.942 21.4904 432.026 20.5141C434.221 19.0644 436.413 17.5925 438.603 16.0984C438.976 15.9209 439.349 15.6916 439.722 15.4105C440.127 15.2108 440.516 15.0185 440.889 14.8336C440.945 16.0762 440.987 17.4224 441.015 18.8721C441.043 20.344 441.057 21.9231 441.057 23.6095C441.006 25.6214 440.966 28.2767 440.938 31.5755C440.938 34.9039 440.938 37.8773 440.938 40.4957C440.938 44.5415 440.924 48.9609 440.896 53.7539C440.896 58.5542 440.882 63.1511 440.854 67.5446C440.84 71.5609 440.824 75.5808 440.805 79.6045C440.805 81.2095 440.822 82.7739 440.854 84.2976C440.878 85.7991 440.917 87.2007 440.973 88.5025C440.656 88.7392 440.297 88.9684 439.897 89.1903C439.473 89.3235 438.916 89.5676 438.226 89.9226C437.508 90.3516 436.532 90.9026 435.297 91.5757C434.062 92.3227 432.441 93.3804 430.432 94.7488ZM460 0C457.922 22.1968 455.843 44.2457 453.765 66.1466C453.42 66.2206 453.075 66.2909 452.73 66.3574C452.358 66.4314 451.999 66.5017 451.654 66.5682C450.661 66.7605 449.671 66.9529 448.683 67.1452C448.441 47.3078 448.196 27.77 447.949 8.53183C447.949 7.3262 448.105 6.63833 448.418 6.46821C448.823 6.25372 449.496 5.89129 450.438 5.38093C451.356 4.87797 452.39 4.30844 453.541 3.67235C454.688 2.9327 455.792 2.26702 456.854 1.6753C457.903 1.10577 458.952 0.547339 460 0ZM446.097 99.9411C446.283 92.6112 446.472 85.2221 446.663 77.7739C447.381 77.5668 448.21 77.4595 449.151 77.4521C450.102 77.319 451.064 77.2413 452.038 77.2192C452.989 77.1896 453.837 77.1193 454.583 77.0084C454.583 77.5557 454.552 78.7613 454.492 80.6252C454.464 82.4669 454.422 84.5343 454.366 86.8272C454.31 89.0831 454.25 91.3945 454.184 93.7614C454.128 96.0912 454.086 98.0476 454.058 99.6305C453.942 99.7414 453.597 99.8006 453.024 99.808C452.479 99.9189 451.789 99.9818 450.955 99.9966C450.153 100.011 449.308 99.9781 448.418 99.8967C447.555 99.9189 446.782 99.9337 446.097 99.9411Z"
fill="currentColor">
</path>
</svg>
<div
class="absolute inset-0 flex items-center justify-center pointer-events-auto select-text whitespace-nowrap text-[64px] tracking-[0.02em] leading-none text-transparent bg-transparent"
role="text"
aria-label="Launching soon!">
Launching soon!
</div>
</div>
<div class="flex flex-col gap-12px">
<p class="text-p3 lg:text-p2 text-center">
Generate custom design system that speaks both des and dev.
<br>
</br>
Sane defaults, framework-agnostic components,
<br>
</br>
and AI-powered customization.
</p>
</div>
<div class="flex flex-col gap-8px">
<label class="flex flex-col gap-4px">
<div class="flex flex-col relative">
<input
type="email"
name="waitlist_subscriber[email]"
placeholder="Your email"
class="flex gap-8px items-center text-p2 peer text-black py-8px rounded-8px border placeholder:text-black-500 outline-none transition-all dark:text-white dark:placeholder:text-black-400 px-16px bg-white border-accent-200 hover:border-accent-600 focus:border-accent-600 active:border-accent-600 user-invalid:border-red-600 user-invalid:hover:border-red-600 user-invalid:focus:border-red-600 user-invalid:active:border-red-600 user-invalid:bg-red-50 dark:bg-black dark:border-black-600 dark:hover:border-black-400 dark:focus:border-black-400 dark:active:border-black-400 dark:user-invalid:bg-red-900 dark:user-invalid:bg-black shadow-[0_1px_2px_0px_#0000000D] focus:shadow-[0_0_0_2px_#0F172A33] dark:shadow-[0_1px_2px_0px_rgba(255,255,255,0.06)] dark:focus:shadow-[0_0_0_2px_rgba(255,255,255,0.33)] disabled:bg-gray-50 disabled:border-gray-100 dark:disabled:bg-gray-800 dark:disabled:border-gray-700 disabled:shadow-none [&_svg]:w-16px [&_svg]:h-16px [&_svg]:me-4px"
pattern="^[^ @]+@[^ @]+.[^ @]+$"
value=""
required="required">
</input>
</div>
</label>
<button
name="button"
type="button"
class="flex gap-8px items-center justify-center whitespace-nowrap py-4px px-16px text-btn2 [&>svg]:w-16px [&>svg]:h-16px rounded-8px text-white dark:text-accent-900 border disabled:opacity-30 focus:shadow-[0_0_0_2px_#FFFFFF,0_0_0_4px_#0F172A] dark:focus:shadow-[0_0_0_2px_#2d2e33,0_0_0_4px_#FFFFFF] bg-accent-900 border-accent-900 hover:bg-accent-700 hover:border-accent-700 focus:bg-accent-700 focus:border-accent-700 active:bg-accent-500 active:border-accent-500 dark:bg-white dark:border-white dark:hover:bg-accent-200 dark:hover:border-accent-200 dark:focus:bg-accent-200 dark:focus:border-accent-200 dark:active:bg-accent-400 dark:active:border-accent-400"
title="Join waitlist">
Join waitlist
</button>
</div>
</div>
</div>
<div class="absolute z-[-1] max-w-[800px] max-h-[800px] w-full h-full left-[50%] top-[50%] -translate-[50%]">
<div
class="absolute -left-[60%] -top-[60%] w-[100dvw] max-w-[800px] rotate-45"
aria-hidden="true">
<div
class="site-element site-element_square"
data-element="square"
data-element-place="">
<picture class="w-full max-w-full ">
<source
srcset="/assets/images/shared/elements/square-800/600.avif,
/assets/images/shared/elements/square-800/1200.avif 2x"
media="(max-width: 576px)"
type="image/avif">
<source
srcset="/assets/images/shared/elements/square-800/1200.avif,
/assets/images/shared/elements/square-800/1800.avif 2x"
media="(max-width: 992px)"
type="image/avif">
<source
srcset="/assets/images/shared/elements/square-800/3000.avif,
/assets/images/shared/elements/square-800/3000.avif 2x"
type="image/avif">
<source
srcset="/assets/images/shared/elements/square-800/600.webp,
/assets/images/shared/elements/square-800/1200.webp"
media="(max-width: 576px)"
type="image/webp">
<source
srcset="/assets/images/shared/elements/square-800/1200.webp,
/assets/images/shared/elements/square-800/1800.webp 2x"
media="(max-width: 992px)"
type="image/webp">
<source
srcset="/assets/images/shared/elements/square-800/3000.webp,
/assets/images/shared/elements/square-800/3000.webp 2x"
type="image/webp">
<source
srcset="/assets/images/shared/elements/square-800/600.jpg'),
/assets/images/shared/elements/square-800/1200.jpg"
media="(max-width: 576px)">
<source
srcset="/assets/images/shared/elements/square-800/1200.jpg,
/assets/images/shared/elements/square-800/1800.jpg 2x"
media="(max-width: 992px)">
<source srcset="/assets/images/shared/elements/square-800/3000.jpg,
/assets/images/shared/elements/square-800/3000.jpg 2x">
<img
class="w-full"
src="/assets/images/shared/elements/square-800/3000.jpg"
alt="decorative element"
style="aspect-ratio: 1 / 1"
loading="lazy">
</img>
</source>
</source>
</source>
</source>
</source>
</source>
</source>
</source>
</source>
</picture>
</div>
</div>
<div
class="absolute -right-[60%] -bottom-[60%] w-[100dvw] max-w-[900px]"
aria-hidden="true">
<div
class="site-element site-element_circle"
data-element="circle"
data-element-place="">
<picture class="w-full max-w-full ">
<source
srcset="/assets/images/shared/elements/circle-1000/600.avif,
/assets/images/shared/elements/circle-1000/1200.avif 2x"
media="(max-width: 576px)"
type="image/avif">
<source
srcset="/assets/images/shared/elements/circle-1000/1200.avif,
/assets/images/shared/elements/circle-1000/1800.avif 2x"
media="(max-width: 992px)"
type="image/avif">
<source
srcset="/assets/images/shared/elements/circle-1000/3000.avif,
/assets/images/shared/elements/circle-1000/3000.avif 2x"
type="image/avif">
<source
srcset="/assets/images/shared/elements/circle-1000/600.webp,
/assets/images/shared/elements/circle-1000/1200.webp"
media="(max-width: 576px)"
type="image/webp">
<source
srcset="/assets/images/shared/elements/circle-1000/1200.webp,
/assets/images/shared/elements/circle-1000/1800.webp 2x"
media="(max-width: 992px)"
type="image/webp">
<source
srcset="/assets/images/shared/elements/circle-1000/3000.webp,
/assets/images/shared/elements/circle-1000/3000.webp 2x"
type="image/webp">
<source
srcset="/assets/images/shared/elements/circle-1000/600.jpg'),
/assets/images/shared/elements/circle-1000/1200.jpg"
media="(max-width: 576px)">
<source
srcset="/assets/images/shared/elements/circle-1000/1200.jpg,
/assets/images/shared/elements/circle-1000/1800.jpg 2x"
media="(max-width: 992px)">
<source srcset="/assets/images/shared/elements/circle-1000/3000.jpg,
/assets/images/shared/elements/circle-1000/3000.jpg 2x">
<img
class="w-full"
src="/assets/images/shared/elements/circle-1000/3000.jpg"
alt="decorative element"
style="aspect-ratio: 1 / 1"
loading="lazy">
</img>
</source>
</source>
</source>
</source>
</source>
</source>
</source>
</source>
</source>
</picture>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Usage
To use this component copy our js code:
/**
* 3D Mouse Tilt Effect
* Creates a 3D tilt effect that follows the mouse cursor
*/
class MouseTilt3D {
constructor(container, target_or_options, options = {}) {
// Determine if second parameter is target element or options
let target;
if (target_or_options instanceof HTMLElement) {
// If second parameter is HTMLElement, it's the target
target = target_or_options;
// Use provided options as third parameter
} else {
// If second parameter is not HTMLElement, it's options
target = container;
options = target_or_options || {};
}
// Save container and target elements
this.container = container;
this.target = target;
// Merge default options with user-defined options
this.options = {
max_tilt: 15, // Maximum tilt angle in degrees
perspective: 1000, // CSS perspective value
easing: 'cubic-bezier(0.03, 0.98, 0.52, 0.99)', // Transition easing function
scale: 1.05, // Scale factor on hover
speed: 500, // Animation speed in milliseconds
glare: false, // Enable glare effect
glare_max_opacity: 0.7, // Maximum opacity for glare effect
reset_on_leave: true, // Reset to initial state when mouse leaves
self_prevent: false, // Block tilt effect when hovering over tilt target
...options,
};
// Disable glare if self_prevent is enabled (inconsistent to show glare when tilt is blocked)
if (this.options.self_prevent) {
this.options.glare = false;
}
// Internal state variables
this.is_active = true;
this.glare_element = null;
this.animation_frame = null;
this.is_over_target = false; // Track if mouse is over target element
this.is_transform_reset = true; // Track if transform is in reset state
// Store original styles to restore on destroy
this.original_target_styles = {
transform: target.style.transform,
transition: target.style.transition,
transform_style: target.style.transformStyle,
backface_visibility: target.style.backfaceVisibility,
will_change: target.style.willChange,
};
// Bind event handlers to maintain 'this' context
this.handle_mouse_enter = this.handle_mouse_enter.bind(this);
this.handle_mouse_move = this.handle_mouse_move.bind(this);
this.handle_mouse_leave = this.handle_mouse_leave.bind(this);
// Initialize the effect
this.init();
}
/**
* Initialize the tilt effect
*/
init() {
// Set up target styles for 3D effect
this.setup_target();
// Create glare element if enabled
if (this.options.glare) {
this.create_glare();
}
// Add event listeners to container
this.add_event_listeners();
}
/**
* Set up target element with necessary CSS styles
*/
setup_target() {
// Apply 3D transform styles to target element
this.target.style.transformStyle = 'preserve-3d';
this.target.style.backfaceVisibility = 'hidden';
this.target.style.willChange = 'transform';
this.target.style.transition = `transform ${this.options.speed}ms ${this.options.easing}`;
// If target is different from container, ensure it has proper positioning
if (this.target !== this.container) {
// Ensure target has position relative or absolute for proper 3D context
const computed_style = window.getComputedStyle(this.target);
if (computed_style.position === 'static') {
this.target.style.position = 'relative';
}
}
}
/**
* Create glare effect element
*/
create_glare() {
this.glare_element = document.createElement('div');
// Set glare element styles
this.glare_element.style.position = 'absolute';
this.glare_element.style.top = '0';
this.glare_element.style.left = '0';
this.glare_element.style.width = '100%';
this.glare_element.style.height = '100%';
this.glare_element.style.pointerEvents = 'none';
this.glare_element.style.borderRadius = 'inherit';
this.glare_element.style.opacity = '0';
this.glare_element.style.transition = `opacity ${this.options.speed}ms ease`;
this.glare_element.style.zIndex = '2';
// Ensure container has relative positioning for absolute child
const container_style = window.getComputedStyle(this.container);
if (container_style.position === 'static') {
this.container.style.position = 'relative';
}
// Add glare element to target (not container)
this.target.appendChild(this.glare_element);
}
/**
* Add mouse event listeners to container
*/
add_event_listeners() {
this.container.addEventListener('mouseenter', this.handle_mouse_enter);
this.container.addEventListener('mousemove', this.handle_mouse_move);
this.container.addEventListener('mouseleave', this.handle_mouse_leave);
}
/**
* Handle mouse enter event
*/
handle_mouse_enter() {
if (!this.is_active) return;
// Apply initial scale transform to target
this.target.style.transform = `
perspective(${this.options.perspective}px)
scale3d(${this.options.scale}, ${this.options.scale}, ${this.options.scale})
`;
this.is_transform_reset = false;
this.is_over_target = false;
// Show glare effect if enabled
if (this.glare_element) {
this.glare_element.style.opacity = '1';
}
}
/**
* Handle mouse move event
* Calculates tilt based on mouse position relative to container
*/
handle_mouse_move(event) {
if (!this.is_active) return;
// Block tilt effect when hovering over tilt target
if (this.options.self_prevent) {
const target_rect = this.target.getBoundingClientRect();
const mouse_x = event.clientX;
const mouse_y = event.clientY;
// Check if mouse is within target bounds
const currently_over_target = (
mouse_x >= target_rect.left &&
mouse_x <= target_rect.right &&
mouse_y >= target_rect.top &&
mouse_y <= target_rect.bottom
);
// If mouse is over target element, reset transform and skip tilt
if (currently_over_target) {
this.reset_transform();
this.is_over_target = true;
return;
}
// If mouse just left the target element, reset transform
if (this.is_over_target) {
this.reset_transform();
this.is_over_target = false;
}
}
// Cancel any pending animation frame
if (this.animation_frame) {
cancelAnimationFrame(this.animation_frame);
}
// Use requestAnimationFrame for smooth animation
this.animation_frame = requestAnimationFrame(() => {
this.calculate_and_apply_tilt(event);
});
}
/**
* Reset target transform to initial state
*/
reset_transform() {
if (!this.options.reset_on_leave || this.is_transform_reset) return;
this.target.style.transform = `
perspective(${this.options.perspective}px)
rotateX(0deg)
rotateY(0deg)
scale3d(1, 1, 1)
`;
this.is_transform_reset = true;
}
/**
* Calculate tilt angles and apply transform to target
*/
calculate_and_apply_tilt(event) {
this.is_transform_reset = false;
// Use container bounds for mouse tracking
const container_rect = this.container.getBoundingClientRect();
// Calculate container center
const center_x = container_rect.left + container_rect.width / 2;
const center_y = container_rect.top + container_rect.height / 2;
// Calculate mouse position relative to center (-1 to 1)
const mouse_x = event.clientX - center_x;
const mouse_y = event.clientY - center_y;
const percentage_x = mouse_x / (container_rect.width / 2);
const percentage_y = mouse_y / (container_rect.height / 2);
// Calculate tilt angles based on mouse position
const tilt_x = (this.options.max_tilt * percentage_y * -1).toFixed(2);
const tilt_y = (this.options.max_tilt * percentage_x).toFixed(2);
// Apply the transform to target element
this.target.style.transform = `
perspective(${this.options.perspective}px)
rotateX(${tilt_x}deg)
rotateY(${tilt_y}deg)
scale3d(${this.options.scale}, ${this.options.scale}, ${this.options.scale})
`;
// Update glare position if enabled
this.update_glare_position(percentage_x, percentage_y);
}
/**
* Update glare position based on mouse position
*/
update_glare_position(percentage_x, percentage_y) {
if (!this.glare_element) return;
// Calculate glare gradient angle based on mouse position
const glare_angle = percentage_x * 45;
// Update glare gradient
this.glare_element.style.background = `linear-gradient(
${glare_angle}deg,
rgba(255, 255, 255, 0) 0%,
rgba(255, 255, 255, ${this.options.glare_max_opacity}) 100%
)`;
}
/**
* Handle mouse leave event
*/
handle_mouse_leave() {
if (!this.is_active || !this.options.reset_on_leave) return;
// Reset transform to initial state
this.reset_transform();
// Hide glare effect if enabled
if (this.glare_element) {
this.glare_element.style.opacity = '0';
}
// Reset target tracking state
this.is_over_target = false;
}
/**
* Update effect options
* @param {Object} new_options - New options to merge with current options
*/
update(new_options) {
this.options = { ...this.options, ...new_options };
// Update transition if speed changed
this.target.style.transition =
`transform ${this.options.speed}ms ${this.options.easing}`;
}
/**
* Enable the tilt effect
*/
enable() {
this.is_active = true;
}
/**
* Disable the tilt effect
*/
disable() {
this.is_active = false;
this.target.style.transform = '';
if (this.glare_element) {
this.glare_element.style.opacity = '0';
}
}
/**
* Remove event listeners and restore original styles
*/
destroy() {
// Remove event listeners from container
this.container.removeEventListener('mouseenter', this.handle_mouse_enter);
this.container.removeEventListener('mousemove', this.handle_mouse_move);
this.container.removeEventListener('mouseleave', this.handle_mouse_leave);
// Cancel any pending animation frame
if (this.animation_frame) {
cancelAnimationFrame(this.animation_frame);
}
// Restore original target styles
this.target.style.transform = this.original_target_styles.transform;
this.target.style.transition = this.original_target_styles.transition;
this.target.style.transformStyle = this.original_target_styles.transform_style;
this.target.style.backfaceVisibility = this.original_target_styles.backface_visibility;
this.target.style.willChange = this.original_target_styles.will_change;
// Remove glare element if exists
if (this.glare_element && this.glare_element.parentNode) {
this.glare_element.parentNode.removeChild(this.glare_element);
}
// Clear references
this.container = null;
this.target = null;
this.glare_element = null;
}
}
/**
* Factory function to create a new MouseTilt3D instance
* Supports two usage patterns:
* 1. add_mouse_tilt_effect(container, options) - effect applied to container
* 2. add_mouse_tilt_effect(container, target, options) - effect applied to target
*
* @param {HTMLElement} container - The element to track mouse movement
* @param {HTMLElement|Object} target_or_options - Target element or options object
* @param {Object} options - Configuration options for the effect
* @returns {MouseTilt3D} A new instance of MouseTilt3D
*/
const add_mouse_tilt_effect = (container, target_or_options, options = {}) => {
// Determine if second parameter is target element or options
if (target_or_options instanceof HTMLElement) {
// Three parameters: container, target, options
return new MouseTilt3D(container, target_or_options, options);
} else {
// Two parameters: container, options (target = container)
return new MouseTilt3D(container, target_or_options || {});
}
};
/**
* Initialize all tilt effects on the page
* Supports data attributes for both container and target
*
* @param {Object} default_options - Default options for all tilt effects
*/
const init_tilt_effects = (default_options = {}) => {
// Find all elements with data-tilt attribute (these are containers)
document.querySelectorAll('[data-tilt]').forEach((container) => {
// Check if effect is already initialized on this container
if (container._tilt_effect) {
return; // Skip already initialized elements
}
// Parse options from data attributes
const data_options = {};
// Get max tilt from data attribute
if (container.dataset.tiltMax) {
data_options.max_tilt = parseFloat(container.dataset.tiltMax);
}
// Get perspective from data attribute
if (container.dataset.tiltPerspective) {
data_options.perspective = parseFloat(container.dataset.tiltPerspective);
}
// Get scale from data attribute
if (container.dataset.tiltScale) {
data_options.scale = parseFloat(container.dataset.tiltScale);
}
// Check if glare is enabled
if (container.dataset.tiltGlare) {
data_options.glare = container.dataset.tiltGlare === 'true';
}
// Check if reset on leave is disabled
if (container.dataset.tiltResetOnLeave) {
data_options.reset_on_leave = container.dataset.tiltResetOnLeave === 'true';
}
// Check if self-prevent is enabled (block tilt when hovering over tilt target)
if (container.dataset.tiltSelfPrevent) {
data_options.self_prevent = container.dataset.tiltSelfPrevent === 'true';
}
// Check if target element is specified
let target_element = container;
if (container.dataset.tiltTarget) {
const target_selector = container.dataset.tiltTarget;
target_element = container.querySelector(target_selector) ||
document.querySelector(target_selector);
if (!target_element) {
console.warn(`MouseTilt3D: Target element "${target_selector}" not found`);
target_element = container;
}
}
// Merge all options: data attributes override defaults
const options = { ...default_options, ...data_options };
// Create new tilt effect instance using factory function
const tilt_effect = add_mouse_tilt_effect(container, target_element, options);
// Store reference to tilt effect on container for later access
container._tilt_effect = tilt_effect;
});
};
/**
* Remove tilt effect from specific container
* @param {HTMLElement} container - Container element to remove tilt effect from
*/
const remove_mouse_tilt_effect = (container) => {
if (container._tilt_effect) {
container._tilt_effect.destroy();
delete container._tilt_effect;
}
};
/**
* Remove all tilt effects from the page
*/
const destroy_all_tilt_effects = () => {
document.querySelectorAll('[data-tilt]').forEach((container) => {
remove_mouse_tilt_effect(container);
});
};
// Make functions available globally
window.add_mouse_tilt_effect = add_mouse_tilt_effect;
window.init_tilt_effects = init_tilt_effects;
window.remove_mouse_tilt_effect = remove_mouse_tilt_effect;
window.destroy_all_tilt_effects = destroy_all_tilt_effects;
// Export for module usage (if supported)
if (typeof module !== 'undefined' && module.exports) {
module.exports = {
MouseTilt3D,
add_mouse_tilt_effect,
init_tilt_effects,
remove_mouse_tilt_effect,
destroy_all_tilt_effects,
};
}
Then init effect:
init_tilt_effects();
Or initialize with custom params:
init_tilt_effects({
max_tilt: 15,
glare: false,
scale: 1.05,
});
Auto init
Insert in the end of JS (mouse-tilt.js) file this:
document.addEventListener("DOMContentLoaded", () => init_tilt_effects());
Then connect:
<script src="mouse-tilt.js"></script>
Params
Available parameters for use in init_tilt_effects or add_mouse_tilt_effect:
init_tilt_effects({
max_tilt: 15, // Maximum tilt angle in degrees
perspective: 1000, // CSS perspective value
easing: 'cubic-bezier(0.03, 0.98, 0.52, 0.99)', // Transition easing function
scale: 1.05, // Scale factor on hover
speed: 500, // Animation speed in milliseconds
glare: false, // Enable glare effect
glare_max_opacity: 0.7, // Maximum opacity for glare effect
reset_on_leave: true, // Reset to initial state when mouse leaves
self_prevent: false, // Block tilt effect when hovering over tilt target
});
// Or with window method
const tilt2 = add_mouse_tilt_effect(parent, child, {
max_tilt: 25,
perspective: 1200,
scale: 1.05,
glare: false,
});
// Or with module
const tilt_effect = new MouseTilt3D(container, {
max_tilt: 20,
perspective: 1500,
scale: 1.1,
glare: true,
glare_max_opacity: 0.5,
speed: 300,
});
You can control the effect using the returned instance:
tilt_effect.disable(); // Temporarily disable the effect
tilt_effect.enable(); // Re-enable the effect
tilt_effect.update({ max_tilt: 30 }); // Update options
tilt_effect.destroy(); // Completely remove the effect
These attributes override the global options passed to init_tilt_effects() for that specific tilt effect.
Data attributes
You can also configure individual tilt effects via data attributes on the container:
data-tilt-max – maximum tilt angle in degrees (same as max_tilt).
data-tilt-perspective – CSS perspective value (same as perspective).
data-tilt-scale – scale factor on hover (same as scale).
data-tilt-glare – enable glare effect (boolean, "true" or "false").
data-tilt-reset-on-leave – reset to initial state when mouse leaves (boolean).
data-tilt-target – selector for target element to apply tilt effect.
data-tilt-self-prevent – block tilt effect when hovering over tilt target (boolean).