# Flag animated icon

> MIT-licensed Flag animated icon: loops while hovered. Use it in React or shadcn/ui, or get the Lottie JSON or SVG.

Flag is a 1.33 s micro animation from the action set that loops while hovered, like Plus Circle and Link 2. Hover loop icons typically mark social links, community invites, portfolio links and language pickers.

## Facts

- Interaction: [Hover loop](https://useanimations.com/interactions/hover-loop). Loops while hovered, finishes the current cycle after mouseleave and stays static when reduced motion is preferred.
- Category: [Action](https://useanimations.com/categories/action)
- Duration: 1.33 s at 30 fps
- Artboard: 32 × 32 px
- Lottie size: 2.3 kB
- License: MIT, attribution optional ([Licencing & Terms](https://useanimations.com/licencing-and-terms))

## Files

- Lottie JSON: https://useanimations.com/icons/flag.json
- Static SVG (flag): https://useanimations.com/icons/flag/flag.svg
- ZIP (Lottie JSON and SVGs): https://useanimations.com/icons/flag.zip
- shadcn registry item: https://useanimations.com/r/flag.json
- Web page: https://useanimations.com/icons/flag

## React

```bash
npm install react-useanimations
```

```jsx
import UseAnimations from 'react-useanimations';
import flag from 'react-useanimations/lib/flag';

<UseAnimations animation={flag} size={32} />
```

## shadcn/ui

```bash
npx shadcn@latest add https://useanimations.com/r/flag.json
```

```tsx
import { AnimatedFlag } from '@/components/animations/flag';

<AnimatedFlag size={24} />
```

## HTML and lottie-web

```html
<div id="flag-icon" style="width: 48px; height: 48px"></div>

<script src="https://cdn.jsdelivr.net/npm/lottie-web@5.13.0/build/player/lottie_light.min.js"></script>
<script>
  const el = document.getElementById('flag-icon');
  const a = lottie.loadAnimation({ container: el, renderer: 'svg', loop: true, autoplay: false, path: 'https://useanimations.com/icons/flag.json' });
  const motion = matchMedia('(prefers-reduced-motion: reduce)');
  let stopAfterCycle = false;
  a.addEventListener('loopComplete', () => { if (stopAfterCycle) { stopAfterCycle = false; a.goToAndStop(0, true); } });
  el.addEventListener('mouseenter', () => { stopAfterCycle = false; if (!motion.matches) a.play(); });
  el.addEventListener('mouseleave', () => { stopAfterCycle = !motion.matches && !a.isPaused; if (!stopAfterCycle) a.goToAndStop(0, true); });
</script>
```

## FAQ

### Where does Flag stop after hover?

It finishes the cycle it is in (at most 1.33 s) and then rests on its first frame, so it never freezes mid-motion. Keyboard focus plays it as well; a tap on a touch screen does not.

### Is Flag decorative?

By default it is aria-hidden. Pass aria-label="Flag" to announce it as an image, or leave it hidden when the link or button it sits in has its own text.

### Can Flag loop all the time instead?

Yes: pass interaction="loop". It then plays continuously; stays on the static first frame when reduced motion is preferred.

## Related icons

- [Plus Circle](https://useanimations.com/icons/plus-circle) (click-replay)
- [Link 2](https://useanimations.com/icons/link-2) (click-replay)
- [Bookmark](https://useanimations.com/icons/bookmark) (click-toggle)
- [Download V2](https://useanimations.com/icons/download-v2) (click-replay)
- [Chevron left](https://useanimations.com/icons/chevron-left) (click-replay)
- [Save](https://useanimations.com/icons/save) (click-replay)
- [Checkmark](https://useanimations.com/icons/checkmark) (loop)
- [Key](https://useanimations.com/icons/key) (hover-replay)
- [Edit](https://useanimations.com/icons/edit) (hover)
- [Info](https://useanimations.com/icons/info) (hover)
- [Help](https://useanimations.com/icons/help) (loop)
- [Filter](https://useanimations.com/icons/filter) (click-replay)

[All action icons](https://useanimations.com/categories/action) · [All icons](https://useanimations.com/icons)
