Skip to content

Getting Started

Install the package using your preferred package manager:

terminal
npm install hover-tilt

Because HoverTilt is available both as a Svelte Component (<HoverTilt />) and a Web Component (<hover-tilt />), there are options for using it;


Import and Use

Import the HoverTilt component in your Svelte file:

App.svelte
<script>
import { HoverTilt } from 'hover-tilt';
</script>
<HoverTilt>Your content here</HoverTilt>

This would look pretty bad, though, so let’s add a bit of styling to make it look better:

Basic Example

The content of the <HoverTilt /> component is passed as a slot, and can be anything you want.

MyComponent.svelte
<script>
import {HoverTilt} from 'hover-tilt';
</script>
<HoverTilt tiltFactor={1.5} scaleFactor={1.1}>
<div class="card">
<h2>Card Title</h2>
<p>Hover over this card to see the effect!</p>
</div>
</HoverTilt>
<style>
.card {
width: 300px;
height: 200px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border-radius: 12px;
padding: 2rem;
color: white;
}
</style>
Preview