Avatar
Avatar (아바타)
출처: 문서
본문
Avatar
아바타는 사람이나 객체를 나타내는 데 사용돼요. 이미지, 아이콘, 또는 문자를 지원해요.
기본 사용법
shape와 size prop을 사용해서 아바타의 모양과 크기를 설정해요.
import { reactive, toRefs } from 'vue'
const state = reactive({
circleUrl:
'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png',
squareUrl:
'https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png',
sizeList: ['small', '', 'large'] as const,
})
const { circleUrl, squareUrl, sizeList } = toRefs(state)
.demo-basic {
text-align: center;
}
.demo-basic .sub-title {
margin-bottom: 10px;
font-size: 14px;
color: var(--el-text-color-secondary);
}
.demo-basic .demo-basic--circle,
.demo-basic .demo-basic--square {
display: flex;
justify-content: space-between;
align-items: center;
}
.demo-basic .block:not(:last-child) {
border-right: 1px solid var(--el-border-color);
}
.demo-basic .block {
flex: 1;
}
.demo-basic .el-col:not(:last-child) {
border-right: 1px solid var(--el-border-color);
}
@media screen and (max-width: 992px) {
.demo-basic .el-col:not(:last-child) {
border-right: none;
}
}
타입
이미지, 아이콘, 또는 문자를 지원해요.
import { UserFilled } from '@element-plus/icons-vue'
.demo-type {
display: flex;
}
.demo-type > div {
flex: 1;
text-align: center;
}
.demo-type > div:not(:last-child) {
border-right: 1px solid var(--el-border-color);
}
Fallback
이미지 로드에 실패했을 때의 대체 동작이에요.
const errorHandler = () => true
컨테이너 맞춤
이미지 아바타가 컨테이너에 어떻게 맞는지 설정해요. object-fit과 같아요.
import { reactive, toRefs } from 'vue'
import type { CSSProperties } from 'vue'
const state = reactive({
fits: [
'fill',
'contain',
'cover',
'none',
'scale-down',
] as CSSProperties['object-fit'][],
url: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg',
})
const { fits, url } = toRefs(state)
.demo-fit {
display: flex;
text-align: center;
justify-content: space-between;
}
.demo-fit .block {
flex: 1;
display: flex;
flex-direction: column;
flex-grow: 0;
}
.demo-fit .title {
margin-bottom: 10px;
font-size: 14px;
color: var(--el-text-color-secondary);
}
Avatar Group 2.13.1
아바타 그룹으로 표시돼요.
<el-avatar-group> 태그를 사용해서 아바타를 그룹화해요.
- use collapse-avatars
- use collapse-class and collapse-style
- use max-collapse-avatars
- use collapse-avatars-tooltip
const circleUrl =
'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png'
.my-collapse-avatar {
color: #409eff;
}
Avatar API
Avatar Attributes
| Name | Description | Type | Default |
|---|---|---|---|
| icon | 표현 타입을 아이콘으로. icon 컴포넌트에 대한 자세한 정보는 여기에서 확인해요 | string / Component | — |
| size | 아바타 크기 | number / enum | — |
| shape | 아바타 모양 | enum | — |
| src | 이미지 아바타의 이미지 소스 | string | — |
| src-set | 이미지 아바타의 네이티브 속성 srcset | string | — |
| alt | 이미지 아바타의 네이티브 속성 alt | string | — |
| fit | 이미지 아바타가 컨테이너에 맞는 방식을 설정 | enum | cover |
Avatar Events
| Name | Description | Type |
|---|---|---|
| error | 이미지 로드 실패 시 실행돼요 | Function |
Avatar Slots
| Name | Description |
|---|---|
| default | 아바타 내용을 커스터마이즈해요 |
AvatarGroup API 2.13.1
AvatarGroup Attributes
| Name | Description | Type | Default |
|---|---|---|---|
| size | 이 avatar-group의 아바타 크기 제어 | number / enum | — |
| shape | 이 avatar-group의 아바타 모양 제어 | enum | — |
| collapse-avatars | 아바타를 접을지 여부 | boolean | false |
| collapse-avatars-tooltip | collapse-avatar의 텍스트에 마우스를 올리면 접힌 아바타를 모두 표시할지 여부. 사용하려면 collapse-avatars가 true여야 해요 | boolean | false |
| max-collapse-avatars | 표시할 최대 아바타 수. 사용하려면 collapse-avatars가 true여야 해요 | number | 1 |
| effect | tooltip 테마, 내장 테마: dark / light | enum / string | light |
| placement | tooltip의 위치 | enum | top |
| popper-class | tooltip의 커스텀 클래스 이름 | string | '' |
| popper-style | tooltip의 커스텀 스타일 | string / object | — |
| collapse-class | collapse-avatar의 커스텀 클래스 이름 | string | '' |
| collapse-style | collapse-avatar의 커스텀 스타일 | string / object | — |