Composables
Docs Login
Vela

Scroll To Latest Button

Jetpack Compose Component

Download
package com.composables.vela.components

import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.scaleIn
import androidx.compose.animation.scaleOut
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.composables.vela.theme.ArrowDown
import com.composables.vela.theme.Icons
import com.composables.vela.theme.Theme

@Composable
fun ScrollToLatestButton(
    visible: Boolean,
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
) {
    AnimatedVisibility(
        visible,
        modifier,
        enter = fadeIn() + scaleIn(initialScale = 0.8f),
        exit = fadeOut() + scaleOut(targetScale = 0.8f),
    ) {
        IconButton(
            onClick = onClick,
            contentDescription = "Scroll to latest",
            variant = IconButtonVariant.Tonal,
            modifier = Modifier.border(1.dp, Theme.colors.border, Theme.shapes.fullyRounded),
        ) {
            Icon(Icons.ArrowDown, contentDescription = null, modifier = Modifier.size(18.dp))
        }
    }
}

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.