The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
---
title: AnimatedIconCrossfade
description: Crossfade between two icons as application state changes.
---
import { PageBanner } from "/snippets/page-banner.mdx"
import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';
import AnimatedIconCrossfadeReference from '/snippets/ui/generated/components/layout/animated-icon-crossfade.mdx';
## Overview
`AnimatedIconCrossfade` crossfades between `activeIcon` and `inactiveIcon` node content according to `isActive`. It does not own the action or state. Compose it inside a labeled [Button](/ui/primitives/input/button).
<StoryEmbed
storyId="ui-components-layout-animatediconcrossfade--display"
title="AnimatedIconCrossfade example"
height={100}
/>
## Usage
```tsx
import { useState } from 'react';
import { AnimatedIconCrossfade } from 'twenty-ui/components/layout';
import { IconPencil, IconX } from 'twenty-ui/icon';
import { Button } from 'twenty-ui/primitives/input';
export const EditToggle = () => {
const [isEditing, setIsEditing] = useState(false);
return (
<Button
size="sm"
aria-expanded={isEditing}
onClick={() => setIsEditing(!isEditing)}
startIcon={
<AnimatedIconCrossfade
isActive={isEditing}
activeIcon={<IconX size={14} />}
inactiveIcon={<IconPencil size={14} />}
/>
}
>
Edit actions
</Button>
);
};
```
Both nodes stay mounted as `isActive` changes, preserving their local state. The layers animate opacity and scale, and disable transitions for reduced motion. Both layers are decorative; keep the accessible action name on the surrounding control. For a standalone labeled image, set `role="img"` and `aria-label` on the root.
Native attributes, events, `className`, `style`, and `ref` target an inline span, which can sit inside a button. `render` replaces that target through Base UI composition. The root dimensions default to the small icon theme token. Size each icon node explicitly, and use root width and height styles for larger artwork.
Replace `ActiveIcon` and `InactiveIcon` constructors with lowercase `activeIcon` and `inactiveIcon` nodes. Move the former `size` option to the node dimensions and root styles.
## Props
<AnimatedIconCrossfadeReference />
<PageBanner illustration="card-page-sync-recovery" />