### Install hover-tilt with bun Source: https://hover-tilt.simey.me/getting-started Installs the hover-tilt package using the bun runtime and package manager. bun is a fast, all-in-one JavaScript toolkit. ```bash bun add hover-tilt ``` -------------------------------- ### Install hover-tilt with pnpm Source: https://hover-tilt.simey.me/getting-started Installs the hover-tilt package using the pnpm package manager. pnpm is known for its efficient disk space usage and faster installation times. ```bash pnpm add hover-tilt ``` -------------------------------- ### Install Svelte Integration for Astro Source: https://hover-tilt.simey.me/usage Provides the command to install the Svelte integration for Astro. This setup is necessary to use Svelte components, including Hover Tilt when configured as a Svelte component, within an Astro project. ```bash npx astro add svelte ``` -------------------------------- ### Install hover-tilt with npm Source: https://hover-tilt.simey.me/getting-started Installs the hover-tilt package using the npm package manager. This is the standard way to add JavaScript libraries to a project managed by npm. ```bash npm install hover-tilt ``` -------------------------------- ### Basic HoverTilt Web Component Example Source: https://hover-tilt.simey.me/usage Illustrates the basic usage of the Hover Tilt Web Component after its script has been included. It shows how to apply tilt and scale factors using HTML attributes and includes example styling for the content. ```html

Card Title

Hover over this card to see the effect!

``` -------------------------------- ### Install hover-tilt with yarn Source: https://hover-tilt.simey.me/getting-started Installs the hover-tilt package using the yarn package manager. yarn is another popular choice for managing JavaScript dependencies. ```bash yarn add hover-tilt ``` -------------------------------- ### Basic Svelte Component with Hover Tilt Source: https://hover-tilt.simey.me/getting-started Demonstrates a basic implementation of the hover-tilt component within a Svelte application. It imports the HoverTilt component and applies it to a div with some internal content. ```svelte

Basic Example

Hover over this card to see the default tilt effect

``` -------------------------------- ### Basic HoverTilt Svelte Example with Styling Source: https://hover-tilt.simey.me/usage Shows a basic Svelte example of the HoverTilt component with applied tilt and scale factors, along with custom CSS styling for the content inside the tiltable area. This allows for visually enhanced tilt effects. ```svelte

Card Title

Hover over this card to see the effect!

