Skip to content

About

Expandable Card example

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

8 Commits

Folders and files

Repository files navigation

ExpandableCard 📇

An elegant, animated, and fully customizable Expandable Card component built with Jetpack Compose and Material 3 for Android.

Kotlin Jetpack Compose Min SDK


🌟 Features

  • 🎨 Material 3 Design: Built using standard Material 3 Card, IconButton, and Text composables.
  • 🔄 Smooth Icon Rotation: Arrow dropdown icon rotates 180° smoothly using animateFloatAsState.
  • 📐 Animated Content Expansion: Description text enters/exits using AnimatedVisibility with combined fadeIn() and expandVertically().
  • 📱 Edge-to-Edge & Inset Aware: Fully compatible with Compose Scaffold and system bar insets.
  • 🛡️ Long Title Protection: Uses TextOverflow.Ellipsis and Modifier.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 @Preview annotations for instant design inspection.

💻 Usage

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)
    )
}

⚙️ Component Parameters

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.

🛠️ Tech Stack & Requirements

  • Language: Kotlin
  • UI Framework: Jetpack Compose (Material 3)
  • Minimum SDK: 26 (Android 8.0)
  • Target SDK: 37
  • Gradle: Version Catalog (gradle/libs.versions.toml)

🚀 Getting Started

  1. Clone the repository:
    git clone https://github.com/MagdyDeveloper007/ExpandableCard.git
  2. Open in Android Studio (Ladybug or newer recommended).
  3. Build & Run on an emulator or physical device.

📄 License

This project is open-source and available under the MIT License.

About

Expandable Card example

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages