Skip to main content
Vuetify0 is now in alpha!
Vuetify0 Logo
Theme
Mode
Palettes
Accessibility
Vuetify One
Sign in to Vuetify One

Access premium tools across the Vuetify ecosystem — Bin, Play, Studio, and more.

Not a subscriber? See what's included

useImage API

API reference for the useImage composable.

Explore these related pages for additional context and usage patterns.

PageCategory
useImageSystem
useIntersectionObserverSystem
useLazySystem
ImageSemantic
AvatarSemantic

Functions

useImage

(options: UseImageOptions) => UseImageReturn

Tracks image loading state as a reactive state machine.

Options

src required

MaybeRefOrGetter<string | undefined>

Image source URL. Changes trigger a reload.

eager

MaybeRefOrGetter<boolean> | undefined

Whether the image should load. When `false`, status stays `idle` and `source` resolves to `undefined` so the browser does not start loading.

Default: true

Properties

status

Readonly<ShallowRef<ImageStatus>>

Current loading state.

isIdle

Readonly<Ref<boolean, boolean>>

Whether the image has not yet started loading (eager is false).

isLoading

Readonly<Ref<boolean, boolean>>

Whether the image is currently loading.

isLoaded

Readonly<Ref<boolean, boolean>>

Whether the image has loaded successfully.

isError

Readonly<Ref<boolean, boolean>>

Whether the image failed to load.

source

Readonly<Ref<string | undefined, string | undefined>>

Gated source URL. Resolves to `undefined` while idle, otherwise the current `src` value. Bind directly to the `<img>` `src` attribute.

Methods

onLoad

(e?: Event) => void

Bind to the `<img>` `load` event.

onError

(e?: Event) => void

Bind to the `<img>` `error` event.

retry

() => void

Reset status back to `loading` so the browser re-attempts the source.

Was this page helpful?

© 2016-1970 Vuetify, LLC
Ctrl+/