

Aspecto is a grid layout that perfectly preserves each item's aspect ratio for the Jetpack Compose / Compose Multiplatform.
✨ Just as the 🪄 Patronus charm protects its caster, Aspecto protects image layouts from distortion!
Showcase

https://github.com/user-attachments/assets/58cd864b-0a82-431b-ac6e-de755f885b98
Features
- Aspect Ratio Preservation - Maintains natural dimensions of images
- Smart Row Distribution - Magically arranges items for optimal space utilization
- ️Efficient Updates - Uses incremental calculations for smooth performance
- Height Protection - Guards against overly tall items disrupting layouts
- Responsive Layout - Adapts gracefully to different screen sizes
Multiplatform Support
Installation
Add the dependency to your project:
Compose Multiplatform
implementation("com.vipulasri.aspecto:aspecto:<latest-version>")
Android Only
implementation("com.vipulasri.aspecto:aspecto-android:<latest-version>")
Usage
AspectoGrid(
modifier = Modifier.fillMaxWidth(),
contentPadding = PaddingValues(16.dp)
) {
items(
items = images,
key = { it.id },
aspectRatio = { it.width.toFloat() / it.height }
) { image ->
}
}
Android &
iOS samples.
Both samples use the same shared code to demonstrate the Compose Multiplatform capabilities.
Inspired by
License
Copyright 2025 Vipul Asri
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http:
Unless applicable law agreed to writing, software
distributed under the License distributed an BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express implied.
See the License the specific language governing permissions
limitations under the License.