# Image label

> An image label is a short text or an icon pinned to a corner of an image, such as "AI", "New" or a video length.

Pin a short label to a corner of an image with the image label component. Change the corner and the color, or add an icon.

Source: https://docs.tabler.io/ui/components/image-label

---

## Default markup

Wrap the image in an `.img-labeled` element and put an `.img-label` next to the image. The label sits in the bottom end corner, on a dark, see-through background that stays readable on any photo.

```html
<div class="img-labeled">
  <img src="/static/photos/book-on-the-grass.jpg" class="rounded" width="240" alt="A book on the grass" />
  <span class="img-label">AI</span>
</div>
```

## Position

Move the label to another corner with `.img-label-top-start`, `.img-label-top-end` or `.img-label-bottom-start`. The corners follow the text direction, so start and end swap in right-to-left layouts.

```html
<div class="d-flex flex-wrap gap-3">
  <div class="img-labeled">
    <img src="/static/photos/a-woman-works-on-a-laptop-at-home.jpg" class="rounded" width="160" alt="A woman working on a laptop" />
    <span class="img-label img-label-top-start">Top start</span>
  </div>
  <div class="img-labeled">
    <img src="/static/photos/a-woman-works-on-a-laptop-at-home.jpg" class="rounded" width="160" alt="A woman working on a laptop" />
    <span class="img-label img-label-top-end">Top end</span>
  </div>
  <div class="img-labeled">
    <img src="/static/photos/a-woman-works-on-a-laptop-at-home.jpg" class="rounded" width="160" alt="A woman working on a laptop" />
    <span class="img-label img-label-bottom-start">Bottom start</span>
  </div>
  <div class="img-labeled">
    <img src="/static/photos/a-woman-works-on-a-laptop-at-home.jpg" class="rounded" width="160" alt="A woman working on a laptop" />
    <span class="img-label">Bottom end</span>
  </div>
</div>
```

## With an icon

A label can hold an icon, a text, or both. The icon is scaled down to match the label text. Add `.img-label-icon` to a label with only an icon to make it a square.

```html
<div class="d-flex flex-wrap gap-3">
  <div class="img-labeled">
    <img src="/static/photos/brainstorming-session-with-creative-designers.jpg" class="rounded" width="200" alt="A brainstorming session" />
    <span class="img-label">
      <!-- Download SVG icon from http://tabler.io/icons/icon/player-play -->
      <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false" class="icon">
        <path d="M7 4v16l13 -8l-13 -8" />
      </svg> 1:24
    </span>
  </div>
  <div class="img-labeled">
    <img src="/static/photos/blond-using-her-laptop-at-her-bedroom.jpg" class="rounded" width="200" alt="A woman using a laptop" />
    <span class="img-label img-label-icon">
      <!-- Download SVG icon from http://tabler.io/icons/icon/crown -->
      <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false" class="icon">
        <path d="M12 6l4 6l5 -4l-2 10h-14l-2 -10l5 4l4 -6" />
      </svg>
      <span class="visually-hidden">Premium</span>
    </span>
  </div>
</div>
```

## Colors

Change the color with a background utility and its matching text color, for example `.bg-red` with `.text-red-fg`.

```html
<div class="d-flex flex-wrap gap-3">
  <div class="img-labeled">
    <img src="/static/photos/a-visit-to-the-bookstore.jpg" class="rounded" width="160" alt="A visit to the bookstore" />
    <span class="img-label bg-primary text-primary-fg">New</span>
  </div>
  <div class="img-labeled">
    <img src="/static/photos/a-visit-to-the-bookstore.jpg" class="rounded" width="160" alt="A visit to the bookstore" />
    <span class="img-label bg-red text-red-fg">-20%</span>
  </div>
  <div class="img-labeled">
    <img src="/static/photos/a-visit-to-the-bookstore.jpg" class="rounded" width="160" alt="A visit to the bookstore" />
    <span class="img-label bg-green text-green-fg">Free</span>
  </div>
</div>
```

## Multiple labels

Put several labels on one image, each in its own corner.

```html
<div class="img-labeled">
  <img src="/static/photos/brainstorming-session-with-creative-designers-2.jpg" class="rounded" width="320" alt="Designers at a brainstorming session" />
  <span class="img-label img-label-top-start bg-red text-red-fg">Live</span>
  <span class="img-label img-label-top-end">
    <!-- Download SVG icon from http://tabler.io/icons/icon/lock -->
    <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false" class="icon">
      <path d="M5 13a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v6a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-6" />
      <path d="M11 16a1 1 0 1 0 2 0a1 1 0 0 0 -2 0" />
      <path d="M8 11v-4a4 4 0 1 1 8 0v4" />
    </svg> Members
  </span>
  <span class="img-label">4K</span>
</div>
```

## Custom look

Set the `--tblr-img-label-*` variables on the label to change its offset, size or background. Set `--tblr-img-label-backdrop-filter` to `none` to turn off the blur.

```html
<div class="img-labeled">
  <img src="/static/photos/book-on-the-grass.jpg" class="rounded" width="240" alt="A book on the grass" />
  <span class="img-label" style="--tblr-img-label-offset: 0.75rem; --tblr-img-label-font-size: 0.875rem; --tblr-img-label-bg: rgba(255, 255, 255, 0.8); --tblr-img-label-color: #000">Sponsored</span>
</div>
```

## Accessibility

- The label is real text, so screen readers read it after the image. For a short form such as "AI", add the full meaning in a `.visually-hidden` element, for example "AI generated".
- A label with only an icon needs a `.visually-hidden` text that names it.
- The label does not take clicks. When the image is a link, a click on the label goes to the link.
