Image

nuxt/image
Pohon UI integrates with Nuxt Image to optimize the images rendered by its components.

Installation

To get started, you can follow the official guide or in summary:

pnpm add @nuxt/image

Then, add the @nuxt/image module in your nuxt.config.ts:

nuxt.config.ts
export default defineNuxtConfig({
  modules: [
    'pohon-ui',
    '@nuxt/image'
  ],
  css: ['~/assets/css/main.css']
});

Usage

When @nuxt/image is installed, Pohon UI renders the <NuxtImg> component instead of the native img tag in the following components:

There is nothing else to configure. Any <NuxtImg> prop you pass to these components, like format, quality or provider, is forwarded to it:

<template>
  <PAvatar
    src="/avatar.png"
    format="webp"
  />

  <PBlogPost
    title="Introducing Nuxt Image"
    :image="{ src: '/blog/nuxt-image.png', format: 'webp', quality: 80 }"
  />
</template>
Remote images are only optimized when their host is listed in the image.domains option of your nuxt.config.ts.
The Avatar passes its size as width and height, so <NuxtImg> requests an image that matches the rendered size.

Opt-out

To render a native img tag on a single Avatar, use the as prop:

<template>
  <PAvatar
    src="https://github.com/benjamincanac.png"
    :as="{ img: 'img' }"
  />
</template>