kipluo
Flutter6 min read4 steps

How to Animate Icons in Flutter

Animated icons make state changes readable: a menu that becomes a close button, a bookmark that fills in. Flutter has two built-in tools for this and one common gap. This guide covers AnimatedIcon, AnimatedSwitcher, and when an interactive animated icon widget is worth adding.

You needFlutter 3.xAnimationControllerIconButton
Loading demo
The web version of the Bell icon. Hover or tap it to ring; the Flutter KBellIcon uses the same motion.Component page

1. Morph between two icons with AnimatedIcon

AnimatedIcon draws one of Flutter's built-in morphing icons (AnimatedIcons.menu_close, menu_arrow, play_pause, add_event and others) at a progress you control with an AnimationController. Forward plays the morph; reverse plays it back.

Give the IconButton a tooltip that matches the current state. Tooltips double as the semantics label, so screen readers hear "Open menu" or "Close menu".

menu_button.dart
import 'package:flutter/material.dart';

class MenuButton extends StatefulWidget {
  const MenuButton({super.key, required this.onChanged});

  final ValueChanged<bool> onChanged;

  @override
  State<MenuButton> createState() => _MenuButtonState();
}

class _MenuButtonState extends State<MenuButton> with SingleTickerProviderStateMixin {
  late final AnimationController _controller = AnimationController(
    vsync: this,
    duration: const Duration(milliseconds: 250),
  );
  bool _open = false;

  void _toggle() {
    setState(() => _open = !_open);
    _open ? _controller.forward() : _controller.reverse();
    widget.onChanged(_open);
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return IconButton(
      tooltip: _open ? 'Close menu' : 'Open menu',
      onPressed: _toggle,
      icon: AnimatedIcon(icon: AnimatedIcons.menu_close, progress: _controller),
    );
  }
}

2. Swap any two icons with AnimatedSwitcher

AnimatedIcon only covers its built-in set. For any other pair, such as an outlined and filled bookmark, AnimatedSwitcher cross-fades between children and accepts a transitionBuilder for scale or rotation. The child needs a key that changes with the state, otherwise the switcher sees the same widget and doesn't animate.

bookmark_button.dart
IconButton(
  tooltip: saved ? 'Remove bookmark' : 'Bookmark',
  onPressed: () => setState(() => saved = !saved),
  icon: AnimatedSwitcher(
    duration: const Duration(milliseconds: 200),
    transitionBuilder: (child, animation) => ScaleTransition(scale: animation, child: child),
    child: Icon(
      saved ? Icons.bookmark : Icons.bookmark_border,
      key: ValueKey(saved),
    ),
  ),
)

3. Icons that react to the user

Both techniques above animate between states. A different kind of animated icon reacts to the interaction itself: a bell that swings when tapped, a trash can whose lid lifts on hover. Building those means custom painting or per-icon transforms, a press spring, hover handling for desktop and web, and semantics. That's manageable for one icon and a lot of repetitive work for a full set.

4. Kipluo animated icons

Kipluo ships its animated icon set as Flutter widgets: hand-built icons such as KBellIcon and KHeartIcon, and a larger pack reachable with KipluoIcon.bySlug. Each is a focusable button with a label, animates on hover and tap with springs, and plays a short sound. Many are free in the kipluo package, including the bell and check icons below.

toolbar.dart
import 'package:kipluo/kipluo.dart';

Row(
  children: [
    KBellIcon(label: 'Notifications', onPressed: openNotifications),
    KipluoIcon.bySlug('check-icon', onPressed: markAllRead),
  ],
)

Accessibility checklist

Tick each one off as you check your build. Your ticks stay in this browser.

0 of 4 checked

Build it yourself or install it

Build it yourself when

Menu, play/pause and other pairs covered by AnimatedIcons, or a simple outlined-to-filled swap.

Install Kipluo when

You want a large, consistent set of interactive icons with spring motion and sound, matching the React icon set.

Keep building