# Icon

> A lightweight SVG wrapper that provides consistent sizing, color inheritance, and themed appearances for icons.

Source: https://vaneui.com/docs/basic-components/icon

Import: `import { Icon, Button, Card, Col, Row, Text } from "@vaneui/ui"`

Icon displays an SVG glyph that is not itself clickable; an icon the user clicks belongs in an [IconButton](/docs/basic-components/icon-button), or inside a [Button](/docs/basic-components/button) next to its label. It wraps the SVG in an inline-flex `<span>` that centers the glyph and keeps it from shrinking in a flex row. Without an accessible name the wrapper gets `aria-hidden`, so screen readers skip it; with `aria-label`, `aria-labelledby` or `title` it gets `role="img"` and is announced.

## Basic usage

Wrap any SVG inside `Icon` to apply consistent sizing and color inheritance.

```tsx demo
<Row flexWrap>
  <Icon><Star /></Icon>
  <Icon><Heart /></Icon>
  <Icon><AlertCircle /></Icon>
  <Icon><Check /></Icon>
  <Icon><Info /></Icon>
</Row>
```

## Sizes

Icons support five sizes: `xs`, `sm`, `md` (default), `lg`, `xl`. The glyph is 12, 16, 20, 24 and 32px, so the default sits next to body text. For a larger glyph, give the SVG a `size-*` class.

```tsx demo
<Row flexWrap itemsEnd>
  <Col itemsCenter>
    <Icon xs><Star /></Icon>
    <Text sm secondary>xs</Text>
  </Col>
  <Col itemsCenter>
    <Icon sm><Star /></Icon>
    <Text sm secondary>sm</Text>
  </Col>
  <Col itemsCenter>
    <Icon md><Star /></Icon>
    <Text sm secondary>md</Text>
  </Col>
  <Col itemsCenter>
    <Icon lg><Star /></Icon>
    <Text sm secondary>lg</Text>
  </Col>
  <Col itemsCenter>
    <Icon xl><Star /></Icon>
    <Text sm secondary>xl</Text>
  </Col>
</Row>
```

## Appearances

By default, Icon inherits `currentColor` from the parent. Use appearance props to apply themed colors.

```tsx demo
<Row flexWrap>
  <Col itemsCenter>
    <Icon primary><Star /></Icon>
    <Text xs secondary>primary</Text>
  </Col>
  <Col itemsCenter>
    <Icon accent><Star /></Icon>
    <Text xs secondary>accent</Text>
  </Col>
  <Col itemsCenter>
    <Icon secondary><Star /></Icon>
    <Text xs secondary>secondary</Text>
  </Col>
  <Col itemsCenter>
    <Icon tertiary><Star /></Icon>
    <Text xs secondary>tertiary</Text>
  </Col>
  <Col itemsCenter>
    <Icon success><Star /></Icon>
    <Text xs secondary>success</Text>
  </Col>
  <Col itemsCenter>
    <Icon danger><Star /></Icon>
    <Text xs secondary>danger</Text>
  </Col>
  <Col itemsCenter>
    <Icon warning><Star /></Icon>
    <Text xs secondary>warning</Text>
  </Col>
  <Col itemsCenter>
    <Icon info><Star /></Icon>
    <Text xs secondary>info</Text>
  </Col>
</Row>
```

## Variants

Icons support `outline` (default, text color only) and `filled` (background fill) variants.

```tsx demo
<Row flexWrap>
  <Col itemsCenter>
    <Icon primary><Star /></Icon>
    <Text xs secondary>outline</Text>
  </Col>
  <Col itemsCenter>
    <Icon primary filled><Star /></Icon>
    <Text xs secondary>filled</Text>
  </Col>
  <Col itemsCenter>
    <Icon danger><AlertCircle /></Icon>
    <Text xs secondary>outline</Text>
  </Col>
  <Col itemsCenter>
    <Icon danger filled><AlertCircle /></Icon>
    <Text xs secondary>filled</Text>
  </Col>
</Row>
```

## Shapes

Shape props apply once the icon enters container mode (any of `padding`, `border`, `insetRing`, `shadow`, `filled`). Without a container, the SVG has no visible box for the radius to act on.

```tsx demo
<Row flexWrap>
  <Col itemsCenter>
    <Icon padding primary filled sharp><Star /></Icon>
    <Text xs secondary>sharp</Text>
  </Col>
  <Col itemsCenter>
    <Icon padding primary filled><Star /></Icon>
    <Text xs secondary>rounded</Text>
  </Col>
  <Col itemsCenter>
    <Icon padding primary filled pill><Star /></Icon>
    <Text xs secondary>pill</Text>
  </Col>
</Row>
```

## Container mode

Add `padding` to give the icon a sized box, then combine `filled`, `border`, `insetRing`, or `shadow` to style the container. Padding and radius scale with the size prop.

```tsx demo
<Row flexWrap itemsCenter>
  <Col itemsCenter>
    <Icon padding pill primary filled><Heart /></Icon>
    <Text xs secondary>filled</Text>
  </Col>
  <Col itemsCenter>
    <Icon padding pill primary border><Heart /></Icon>
    <Text xs secondary>border</Text>
  </Col>
  <Col itemsCenter>
    <Icon padding pill primary insetRing><Heart /></Icon>
    <Text xs secondary>ring</Text>
  </Col>
  <Col itemsCenter>
    <Icon padding pill primary filled shadow><Heart /></Icon>
    <Text xs secondary>filled + shadow</Text>
  </Col>
  <Col itemsCenter>
    <Icon padding pill success filled insetRing><Check /></Icon>
    <Text xs secondary>filled + ring</Text>
  </Col>
  <Col itemsCenter>
    <Icon lg padding pill danger filled><AlertCircle /></Icon>
    <Text xs secondary>lg</Text>
  </Col>
</Row>
```

