이미지와 임베드
이미지와 임베드 (Images and embeds)
문서를 더 풍부하게 꾸밀 수 있도록 반응형 이미지, 비디오, 리치 미디어 임베드를 제공하는 가이드예요. 이미지 확대/축소와 다양한 iframe 임베드를 다룹니다.
출처: Nuxt UI
본문
문서를 돋보이게 하고 설명을 보강해 주는 반응형 이미지, 비디오, 리치 미디어 임베드예요.
이미지 (Images)
자동 최적화와 인터랙티브 확대/축소 기능을 갖춘 반응형 이미지예요.
<template>
<p>
<img alt="Image" src="/assets/templates/nuxt/dashboard-dark.png" />
</p>
</template>

:::
export default defineAppConfig({
ui: {
prose: {
img: {
slots: {
base: 'rounded-md',
overlay: 'fixed inset-0 bg-default/75 backdrop-blur-sm',
content: 'fixed inset-0 flex items-center justify-center cursor-zoom-out focus:outline-none',
zoomedImage: 'w-full h-auto max-w-[95vw] max-h-[95vh] object-contain rounded-md'
},
variants: {
zoom: {
true: 'will-change-transform'
},
open: {
true: ''
},
width: {
false: 'w-full'
}
},
compoundVariants: [
{
zoom: true,
open: false,
class: 'cursor-zoom-in'
}
]
}
}
}
})
Nuxt:
[!NOTE]
@nuxt/image가 설치되어 있으면 네이티브img태그 대신<NuxtImg>컴포넌트가 사용되어 성능과 최적화가 향상됩니다.
확대/축소 (Zoom)
기본적으로 이미지는 인터랙티브 확대/축소를 지원해요. 이미지를 클릭하면 부드러운 전환과 함께 모달 오버레이로 열리며, 사용자가 세부 내용을 자세히 살펴볼 수 있습니다.
특정 이미지의 확대/축소를 막으려면 :zoom="false" 속성을 추가하세요.
{:zoom="false"}
크기 (Size)
이미지는 가로세로 비율을 유지하면서 컨테이너에 자동으로 맞춰져요. 필요할 때 마크다운이나 HTML 속성으로 크기를 제어할 수 있습니다.
{width="300"}
Iframes
CodeSandbox, Figma, YouTube 같은 인터랙티브 콘텐츠를 쉽게 임베드할 수 있어요.
YouTube
<iframe src="https://www.youtube-nocookie.com/embed/_eQxomah-nA?si=pDSzchUBDKb2NQu7" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen style="aspect-ratio: 16/9; width: 100%;"></iframe>
CodeSandbox
<iframe src="https://codesandbox.io/p/devbox/nuxt-ui-xgrzw5" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen style="aspect-ratio: 16/9; width: 100%;"></iframe>
Figma
<iframe style="border: 1px solid rgba(0, 0, 0, 0.1); width: 100%; height: 450px;" src="https://embed.figma.com/file/1544369209862884086/hf_embed?community_viewer=true&embed_host=fastma&fuid=960610330589944894&kind=file&page-selector=0&viewer=1" allowfullscreen></iframe>