# <image> Development
The <image> component is used to render and display images. For details, see [image](../reference/arkui-js/js-components-basic-image.md).
## Creating an <image> Component
Create an <image> component in the .hml file under pages/index.
```
```
```
/* xxx.css */
.container {
flex-direction: column;
justify-content: center;
align-items: center;
background-color: #F1F3F5;
}
```

## Setting the Image Style
Set the width, height, and object-fit attributes to define the width, height, and scale type of an image.
```
```
```
/* xxx.css */
.container {
flex-direction: column;
align-items: center;
justify-content: center;
background-color:#F1F3F5;
}
image{
width: 80%; height: 500px;
border: 5px solid saddlebrown;
border-radius: 20px;
object-fit: contain;
match-text-direction:true;
}
```

## Display Multiple Images
Define a for loop to display multiple images cyclically. Set option to specify the image scale style. For details about the scale styles, see the description of object-fit.
```
image{{$idx}}content
```
```
/* xxx.css */
.page-container {
flex-direction:column;
background-color:#F1F3F5;
}
.text-container {
width: 300px;
flex-direction: column;
justify-content: center;
}
.item-container {
flex-direction: row;
align-items: center;
justify-content:center;
margin-top:200px;
}
.testimage {
width: 175px;
height: 220px;
border: 5px solid #add8e6;
padding: 5px 5px 5px 5px;
margin: 5px 5px 5px 5px;
}
.testicon {
width: 50px;
height: 50px;
margin-left: 150px;
border-radius: 25px;
background-color: orange;
}
```
```
/* index.js */
export default {
data: {
url:['common/images/bg-tv.jpg','common/images/img2.jpg'],
list:[0,1],
fit:'cover',
fit_list:['cover','contain','fill','none','scale-down']
},
setfit(e) {
this.fit = e.newValue
}
}
```

## Loading Images
When an image is successfully loaded, the complete event is triggered, and the loaded image is returned. If an exception occurs during image loading, the error event is triggered, and the image loading failure is printed.
```
```
```
/* xxx.css */
.container{
flex-direction: column;
justify-content: center;
align-self: center;
background-color: #F1F3F5;
}
.container div{
margin-left: 10%;
width: 80%;
height: 300px;
margin-bottom: 40px;
}
```
```
/* index.js */
import prompt from '@system.prompt';
export default {
imageComplete(i,e){
prompt.showToast({
message: "Image "+i+"'s width"+ e.width+"----Image "+i+"'s height"+e.height,
duration: 3000,
})
},
imageError(i,e){
setTimeout(()=>{
prompt.showToast({
message: "Failed to load image "+i+".",
duration: 3000,
})
},3000)
}
}
```

## Example Scenario
In this example you touch and hold an image to gradually hide it. After the image is completely hidden, it will show in its original setting. Set a setInterval timer to change the image opacity at a specified interval so that it is hidden gradually. When the opacity changes to 0, the timer is cleared and the opacity is set to 1.
```