Skip to content

UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.

1.8 KB
Raw Blame
---
title: Icon Cloud
date: 2024-05-24
description: An interactive 3D tag cloud component
author: dillionverma
published: true
---

<ComponentPreview name="icon-cloud-demo" />

## Installation

<Tabs defaultValue="cli">

<TabsList>
  <TabsTrigger value="cli">CLI</TabsTrigger>
  <TabsTrigger value="manual">Manual</TabsTrigger>
</TabsList>
<TabsContent value="cli">

```bash
npx shadcn@latest add @magicui/icon-cloud
```

</TabsContent>

<TabsContent value="manual">

<Steps>

<Step>Copy and paste the following code into your project.</Step>

<ComponentSource name="icon-cloud" />

</Steps>

</TabsContent>

</Tabs>

## With Images

<ComponentPreview name="icon-cloud-demo-2" />

## With SVG Icons

<ComponentPreview name="icon-cloud-demo-3" />

## Usage

```tsx showLineNumbers
import { IconCloud } from "@/components/ui/icon-cloud"
```

```tsx showLineNumbers
<div className="relative overflow-hidden">
  <IconCloud images={images} />
</div>
```

## Props

| Prop          | Type                | Default | Description                                |
| ------------- | ------------------- | ------- | ------------------------------------------ |
| `icons`       | `React.ReactNode[]` | `[]`    | Array of icons to render in the cloud      |
| `images`      | `string[]`          | `[]`    | Array of image URLs to render in the cloud |
| `showControl` | `boolean`           | `true`  | Show play/pause control button             |

## Accessibility

The cloud rotates automatically, so it ships with a play/pause control by default to satisfy [WCAG 2.1 SC 2.2.2 (Pause, Stop, Hide)](https://www.w3.org/WAI/WCAG22/Understanding/pause-stop-hide.html).

Rotation also pauses automatically when the user has `prefers-reduced-motion: reduce` enabled. Setting `showControl={false}` removes the only way to resume it, so opt out only when your layout provides its own control.