Powerful animated SVG icons for Svelte 5 with flexible animation control.
npm install svelte-animate-icons
<script>
import { ActivityIcon } from 'svelte-animate-icons';
</script>
<!-- Default hover animation -->
<ActivityIcon size={24} />
<script>
import { ActivityIcon } from 'svelte-animate-icons';
let iconRef;
</script>
<ActivityIcon bind:this={iconRef} triggers={{ custom: true }} />
<button onclick={() => iconRef?.start()}>Start Animation</button>
<script>
import { ActivityIcon } from 'svelte-animate-icons';
let loadingState = 'idle'; // 'idle' | 'loading' | 'success' | 'error'
</script>
<ActivityIcon animationState={loadingState} />
<button onclick={() => loadingState = 'loading'}>Start Loading</button>
Prop | Type | Default | Description |
---|---|---|---|
size |
number |
28 |
Icon size in pixels |
class |
string |
"" |
CSS classes for styling |
triggers |
object |
{ hover: true } |
Animation triggers |
animationState |
string |
'idle' |
State-based animation |
duration |
number |
2000 |
Animation duration (ms) |
loop |
boolean |
false |
Loop animation infinitely |
triggers: {
hover?: boolean; // Hover to animate (default: true)
click?: boolean; // Click to toggle animation
focus?: boolean; // Focus to animate (keyboard navigation)
custom?: boolean; // Programmatic control only
}
'idle'
- Default state, no animation'loading'
- Continuous animation (perfect for loading indicators)'success'
- Brief animation then stop'error'
- Brief animation then stop'active'
- Continuous animationMethod | Description |
---|---|
start() |
Start animation |
stop() |
Stop animation |
toggle() |
Toggle animation state |
<script>
import { ActivityIcon } from 'svelte-animate-icons';
let isLoading = false;
async function handleSubmit() {
isLoading = true;
try {
await api.submit();
} finally {
isLoading = false;
}
}
</script>
<button onclick={handleSubmit} disabled={isLoading}>
<ActivityIcon animationState={isLoading ? 'loading' : 'idle'} size={16} />
{isLoading ? 'Submitting...' : 'Submit'}
</button>
<script>
import { ActivityIcon } from 'svelte-animate-icons';
let cardIcon;
</script>
<div
class="card"
onmouseenter={() => cardIcon?.start()}
onmouseleave={() => cardIcon?.stop()}
>
<ActivityIcon bind:this={cardIcon} triggers={{ custom: true }} size={24} />
<h3>Hover to animate</h3>
</div>
<script>
import { ActivityIcon } from 'svelte-animate-icons';
let inputValue = '';
$: validationState = inputValue.length >= 3 ? 'success' : 'error';
</script>
<div class="input-group">
<input bind:value={inputValue} placeholder="Min 3 characters" />
<ActivityIcon animationState={validationState} size={20} />
</div>
prefers-reduced-motion
Browse all 550+ icons at: Icon Gallery
<!-- UI & Navigation -->
<ActivityIcon /> <!-- Perfect for loading states -->
<CheckIcon />
<XIcon />
<MenuIcon />
<SearchIcon />
<!-- Communication -->
<HeartIcon />
<BellIcon />
<MailsIcon />
<MessageCircleIcon />
<!-- Actions -->
<DownloadIcon />
<UploadIcon />
<CopyIcon />
<TrashIcon />
<!-- Currency -->
<DollarSignIcon />
<EuroIcon />
<BitcoinIcon />
<!-- Social -->
<GithubIcon />
<TwitterIcon />
<LinkedinIcon />
<FacebookIcon />
<!-- +page.svelte -->
<script>
import { ActivityIcon } from 'svelte-animate-icons';
let pageState = 'loading';
</script>
<div class="page-header">
<h1>Dashboard</h1>
<ActivityIcon animationState={pageState} size={32} />
</div>
<script>
import { ActivityIcon } from 'svelte-animate-icons';
</script>
<ActivityIcon
class="text-blue-500 hover:text-blue-600"
triggers={{ hover: true, click: true }}
size={24}
/>
Modern browsers that support:
MIT © Serhat YILDIZ
Contributions welcome! Please read our contributing guide first.
Built with love for the Svelte community.