``` -------------------------------- ### Custom Hover Tilt Gradient Examples Source: https://hover-tilt.simey.me/advanced/custom-gradient This section provides various CSS examples for custom glare gradients that can be applied to the HoverTilt component. Each example demonstrates a different visual effect by utilizing CSS `calc()` and the `--gradient-x`, `--gradient-y` variables. ```css /* Custom Colored Gradient */ :global(.custom-gradient) { --hover-tilt-custom-gradient: radial-gradient( circle at var(--gradient-x, 50%) var(--gradient-y, 50%), rgba(125, 255, 194, calc(var(--hover-tilt-glare-intensity, 1) * 0.5)) 10%, rgba(255, 255, 255, 0) 80%, transparent 70% ); } /* Specular Highlight */ :global(.specular-highlight) { --hover-tilt-custom-gradient: radial-gradient( 80% 100% at var(--gradient-x, 50%) var(--gradient-y, 50%), rgb(255 255 255 / calc(var(--hover-tilt-glare-intensity, 1))) 50%, transparent 55% ); } /* Aurora Sweep */ :global(.aurora-sweep) { --hover-tilt-custom-gradient: conic-gradient( from calc(var(--hover-tilt-angle, 0)) at center center, rgba(255, 255, 255, calc(var(--hover-tilt-glare-intensity, 1) * 0.9)), rgba(6, 182, 212, calc(var(--hover-tilt-glare-intensity, 1) * 0.7)), rgba(255, 255, 255, calc(var(--hover-tilt-glare-intensity, 1) * 0.9)) ); } /* Luminance Beam */ :global(.luminance-beam) { --hover-tilt-custom-gradient: linear-gradient( 120deg, rgb(0 0 0 / 0) calc((var(--gradient-x, 50%) / 2 + var(--gradient-y, 50%) / 2) - 60%), rgb(249 218 173 / var(--hover-tilt-glare-intensity, 1)) calc((var(--gradient-x, 50%) / 2 + var(--gradient-y, 50%) / 2)), rgb(0 0 0 / 0) calc((var(--gradient-x, 50%) / 2 + var(--gradient-y, 50%) / 2) + 60%) ); } /* Inverted Gradient */ :global(.inverted-gradient) { --hover-tilt-custom-gradient: radial-gradient( 200% 200% at calc( var(--gradient-x, 50%) * 2 - 50% ) calc( var(--gradient-y, 50%) * 2 - 50% ), transparent 30%, rgb(255 255 255 / var(--hover-tilt-glare-intensity, 1)) 80% ); } ``` -------------------------------- ### Simple Custom Shadow in Web Component Source: https://hover-tilt.simey.me/advanced/custom-shadow Example of implementing a simple custom shadow for the Hover Tilt component when used as a Web Component. It utilizes the `::part(container)` selector to target the component's internal structure. ```html
Simple Custom Shadow
``` -------------------------------- ### Use HoverTilt Web Component in React Source: https://hover-tilt.simey.me/usage Provides an example of integrating the Hover Tilt Web Component within a React application. It shows how to import the component and bind its content to React state, allowing for dynamic updates. ```javascript import React, { useState } from 'react'; import 'hover-tilt/web-component'; export function MyComponent() { const [msg, setMsg] = useState('Tilt me!'); return ( <>

{msg}

setMsg(event.target.value)} placeholder="Type a message..." /> ); } ``` -------------------------------- ### Simple Custom Shadow in Svelte Source: https://hover-tilt.simey.me/advanced/custom-shadow Example of implementing a simple custom shadow for the Hover Tilt component within a Svelte application. It uses the `:global()` selector to apply styles to the component's container. ```svelte
Simple Custom Shadow
``` -------------------------------- ### Basic Hover Tilt Effect (Svelte & Web Component) Source: https://hover-tilt.simey.me/examples/props Demonstrates the fundamental usage of the HoverTilt component. It applies a subtle tilt effect to the content within the component when the user hovers over it. This example shows the simplest implementation with default properties. ```svelte

Basic Example

Hover over this card to see the default tilt effect

``` ```html

Basic Example

Hover over this card to see the default tilt effect

``` -------------------------------- ### Configuring Glare Intensity and Hue (Svelte & Web Component) Source: https://hover-tilt.simey.me/examples/props Explains how to customize the glare effect, which follows the cursor and adds lighting. The `glareIntensity` prop controls the brightness of the glare, and `glareHue` can be used to adjust its color for a personalized aesthetic. ```svelte
Default
glareIntensity: 0.5
glareIntensity: 0.8, glareHue: blue
``` ```html
Default
glare-intensity: 0.5
glare-intensity: 0.8, glare-hue: blue
``` -------------------------------- ### Import and Use HoverTilt Web Component Source: https://hover-tilt.simey.me/usage Integrate the Hover Tilt Web Component into any Astro project without framework-specific setup by importing 'hover-tilt/web-component'. This registers the `` custom element, allowing direct use in templates with customizable props like 'tilt-factor' and 'scale-factor'. ```html import 'hover-tilt/web-component';

Card Title

Hover over this card to see the effect!

``` -------------------------------- ### Apply Hover Tilt Web Component to DOM Source: https://hover-tilt.simey.me/examples/web-component Applies the Hover Tilt Web Component to an element in the DOM. This example shows how to use the custom `` tag with attributes like `shadow` and `scale-factor` to customize the tilt effect. ```html

Basic Example

Hover over this card to see the default tilt effect

