Types in EJ2 TypeScript Avatar control
11 Jan 202510 minutes to read
This section explains different types of avatar.
Avatar size
The Essential JS 2 Avatar control has the following predefined sizes that can be used with the .e-avatar
class to change the appearance of the avatar:
Class Name | Description |
---|---|
e-avatar-xlarge | Displays extra-large size avatar. |
e-avatar-large | Displays large size avatar. |
e-avatar | Displays default size avatar. |
e-avatar-small | Displays small size avatar. |
e-avatar-xsmall | Displays extra-small size avatar. |
<!DOCTYPE html>
<html lang="en">
<head>
<title>Essential JS 2 for Avatar </title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Essential JS 2 for Avatar UI Control" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/28.1.33/ej2-base/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/28.1.33/ej2-layouts/styles/material.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'>
<span class="e-avatar e-avatar-xlarge"></span>
<span class="e-avatar e-avatar-large"></span>
<span class="e-avatar"></span>
<span class="e-avatar e-avatar-small"></span>
<span class="e-avatar e-avatar-xsmall"></span>
</div>
</div>
<style>
#element {
display: block;
width: 300px;
margin: 100px auto;
border-radius: 3px;
}
.e-avatar {
background-image: url(https://ej2.syncfusion.com/demos/src/avatar/images/pic01.png);
}
</style>
</body>
</html>
#container {
visibility: hidden;
}
#loader {
color: #008cff;
height: 40px;
width: 30%;
position: absolute;
font-family: 'Helvetica Neue','calibiri';
font-size: 14px;
top: 45%;
left: 45%;
}
Avatar types
The types of Essential JS 2 Avatar controls are:
- Default
- Circle
Default
The default style of the avatar is a rectangular shape with rounded corners. It can be applied by adding the modifier class .e-avatar
to the target element.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Essential JS 2 for Avatar </title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Essential JS 2 for Avatar UI Control" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/28.1.33/ej2-base/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/28.1.33/ej2-layouts/styles/material.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'>
<span class="e-avatar e-avatar-xlarge">RT</span>
<span class="e-avatar e-avatar-large">RT</span>
<span class="e-avatar">RT</span>
<span class="e-avatar e-avatar-small">RT</span>
<span class="e-avatar e-avatar-xsmall">RT</span>
</div>
</div>
<style>
#element {
display: block;
width: 260px;
margin: 100px auto;
border-radius: 3px;
}
</style>
</body>
</html>
#container {
visibility: hidden;
}
#loader {
color: #008cff;
height: 40px;
width: 30%;
position: absolute;
font-family: 'Helvetica Neue','calibiri';
font-size: 14px;
top: 45%;
left: 45%;
}
Circle
The circle avatar style can be applied by adding the modifier class .e-avatar-circle
along with the default avatar modifier class .e-avatar
to the target element.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Essential JS 2 for Avatar </title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Essential JS 2 for Avatar UI Control" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/28.1.33/ej2-base/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/28.1.33/ej2-layouts/styles/material.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'>
<span class="e-avatar e-avatar-xlarge e-avatar-circle">SJ</span>
<span class="e-avatar e-avatar-large e-avatar-circle">SJ</span>
<span class="e-avatar e-avatar-circle">SJ</span>
<span class="e-avatar e-avatar-small e-avatar-circle">SJ</span>
<span class="e-avatar e-avatar-xsmall e-avatar-circle">SJ</span>
</div>
</div>
<style>
#element {
display: block;
width: 260px;
margin: 100px auto;
border-radius: 3px;
}
</style>
</body>
</html>
#container {
visibility: hidden;
}
#loader {
color: #008cff;
height: 40px;
width: 30%;
position: absolute;
font-family: 'Helvetica Neue','calibiri';
font-size: 14px;
top: 45%;
left: 45%;
}