Composables
Docs Login
Vela

Model Pill

Jetpack Compose Component

Download
package com.composables.vela.components

import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
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.unit.dp
import com.composables.compose.ripple.rememberRippleIndication
import com.composables.vela.theme.CaretDown
import com.composables.vela.theme.Icons
import com.composables.vela.theme.Space
import com.composables.vela.theme.Theme
import com.composeunstyled.UnstyledButton

@Composable
fun ModelPill(
    model: String,
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
) {
    UnstyledButton(
        onClick = onClick,
        modifier = modifier.clip(Theme.shapes.fullyRounded),
        contentPadding = PaddingValues(horizontal = Space * 3, vertical = Space * 1.5f),
        indication = rememberRippleIndication(color = Theme.colors.onSurface),
        interactionSource = remember { MutableInteractionSource() },
    ) {
        Row(
            verticalAlignment = Alignment.CenterVertically,
            horizontalArrangement = Arrangement.spacedBy(Space),
        ) {
            Text(model, style = Theme.typography.label, color = Theme.colors.onSurface)
            Icon(
                Icons.CaretDown,
                contentDescription = null,
                modifier = Modifier.size(14.dp),
                tint = Theme.colors.onBackgroundMuted,
            )
        }
    }
}

More components from Vela

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.