Build a screen
Use BasicScreen for the title bar and content area, and ScreenCard or Items to group the content. Opt in with @OptIn(UnstableSaltUiApi::class) for these APIs.
BasicScreen
Pass a title and back callback. BasicScreen handles title placement, safe areas, and the backdrop behind the bar. Desktop displays the title and subtitle side by side.
BasicScreen(
onBack = { },
title = "Settings"
) { contentPadding ->
// Page content
}Content area
Apply the provided contentPadding to the scroll container. It includes the title bar and safe-area spacing. BasicScreen also accounts for the title bar when bringing focused content into view.
BasicScreen(
onBack = { },
title = "Settings"
) { contentPadding ->
Column(
modifier = Modifier
.fillMaxSize()
.verticalScroll(rememberScrollState())
) {
Spacer(Modifier.height(contentPadding.calculateTopPadding()))
// Page content
Spacer(Modifier.height(contentPadding.calculateBottomPadding()))
}
}Customize the leading action
The onBack overload installs the built-in back button. Use actionButton to replace it. Set it to null for a title without a leading action.
BasicScreen(
actionButton = {
BasicScreenDefaults.BackButton(onBack = { })
},
title = "Settings"
) { contentPadding ->
// Page content
}Add trailing actions
Place frequently used page actions in toolButtons. Keep labels and titles short enough to fit the single-line bar.
BasicScreen(
onBack = { },
title = "Settings",
toolButtons = {
TitleBarButton(onClick = { /* ... */ }) {
Icon(
painter = rememberVectorPainter(SaltIcons.Check),
contentDescription = null
)
}
}
) { contentPadding ->
// Page content
}Title bar backdrop
TitleBarBackdropType | Appearance | Availability |
|---|---|---|
Progressive | Progressive blur that fades into the content | iOS and Android 13+ |
Mask | Uniform blur with a fade mask | Desktop and Android 12+ |
None | No backdrop effect | All targets |
The default picks a supported effect. Use isSupported() or supportedEntries() when exposing options in app settings. Set a page’s style to customize one bar, or SaltTheme’s basicScreenStyle to customize the theme.
Title bar guidance
Use the screen’s padding and give the title a short label. Put the most frequently used actions in the title bar and place less frequent actions in the content.
TitleBarButton
Use TitleBarButton for icon actions in the bar. The control draws press and disabled feedback. Give its icon an accessible name that conveys the action.
TitleBarButton(
onClick = { },
icon = {
Icon(
painter = rememberVectorPainter(SaltIcons.Check),
contentDescription = null
)
}
)ScreenCard
A ScreenCard combines an optional heading, themed card, and optional supporting text. Put it in the scroll container that already applies the screen's padding.
ScreenCard(
header = "Playback",
footer = "Changes take effect when the app restarts."
) {
Item(
text = "Equalizer",
onClick = { }
)
Item(
text = "Playback speed",
onClick = { }
)
}BasicScreen(
onBack = { },
title = "Settings"
) { contentPadding ->
Column(
modifier = Modifier
.fillMaxSize()
.verticalScroll(rememberScrollState())
) {
Spacer(Modifier.height(contentPadding.calculateTopPadding()))
ScreenCard(header = "Playback") {
// Settings rows
}
ScreenCard(header = "About") {
// Settings rows
}
Spacer(Modifier.height(contentPadding.calculateBottomPadding()))
}
}Section guidance
Group related rows under a short heading. Use the footer for consequences, availability, or timing that the rows cannot convey on their own.
Cupertino scrolling
com.moriafly.salt.ui.gestures.cupertino provides a rubber-band overscroll effect, fling behavior, and a decay animation spec. On iOS, SaltUI scroll containers already use Cupertino fling behavior.
Enable across the app
Provide CupertinoOverscrollEffectFactory at the app root to use the effect across scroll containers.
import androidx.compose.foundation.LocalOverscrollFactory
import com.moriafly.salt.ui.gestures.cupertino.CupertinoOverscrollEffectFactory
CompositionLocalProvider(
LocalOverscrollFactory provides CupertinoOverscrollEffectFactory()
) {
// App content
}Enable for one scroll container
Create a rememberCupertinoOverscrollEffect() for the container. Disable individual edges with allowTopOverscroll, allowBottomOverscroll, allowStartOverscroll, and allowEndOverscroll to coordinate nested scrollers.
import com.moriafly.salt.ui.gestures.cupertino.rememberCupertinoOverscrollEffect
val overscrollEffect = rememberCupertinoOverscrollEffect()
Column(
modifier = Modifier
.verticalScroll(
state = rememberScrollState(),
overscrollEffect = overscrollEffect
)
) {
// Content
}Scrolling guidance
Use consistent overscroll within the app. iOS already uses Cupertino fling behavior. For nested scrollers, configure the edges to avoid competing gestures.
Complete settings screen
@OptIn(UnstableSaltUiApi::class)
@Composable
fun SettingsScreen(onBack: () -> Unit) {
BasicScreen(
onBack = onBack,
title = "Settings",
toolButtons = {
TitleBarButton(onClick = { /* Done */ }) {
Icon(
painter = rememberVectorPainter(SaltIcons.Check),
contentDescription = null
)
}
}
) { contentPadding ->
Column(
modifier = Modifier
.fillMaxSize()
.verticalScroll(rememberScrollState())
) {
Spacer(Modifier.height(contentPadding.calculateTopPadding()))
ScreenCard(
header = "Appearance",
footer = "Follow the system light or dark appearance."
) {
Item(
text = "Theme",
onClick = { }
)
}
ScreenCard(header = "About") {
Item(
text = "Version",
onClick = { }
)
}
Spacer(Modifier.height(contentPadding.calculateBottomPadding()))
}
}
}