본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

컬러모드 아바타

원문 보기 위키 갱신

컬러모드 아바타 (ColorModeAvatar)

컬러모드 아바타(ColorModeAvatar)는 라이트 모드와 다크 모드에서 서로 다른 이미지를 보여주는 아바타 컴포넌트예요. 테마에 따라 바뀌는 로고나 프로필 이미지를 간단하게 표현할 때 유용해요.

출처: Nuxt UI

본문

라이트·다크 모드에서 서로 다른 이미지를 보여주는 아바타예요.

사용법 (Usage)

ColorModeAvatar 컴포넌트는 Avatar 컴포넌트를 확장하므로 size, icon 같은 속성을 그대로 전달할 수 있어요.

light와 dark prop으로 라이트·다크 모드에서 쓸 이미지 소스를 각각 지정해요.

<template>
  <UColorModeAvatar light="https://github.com/vuejs.png" dark="https://github.com/nuxt.png" />
</template>

[!NOTE]

라이트·다크 모드를 전환하면서 서로 다른 이미지가 나타나는 걸 확인해 보세요:

API

Props

/**
 * Props for the ColorModeAvatar component
 */
interface ColorModeAvatarProps {
  light: string;
  dark: string;
  /**
   * The element or component this component should render as.
   * @default 'span'
   */
  as?: any;
  /**
   * @default 'neutral'
   */
  color?: "primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral" | undefined;
  ui?: { root?: SlotClass; image?: SlotClass; fallback?: SlotClass; icon?: SlotClass; } | undefined;
  alt?: string | undefined;
  decoding?: "async" | "auto" | "sync" | undefined;
  height?: string | number | undefined;
  loading?: "lazy" | "eager" | undefined;
  referrerpolicy?: "" | "no-referrer" | "no-referrer-when-downgrade" | "origin" | "origin-when-cross-origin" | "same-origin" | "strict-origin" | "strict-origin-when-cross-origin" | "unsafe-url" | undefined;
  sizes?: string | undefined;
  srcset?: string | undefined;
  usemap?: string | undefined;
  width?: string | number | undefined;
  crossorigin?: "anonymous" | "use-credentials" | undefined;
  icon?: any;
  text?: string | undefined;
  /**
   * @default 'md'
   */
  size?: "md" | "3xs" | "2xs" | "xs" | "sm" | "lg" | "xl" | "2xl" | "3xl" | undefined;
  chip?: boolean | ChipProps | undefined;
}

[!NOTE] See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attributes

이 컴포넌트는 기본 <img> HTML 속성도 모두 지원해요.

변경 기록 (Changelog)

컴포넌트와 테마의 커밋 히스토리를 확인해 보세요.

더 알아보기 (Learn more)