https://github.com/vipulasri/aspecto
Aspect-Perfect Grid for Jetpack Compose / Compose Multiplatform: Achieve precise aspect ratios and seamless layout consistency.
https://github.com/vipulasri/aspecto
android aspect-ratio compose compose-multiplatform grid-layout jetpack-compose kotlin
Last synced: 13 days ago
JSON representation
Aspect-Perfect Grid for Jetpack Compose / Compose Multiplatform: Achieve precise aspect ratios and seamless layout consistency.
- Host: GitHub
- URL: https://github.com/vipulasri/aspecto
- Owner: vipulasri
- License: apache-2.0
- Created: 2024-11-18T03:09:47.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-03-23T13:11:35.000Z (about 1 month ago)
- Last Synced: 2025-03-23T14:22:37.365Z (about 1 month ago)
- Topics: android, aspect-ratio, compose, compose-multiplatform, grid-layout, jetpack-compose, kotlin
- Language: Kotlin
- Homepage:
- Size: 249 KB
- Stars: 113
- Watchers: 1
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

[](https://search.maven.org/search?q=g:com.vipulasri.aspecto)
[](https://github.com/vipulasri/aspecto/actions)
[](https://androidweekly.net/issues/issue-657)[Aspecto](https://github.com/vipulasri/aspecto) is a grid layout that perfectly preserves each item's aspect ratio for the [Jetpack Compose](https://developer.android.com/compose) / [Compose Multiplatform](https://www.jetbrains.com/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
- Android
- iOS## Installation
Add the dependency to your project:
### Compose Multiplatform
```kotlin
implementation("com.vipulasri.aspecto:aspecto:")
```### Android Only
```groovy
implementation("com.vipulasri.aspecto:aspecto-android:")
```## Usage
```kotlin
AspectoGrid(
modifier = Modifier.fillMaxWidth(),
contentPadding = PaddingValues(16.dp)
) {
items(
items = images,
key = { it.id },
aspectRatio = { it.width.toFloat() / it.height }
) { image ->
// content
}
}
```
[Android](https://github.com/vipulasri/aspecto/tree/main/sample) &
[iOS](https://github.com/vipulasri/aspecto/tree/main/iosApp) samples.
Both samples use the same [shared code](https://github.com/vipulasri/aspecto/tree/main/sample/src/commonMain/kotlin/com/vipulasri/aspecto/sample/App.kt) to demonstrate the Compose Multiplatform capabilities.## Inspired by
* [Greedo Layout](https://github.com/500px/greedo-layout-for-android) from [500px](https://github.com/500px)
## License
```
Copyright 2025 Vipul AsriLicensed 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 athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```