# IconTile

Anchors a centered modal with one icon in a rounded square.

[View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/IconTile.tsx)

Figma: [Elements/Icon Tile](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=5227-1245)

## Overview

An icon tile is a 56px rounded square with a 24px icon. It sits above the centered title of a modal, and `intent` tints it for the modal's outcome.

## Examples

### Basic

```tsx
import { IconTile } from '@tempoxyz/ds'
import { Settings } from '@tempoxyz/ds/icons'

export function Demo() {
  return (
    <IconTile>
      <Settings />
    </IconTile>
  )
}
```

[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/IconTile/Basic.tsx)

### Intent

Set `intent` to `neutral` (default), `positive`, `warning`, or `negative`. Each tints the fill and the icon.

```tsx
import { IconTile, style } from '@tempoxyz/ds'
import { AlertTriangle, Check, Delete, Passkey } from '@tempoxyz/ds/icons'

export function Demo() {
  return (
    <div {...styles.row()}>
      <IconTile intent="neutral">
        <Passkey />
      </IconTile>
      <IconTile intent="positive">
        <Check />
      </IconTile>
      <IconTile intent="warning">
        <AlertTriangle />
      </IconTile>
      <IconTile intent="negative">
        <Delete />
      </IconTile>
    </div>
  )
}

namespace styles {
  export const row = style({ alignItems: 'center', display: 'flex', gap: '12' })
}
```

[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/IconTile/Intent.tsx)

## Anatomy

Import the component and assemble its parts.

```tsx
import { IconTile } from '@tempoxyz/ds'

<IconTile />
```

## Guidelines

### When to Use

* Top a centered acknowledgment, onboarding, success, or destructive confirmation modal with one chip above the title.

### When Not to Use

* Use [Avatar](/docs/components/avatar) with an icon to lead a list row, such as a wallet or app.
* Use [Button](/docs/components/button) with `shape="icon"` for an icon that does something. The chip isn't interactive.
* Use [Badge](/docs/components/badge) to show a status.
* Use [Visual](/docs/components/visual) for an illustrated onboarding or feature modal. Never pair the two.

### Pair the Chip With a Title

**Do:** Place the chip above a centered title that states the outcome.

```tsx
/**
 * Do example for "Pair the Chip With a Title" on the IconTile page.
 * Place the chip above a centered title that states the outcome.
 * @module
 */
import { IconTile, style } from '@tempoxyz/ds'
import { Check } from '@tempoxyz/ds/icons'

/** Renders the static preview, which the guideline card shows inert. */
export function Demo() {
  return (
    <div {...styles.stack()}>
      <IconTile intent="positive">
        <Check />
      </IconTile>
      <span {...styles.title()}>Payment sent</span>
      <span {...styles.detail()}>Jane Cooper received 25.00 USDC.</span>
    </div>
  )
}

namespace styles {
  export const detail = style({ color: 'content.secondary', typography: 'body.b2' })

  export const stack = style({
    alignItems: 'center',
    display: 'flex',
    flexDirection: 'column',
    gap: '4',
    textAlign: 'center',
    width: '100% !custom',
  })

  export const title = style({
    color: 'content.primary',
    marginBlockStart: '20',
    typography: 'body.b1Strong',
  })
}
```

**Don't:** Rely on the chip alone to state the outcome.

```tsx
/**
 * Don't example for "Pair the Chip With a Title" on the IconTile page.
 * Don't rely on the chip alone to state the outcome.
 * @module
 */
import { IconTile, style } from '@tempoxyz/ds'
import { Check } from '@tempoxyz/ds/icons'

/** Renders the static preview, which the guideline card shows inert. */
export function Demo() {
  return (
    <div {...styles.stack()}>
      <IconTile intent="positive">
        <Check />
      </IconTile>
    </div>
  )
}

namespace styles {
  export const stack = style({ display: 'flex', justifyContent: 'center', width: '100% !custom' })
}
```

### Use One Icon From the Library

The icon inherits the intent's color and the chip's 24px font size, so leave its size and color unset.

**Do:** Pass one icon from `@tempoxyz/ds/icons`.

```tsx
/**
 * Do example for "Pair the Chip With a Title" on the IconTile page.
 * Place the chip above a centered title that states the outcome.
 * @module
 */
import { IconTile, style } from '@tempoxyz/ds'
import { Check } from '@tempoxyz/ds/icons'

/** Renders the static preview, which the guideline card shows inert. */
export function Demo() {
  return (
    <div {...styles.stack()}>
      <IconTile intent="positive">
        <Check />
      </IconTile>
      <span {...styles.title()}>Payment sent</span>
      <span {...styles.detail()}>Jane Cooper received 25.00 USDC.</span>
    </div>
  )
}

namespace styles {
  export const detail = style({ color: 'content.secondary', typography: 'body.b2' })

  export const stack = style({
    alignItems: 'center',
    display: 'flex',
    flexDirection: 'column',
    gap: '4',
    textAlign: 'center',
    width: '100% !custom',
  })

  export const title = style({
    color: 'content.primary',
    marginBlockStart: '20',
    typography: 'body.b1Strong',
  })
}
```

**Don't:** Put text, numbers, or images in the chip.

```tsx
/**
 * Don't example for "Use One Icon From the Library" on the IconTile page.
 * Don't put text, numbers, or images in the chip.
 * @module
 */
import { IconTile, style } from '@tempoxyz/ds'

/** Renders the static preview, which the guideline card shows inert. */
export function Demo() {
  return (
    <div {...styles.stack()}>
      <IconTile intent="positive">OK</IconTile>
      <span {...styles.title()}>Payment sent</span>
      <span {...styles.detail()}>Jane Cooper received 25.00 USDC.</span>
    </div>
  )
}

namespace styles {
  export const detail = style({ color: 'content.secondary', typography: 'body.b2' })

  export const stack = style({
    alignItems: 'center',
    display: 'flex',
    flexDirection: 'column',
    gap: '4',
    textAlign: 'center',
    width: '100% !custom',
  })

  export const title = style({
    color: 'content.primary',
    marginBlockStart: '20',
    typography: 'body.b1Strong',
  })
}
```

### Match the Intent to the Outcome

Use one chip per modal, and leave it out of form and review modals.

* **Feature (neutral):** Introduces a feature, such as passkeys.
* **Done (positive):** Confirms a finished task, such as a payment.
* **Risk (warning):** Flags a risk to read before you continue.
* **Irreversible (negative):** Marks an action that can't be undone.

## Accessibility

An icon tile renders a `<span>` with no role and takes no focus. The icon inside sets what assistive technology perceives.

### Semantics

* **Chip (span):** Has no role of its own.
* **Unnamed Icons (aria-hidden):** Icons without an `aria-label` are hidden, so the chip is silent.
* **Named Icons (img):** An icon with an `aria-label` is announced as an image.

### Your Responsibilities

* **Leave Decorative Icons Unnamed:** If the title below the chip names the outcome, leave the icon unnamed.
* **Name Icons That Stand Alone (aria-label):** If the icon carries meaning alone, label it, such as "Wallet connected".
* **State the Outcome in Text (intent):** The tint has no text alternative, so the modal title states the outcome.

## Related

[Avatar](/docs/components/avatar)

Use for people, contacts, and wallets in list rows.

[Button](/docs/components/button)

Use for icon actions.

[Visual](/docs/components/visual)

Use for illustrated onboarding and feature modals.

[Iconography](/docs/foundations/iconography)

Covers choosing icons.