``` -------------------------------- ### Apply PNG Mask with Luminance Mode (Svelte/Web Component) Source: https://hover-tilt.simey.me/advanced/glare-masks This example demonstrates applying a PNG mask to the glare effect using the 'luminance' mode. It shows how to reference a monochrome PNG asset for the mask and set the appropriate glareMaskMode. This is suitable for black & white PNG masks. ```svelte Your content here ``` ```html Your content here ``` -------------------------------- ### Implementing Shadow Effects on Hover (Svelte & Web Component) Source: https://hover-tilt.simey.me/examples/props Shows how to enable and customize dynamic shadow effects that follow the cursor during hover using the `shadow` and `shadowBlur` props. The `shadow` prop activates the effect, while `shadowBlur` controls its intensity, providing a dynamic visual enhancement. ```svelte
Default
shadow
shadowBlur: 60
``` ```html
Default
shadow
shadow-blur: 60
``` -------------------------------- ### Configure Enter Delay for Hover Tilt Component Source: https://hover-tilt.simey.me/examples/props Control the delay before the hover tilt animation activates using the `enterDelay` prop. This prevents flickering by waiting for sustained cursor entry. The default is 0ms. ```html
Default
enterDelay: 300ms
``` ```html
Default
enter-delay: 300ms
``` -------------------------------- ### Configure Exit Delay for Hover Tilt Component Source: https://hover-tilt.simey.me/examples/props Adjust the delay before the component returns to its default state after the cursor leaves using the `exitDelay` prop. This allows for smoother transitions. The default is 200ms. ```html
Default
exitDelay: 1000ms
exitDelay: 0ms
``` ```html
Default
exit-delay: 1000ms
exit-delay: 0ms
``` -------------------------------- ### Apply SVG Mask with Alpha Mode (Svelte/Web Component) Source: https://hover-tilt.simey.me/advanced/glare-masks This example demonstrates using a transparent SVG sourced from a local folder as a glare mask with the 'alpha' mode. It highlights how to link an SVG file and use 'alpha' mode when the SVG has a transparent background. ```svelte Your content here ``` ```html Your content here ``` -------------------------------- ### Configure Blend Mode for Hover Tilt Component Source: https://hover-tilt.simey.me/examples/props Customize how the glare effect integrates with the content using the `blendMode` prop. This prop accepts various CSS blend modes such as 'overlay', 'screen', 'multiply', etc. The default is 'overlay'. ```html
Default (overlay)
blendMode: color-dodge
blendMode: plus-lighter
``` ```html
Default (overlay)
blend-mode: luminosity
blend-mode: plus-lighter
``` -------------------------------- ### Svelte Neon Underglow with Hover Tilt Source: https://hover-tilt.simey.me/advanced/custom-shadow Implements a neon underglow shadow effect in Svelte using the HoverTilt component. This example defines custom shadow styles within a Svelte style block, accessible via the :global() selector. ```svelte
Neon Underglow
``` -------------------------------- ### Applying Scale Effects on Hover (Svelte & Web Component) Source: https://hover-tilt.simey.me/examples/props Demonstrates how to add a scaling effect to the hovered element using the `scaleFactor` prop. This prop allows for adjusting the size of the element during the hover state, from no scaling to prominent or even negative scaling. ```svelte
scaleFactor: 1
scaleFactor: 1.05
scaleFactor: 1.2
scaleFactor: 0.9
``` ```html
scale-factor: 1
scale-factor: 1.05
scale-factor: 1.2
scale-factor: 0.9
``` -------------------------------- ### Configure Spring Animations for HoverTilt Source: https://hover-tilt.simey.me/examples/props Enables fine-tuning of animation physics for the hover tilt effect using springOptions. Users can adjust stiffness and damping to alter the feel of the interaction, making it more 'boing-y' or smoother. This functionality is available for Svelte and Web Components, with Web Components requiring JSON string values for options. ```svelte
``` ```webcomponent
``` -------------------------------- ### Customize Tilt Spring Options Independently Source: https://hover-tilt.simey.me/examples/props Provides separate control over the spring physics for tilt animations using tiltSpringOptions, distinct from the general springOptions. This allows for nuanced interactions, such as a bouncy scale with a soft tilt. Supported in Svelte and Web Components, with Web Components requiring JSON string values for these options. ```svelte
``` ```webcomponent
``` -------------------------------- ### Apply CSS Gradient Mask with Alpha Mode (Svelte/Web Component) Source: https://hover-tilt.simey.me/advanced/glare-masks This example shows how to use a CSS repeating-radial-gradient as a glare mask with the 'alpha' mode. It illustrates the flexibility of using CSS gradients for masking effects and how to apply the 'alpha' mode for transparency interpretation. ```svelte Your content here ``` ```html Your content here ``` -------------------------------- ### SV Era ex Holo Card Tilt with CSS Pseudo-element Source: https://hover-tilt.simey.me/bespoke/pokemon-cards Simulates the SV Era ex card effect using a linear gradient and a star-pattern image applied via a CSS pseudo-element (`::after`). It leverages background blending and mix-blend modes for the holo effect, with dynamic positioning of the holo image based on tilt. ```html Pokémon Lillie's Clefairy (ex Holo) ``` -------------------------------- ### Controlling Tilt Intensity with tiltFactor and tiltFactorY (Svelte & Web Component) Source: https://hover-tilt.simey.me/examples/props Illustrates how to control the intensity and direction of the tilt effect using the `tiltFactor` and `tiltFactorY` props. `tiltFactor` affects both axes, while `tiltFactorY` specifically modifies the vertical tilt, allowing for customized tilt behavior. ```svelte
tiltFactor: 1
tiltFactor: 2
tiltFactor: 1.5, tiltFactorY: 0.5
``` ```html
tilt-factor: 1
tilt-factor: 2
tilt-factor: 1.5, tilt-factor-y: 0.5
``` -------------------------------- ### Customize Glare Hue with HoverTilt Source: https://hover-tilt.simey.me/examples/props Allows customization of the glare effect's hue using the glareHue prop. This prop takes a numerical value to define the hue, offering subtle color variations. It is supported in both Svelte and Web Component implementations. ```svelte
Default
glareHue: 20
``` ```webcomponent
Default
glare-hue: 20
``` -------------------------------- ### Card with Multiple Glare Masks using Hover Tilt Source: https://hover-tilt.simey.me/bespoke/pokemon-cards This snippet demonstrates creating a card effect with multiple, overlapping foil masks using the hover-tilt component. It utilizes multiple `glare-mask` values combined with `glare-mask-composite='intersect'` to ensure only the overlapping areas are illuminated. The `glare-intensity`, `scale-factor`, and `shadow-blur` are increased to exaggerate the visual effect. ```html Pokémon #0133: Eevee Reverse Holo Masterball ``` -------------------------------- ### Special Illustration Art Card with Hover Tilt Source: https://hover-tilt.simey.me/bespoke/pokemon-cards This snippet demonstrates creating a special illustration art card effect using the hover-tilt component. It layers a rainbow gradient, sparkles image, and glare gradient with specific blend modes and opacity. The `will-change` CSS property is utilized for performance optimization. It takes an image source and applies various hover effects. ```html Pokémon Trainer Lille's Clefairy (Special Illustration Art) ``` -------------------------------- ### HTML Structure for Hover Tilt Card with Multiple Masks Source: https://hover-tilt.simey.me/bespoke/pokemon-cards This HTML snippet defines the structure of a hover-tilt card component. It utilizes custom properties and nested elements to apply complex visual effects like glare and etching masks. The component relies on external assets for mask images and specific styling classes. ```html Pokémon #0197: Umbreon Reverse Holo Masterball
``` -------------------------------- ### Basic Pokémon Card Tilt Source: https://hover-tilt.simey.me/bespoke/pokemon-cards Applies a basic tilt effect to a Pokémon card image. It wraps the image in a hover-tilt component and uses TailwindCSS for rounded corners on the container, which are inherited by the inner parts of the web component. ```html Pokémon #0035: Clefairy ``` -------------------------------- ### Include HoverTilt Web Component Script Locally Source: https://hover-tilt.simey.me/usage Explains how to include the Hover Tilt Web Component script directly from your local 'node_modules' folder in an HTML file. This method requires the 'hover-tilt.js' file to be accessible via the specified path. ```html Your content here ``` -------------------------------- ### Include HoverTilt Web Component Script via CDN Source: https://hover-tilt.simey.me/usage Demonstrates how to load the Hover Tilt Web Component using a Content Delivery Network (CDN). This is a convenient way to include the component without needing to manage local files. ```html ``` -------------------------------- ### Complete Custom Shadow Implementation (Svelte & Web Component) Source: https://hover-tilt.simey.me/advanced/custom-shadow This is the final consolidated code for a basic custom shadow implementation using CSS variables. It combines dynamic positioning and opacity control for the shadow effect, compatible with both Svelte and Web Component targets. ```svelte :global(.simple-card) { --hover-tilt-custom-shadow: calc(var(--shadow-x) * 10px) calc(var(--shadow-y) * 10px + 5px) 5px 10px hsl(0 0% 0% / calc(var(--hover-tilt-opacity, 0) * 0.5 + 0.2)); } ``` ```css .simple-card::part(container) { --hover-tilt-custom-shadow: calc(var(--shadow-x) * 10px) calc(var(--shadow-y) * 10px + 5px) 5px 10px hsl(0 0% 0% / calc(var(--hover-tilt-opacity, 0) * 0.5 + 0.2)); } ``` -------------------------------- ### Control Glare Intensity with HoverTilt Source: https://hover-tilt.simey.me/examples/props Adjusts the intensity of the glare effect on the hover tilt component. The glareIntensity prop accepts a number, with higher values resulting in a more intense glare. This feature is available for both Svelte and Web Component versions. ```svelte
Default
glareIntensity: 0.5
glareIntensity: 1.5
``` ```webcomponent
Default
glare-intensity: 0.5
glare-intensity: 1.5
``` -------------------------------- ### Import and Use HoverTilt in Svelte Source: https://hover-tilt.simey.me/usage Demonstrates how to import and use the HoverTilt Svelte component. It requires importing the component from the 'hover-tilt' package and then using it as a custom element. The content to be tilted is passed as children. ```svelte Your content here ``` -------------------------------- ### Use HoverTilt Web Component in Vue Source: https://hover-tilt.simey.me/usage Demonstrates how to use the Hover Tilt Web Component in a Vue Single File Component. It shows how to import the component and bind its content to a Vue ref for reactive updates, along with a note on potential Vue component resolution warnings. ```vue ``` -------------------------------- ### Enable Custom Shadow with 'shadow' Prop (Svelte & Web Component) Source: https://hover-tilt.simey.me/advanced/custom-shadow This code demonstrates how to enable the dynamic shadow feature in the HoverTilt component by applying the 'shadow' prop. This action instructs the component to render the shadow layer and emit the necessary CSS variables for customization. ```svelte ... ``` ```html ... ``` -------------------------------- ### Configure Tilt Animation Physics Source: https://hover-tilt.simey.me/options/props Provides separate physics options for tilt animations, allowing different animation feels from scale/opacity. Accepts an object with optional 'stiffness' and 'damping' numbers, or undefined. Defaults to 'springOptions'. ```svelte ``` ```html ``` -------------------------------- ### Full Art Foil Pokémon Card Tilt Source: https://hover-tilt.simey.me/bespoke/pokemon-cards Generates a full art foil effect for a Pokémon card with a metallic sheen. It uses a complex glare mask, a 'hard-light' blend mode, and a controlled glare intensity, along with a scale factor for an enhanced tilt. ```html Pokémon Trainer Lillie (Full Art) ``` -------------------------------- ### Load Hover Tilt Web Component Source: https://hover-tilt.simey.me/examples/web-component Loads the Hover Tilt Web Component script from a CDN. This script enables the custom element without needing any framework or build process. ```html ``` -------------------------------- ### Reverse Holo Pokémon Card Tilt with Glare Mask Source: https://hover-tilt.simey.me/bespoke/pokemon-cards Creates a reverse holographic effect on a Pokémon card using the `glare-mask` prop. It specifies a luminance-based mask and sets the blend mode to 'luminosity' for a shiny effect. Note: Safari has rendering issues with luminance-based masks. ```html Pokémon #0035: Clefairy Reverse Holo ``` -------------------------------- ### HTML Structure for Custom Glare - HTML Source: https://hover-tilt.simey.me/bespoke/stacked-3d Sets up the necessary HTML structure for applying a custom glare effect. It uses nested divs and an img tag, with a comment indicating the use of an ::after pseudo-element for the glare. ```html
Bikikin Bottom
```