Pulled ALL skills from 15 source repositories: - anthropics/skills: 16 (docs, design, MCP, testing) - obra/superpowers: 14 (TDD, debugging, agents, planning) - coreyhaines31/marketingskills: 25 (marketing, CRO, SEO, growth) - better-auth/skills: 5 (auth patterns) - vercel-labs/agent-skills: 5 (React, design, Vercel) - antfu/skills: 16 (Vue, Vite, Vitest, pnpm, Turborepo) - Plus 13 individual skills from various repos Mosaic Stack is not limited to coding — the Orchestrator and subagents serve coding, business, design, marketing, writing, logistics, analysis, and more. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
87 lines
2.4 KiB
Markdown
87 lines
2.4 KiB
Markdown
---
|
|
category: Browser
|
|
---
|
|
|
|
# useImage
|
|
|
|
Reactive load an image in the browser, you can wait the result to display it or show a fallback.
|
|
|
|
## Usage
|
|
|
|
```vue
|
|
<script setup lang="ts">
|
|
import { useImage } from '@vueuse/core'
|
|
|
|
const avatarUrl = 'https://place.dog/300/200'
|
|
const { isLoading } = useImage({ src: avatarUrl })
|
|
</script>
|
|
|
|
<template>
|
|
<span v-if="isLoading">Loading</span>
|
|
<img v-else :src="avatarUrl">
|
|
</template>
|
|
```
|
|
|
|
## Component Usage
|
|
|
|
```vue
|
|
<template>
|
|
<UseImage src="https://place.dog/300/200">
|
|
<template #loading>
|
|
Loading..
|
|
</template>
|
|
|
|
<template #error>
|
|
Failed
|
|
</template>
|
|
</UseImage>
|
|
</template>
|
|
```
|
|
|
|
## Type Declarations
|
|
|
|
```ts
|
|
export interface UseImageOptions {
|
|
/** Address of the resource */
|
|
src: string
|
|
/** Images to use in different situations, e.g., high-resolution displays, small monitors, etc. */
|
|
srcset?: string
|
|
/** Image sizes for different page layouts */
|
|
sizes?: string
|
|
/** Image alternative information */
|
|
alt?: string
|
|
/** Image classes */
|
|
class?: string
|
|
/** Image loading */
|
|
loading?: HTMLImageElement["loading"]
|
|
/** Image CORS settings */
|
|
crossorigin?: string
|
|
/** Referrer policy for fetch https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy */
|
|
referrerPolicy?: HTMLImageElement["referrerPolicy"]
|
|
/** Image width */
|
|
width?: HTMLImageElement["width"]
|
|
/** Image height */
|
|
height?: HTMLImageElement["height"]
|
|
/** https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#decoding */
|
|
decoding?: HTMLImageElement["decoding"]
|
|
/** Provides a hint of the relative priority to use when fetching the image */
|
|
fetchPriority?: HTMLImageElement["fetchPriority"]
|
|
/** Provides a hint of the importance of the image */
|
|
ismap?: HTMLImageElement["isMap"]
|
|
/** The partial URL (starting with #) of an image map associated with the element */
|
|
usemap?: HTMLImageElement["useMap"]
|
|
}
|
|
/**
|
|
* Reactive load an image in the browser, you can wait the result to display it or show a fallback.
|
|
*
|
|
* @see https://vueuse.org/useImage
|
|
* @param options Image attributes, as used in the <img> tag
|
|
* @param asyncStateOptions
|
|
*/
|
|
export declare function useImage<Shallow extends true>(
|
|
options: MaybeRefOrGetter<UseImageOptions>,
|
|
asyncStateOptions?: UseAsyncStateOptions<Shallow>,
|
|
): UseAsyncStateReturn<HTMLImageElement | undefined, any[], true>
|
|
export type UseImageReturn = ReturnType<typeof useImage>
|
|
```
|