Skip to main content

SignOutButton

The SignOutButton composable renders a pre-styled button that calls ThunderIDClient.signOut(), then calls ThunderIDState.refresh() to update the reactive auth state. It disables itself automatically while the sign-out operation is in progress.

SignOutButton requires ThunderIDProvider in its ancestor composable hierarchy.

Usage

import dev.thunderid.compose.components.actions.SignOutButton

@Composable
fun HomeView() {
Column {
Text("You are signed in.")
SignOutButton()
}
}

Parameters

ParameterTypeRequiredDescription
modifierModifierCompose modifier applied to the button.
onSignOutComplete(() -> Unit)?Called after sign-out completes and ThunderIDState has been refreshed.

Example: Handle Sign-Out Completion

SignOutButton(
onSignOutComplete = {
// Navigate to the landing screen or perform cleanup
println("User has signed out")
}
)

Customization with BaseSignOutButton

BaseSignOutButton is the unstyled variant. Use it to implement your own sign-out UI while delegating the actual sign-out logic to thunder.client.signOut().

import dev.thunderid.compose.components.actions.BaseSignOutButton
import dev.thunderid.compose.LocalThunderID

@Composable
fun CustomSignOutButton() {
val thunder = LocalThunderID.current
val scope = rememberCoroutineScope()

BaseSignOutButton(
label = "Log Out",
isLoading = thunder.isLoading,
modifier = Modifier.fillMaxWidth()
) {
scope.launch {
runCatching { thunder.client.signOut() }
thunder.refresh()
}
}
}

BaseSignOutButton Parameters

ParameterTypeRequiredDescription
labelStringThe button label text.
isLoadingBooleanWhen true, the button is disabled. Defaults to false.
modifierModifierCompose modifier.
onClick() -> UnitCalled when the button is tapped.
ThunderID LogoThunderID Logo

Product

DocsAPIsSDKs
© WSO2 LLC. All rights reserved.Privacy PolicyCookie Policy