Back to Snippets

Modern AI Image Generation Gallery JS

Type a prompt and press generate. A colored border spins around the input while it works, three skeleton cards hold the layout, then images fade in over them in a bento grid.

The prompt box grows with your text by resetting its height to auto and then setting it to scrollHeight on every input event. That reset matters, because scrollHeight can only report a smaller value once the element has been allowed to collapse first. The spinning border is a conic-gradient on a pseudo element that only gets its colors while the generating class is applied.

Skeletons occupy the exact grid cells the results will use, so the layout never jumps when the images arrive, and each image gets a staggered animation-delay from its index. The 3.5 second timeout stands in for a real request, so drop your API call in its place and leave the skeleton and reveal steps where they are.

208
#javascript
#css
#ai
#image generation
#gallery
#skeleton loader
#ui
#bento box
#workspace
#glassmorphism