## Transparent

`transparent` drops the container's background and changes nothing else. It only has an effect on `filled`, since every other variant is already background-less.

That leaves the glyph in the "on this fill" colour with no fill of its own, so it belongs on a filled surface of the same appearance, where that colour is the readable one. On a plain surface, use the default `outline` variant instead.

```tsx demo
<Row flexWrap itemsCenter>
  <Col itemsCenter>
    <Icon padding pill danger filled><AlertCircle /></Icon>
    <Text xs secondary>filled: paints its own surface</Text>
  </Col>
  <Card danger filled wFit>
    <Col itemsCenter>
      <Icon padding pill danger filled transparent><AlertCircle /></Icon>
      <Text xs>transparent: blends into a matching fill</Text>
    </Col>
  </Card>
</Row>
```

Note that `border` and `insetRing` have nothing to show on a `filled` icon: the filled variant resolves both to transparent so the edge disappears into the fill. Pair them with `outline` instead.

## In context

Icons work naturally alongside text and inside buttons.

```tsx demo
<Col>
  <Row>
    <Button><Search /> Search</Button>
    <Button success filled><Check /> Saved</Button>
    <Button danger><AlertCircle /> Delete</Button>
  </Row>
  <Text><Icon xs info><Info /></Icon> Icon sizes are fixed per size prop; in body text use `xs` so the line keeps its height.</Text>
  <Row itemsCenter>
    <Icon padding pill primary filled><Star /></Icon>
    <Col gap noPadding>
      <Text fontBold>Container-mode icons</Text>
      <Text sm secondary>Pair a padded icon with adjacent text for compact summaries.</Text>
    </Col>
  </Row>
</Col>
```

## Frequently asked questions

### Do I need to wrap icons in Icon inside a Button?

No. `Button`, `IconButton`, `NavLink` and `Alert` size an SVG child from their own size prop, so `<Button><Download/> Download</Button>` needs no wrapper. Use Icon for a glyph that stands on its own, such as an icon beside a line of `Text`: it sets the size, centers the glyph, keeps it from shrinking in a flex row and hides it from screen readers when it has no name.

### How do I make an icon larger than `xl`?

Give the SVG a `size-*` class, such as `size-10` for 40px. Icon's own sizing skips an SVG that carries a `size-*` class, so the class sets the size instead. The prebuilt `@vaneui/ui/css` stylesheet contains only the utilities VaneUI uses, so in that setup an SVG whose class is missing from the bundle falls back to its own `width` and `height` attributes. Your own Tailwind v4 build generates the class.

### Can I use any icon set with Icon?

Yes, as long as the icon renders an inline `<svg>`. Icon wraps whatever SVG element you pass, so icon components from any package work, and so does an `<svg>` written by hand. An icon loaded as an image file (`<img src="icon.svg">`) is not inline: Icon cannot size it or color it with `currentColor`, so render it with [Img](/docs/layout-components/img) instead.

## Props

| Prop | Category | Default | Description |
| --- | --- | --- | --- |
| `primary` | Appearance |  | Primary color appearance (gray) |
| `accent` | Appearance |  | Accent color appearance (rose) |
| `secondary` | Appearance |  | Secondary color appearance (gray) |
| `tertiary` | Appearance |  | Tertiary color appearance |
| `success` | Appearance |  | Success color appearance (green) |
| `danger` | Appearance |  | Danger color appearance (red) |
| `warning` | Appearance |  | Warning color appearance (amber) |
| `info` | Appearance |  | Info color appearance (cyan) |
| `inheritAppearance` | Appearance |  | Inherit appearance from parent — suppresses own data-appearance/data-variant, uses parent's CSS variables |
| `padding` | Padding |  | Enable internal padding |
| `paddingX` | Padding |  | Enable only horizontal padding |
| `paddingY` | Padding |  | Enable only vertical padding |
| `noPadding` | Padding | yes | Disable internal padding |
| `pill` | Shape |  | Fully rounded corners (circular) |
| `sharp` | Shape |  | No rounded corners (square) |
| `rounded` | Shape | yes | Medium rounded corners (default) |
| `noShrink` | Shrink | yes | Prevent the flex item from shrinking below its content size (= `shrink-0`) |
| `xs` | Size |  | Extra small size |
| `sm` | Size |  | Small size |
| `md` | Size | yes | Medium size (default) |
| `lg` | Size |  | Large size |
| `xl` | Size |  | Extra large size |
| `skeleton` | Skeleton |  | Show the component as a loading placeholder in its own size and shape. On a container, every component inside it becomes a placeholder too |
| `filled` | Variant |  | Filled variant - solid background with contrasting text color |
| `outline` | Variant | yes | Outline variant - transparent background with border and colored text (default) |
| `ghost` | Variant |  | Ghost variant - transparent background, no border, appearance-colored text, tinted hover background |

Layout and utility props (Border, Display, Height, Hide, Items, Justify, Position, Responsive Width, Ring, Shadow, Show, Transition, Transparent, Width) are listed on [Common Props](https://vaneui.com/docs/reference/common-props.md).
