Composables
Docs Login
Tally

Template Card

Jetpack Compose Component

Download
package com.composables.tally.components

import androidx.compose.foundation.background
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.unit.dp
import com.composables.compose.ripple.rememberRippleIndication
import com.composables.tally.theme.Space
import com.composables.tally.theme.Theme
import com.composeunstyled.UnstyledButton

@Composable
fun TemplateCard(
    name: String,
    goal: String,
    icon: ImageVector,
    color: Color,
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
) {
    UnstyledButton(
        onClick = onClick,
        modifier =
            modifier
                .fillMaxWidth()
                .heightIn(min = 148.dp)
                .clip(Theme.shapes.medium)
                .background(color),
        contentPadding = PaddingValues(Space * 4),
        contentAlignment = Alignment.TopStart,
        indication = rememberRippleIndication(color = Theme.colors.onBackground),
        interactionSource = remember { MutableInteractionSource() },
    ) {
        Column(
            Modifier.fillMaxWidth(),
            verticalArrangement = Arrangement.spacedBy(Space * 6),
        ) {
            Box(
                Modifier.size(44.dp)
                    .clip(Theme.shapes.fullyRounded)
                    .background(Theme.colors.surface.copy(alpha = 0.6f)),
                contentAlignment = Alignment.Center,
            ) {
                Icon(
                    icon,
                    contentDescription = null,
                    modifier = Modifier.size(22.dp),
                    tint = Theme.colors.onBackground,
                )
            }
            Column {
                Text(name, style = Theme.typography.title, color = Theme.colors.onBackground)
                Text(goal, style = Theme.typography.caption, color = Theme.colors.onBackground)
            }
        }
    }
}

More components from Tally

by Alex Styl

Search screens and components

Screen flows

Screens

UI Elements

One Android lesson, every Wednesday

Building Android apps?

What Alex learned building Android apps for 14 years, so you don't have to. Reads in under a minute.

Join 3,500+ Android developers. Unsubscribe any time.

You're subscribed

The next lesson lands in on Wednesday.