An elegant, animated, and fully customizable Expandable Card component built with Jetpack Compose and Material 3 for Android.
- 🎨 Material 3 Design: Built using standard Material 3
Card,IconButton, andTextcomposables. - 🔄 Smooth Icon Rotation: Arrow dropdown icon rotates 180° smoothly using
animateFloatAsState. - 📐 Animated Content Expansion: Description text enters/exits using
AnimatedVisibilitywith combinedfadeIn()andexpandVertically(). - 📱 Edge-to-Edge & Inset Aware: Fully compatible with Compose
Scaffoldand system bar insets. - 🛡️ Long Title Protection: Uses
TextOverflow.EllipsisandModifier.weight(1f)so long titles never push the icon out of frame. - ⚙️ Highly Customizable: Easily customize title, description, colors, typography, and padding.
- 🛠️ Android Studio Preview: Includes
@Previewannotations for instant design inspection.
import mohamed.mgd.expandablecard.ui.ExpandableCard
@Composable
fun HomeScreen() {
ExpandableCard(
title = "What is Jetpack Compose?",
desc = "Jetpack Compose is Android's modern toolkit for building native UI with less code and intuitive Kotlin APIs.",
modifier = Modifier.padding(16.dp)
)
}| Parameter | Type | Default Value | Description |
|---|---|---|---|
modifier |
Modifier |
Modifier |
Applied to the top-level Card. |
title |
String |
"Title" |
The header title text. |
titleFontSize |
TextUnit |
MaterialTheme.typography.titleLarge.fontSize |
Font size of the title. |
titleFontWeight |
FontWeight |
FontWeight.Bold |
Font weight of the title. |
desc |
String |
"desc" |
Expandable detailed description text. |
descFontSize |
TextUnit |
MaterialTheme.typography.bodyMedium.fontSize |
Font size of the description text. |
descFontWeight |
FontWeight |
FontWeight.Normal |
Font weight of the description text. |
cardColor |
CardColors |
CardDefaults.cardColors() |
Colors applied to the Card. |
padding |
Dp |
12.dp |
Inner padding for the card container. |
- Language: Kotlin
- UI Framework: Jetpack Compose (Material 3)
- Minimum SDK: 26 (Android 8.0)
- Target SDK: 37
- Gradle: Version Catalog (
gradle/libs.versions.toml)
- Clone the repository:
git clone https://github.com/MagdyDeveloper007/ExpandableCard.git
- Open in Android Studio (Ladybug or newer recommended).
- Build & Run on an emulator or physical device.
This project is open-source and available under the MIT License.