Skip to content

Install SaltUI ​

Add SaltUI to an existing Compose Multiplatform project and wrap your UI in SaltTheme.

Add the dependency ​

Add mavenCentral() to your project's dependency repositories. In a shared module, add the dependency to commonMain. In an Android-only project, use the module's dependencies block.

kotlin
commonMain.dependencies {
    implementation("io.github.moriafly:salt-ui:3.1.0-alpha02")
}

The example uses the published 3.1.0-alpha02 from Maven Central. Check the matching Compose compatibility table and release notes.

Modules ​

ModuleArtifact under io.github.moriaflyWhen to use it
UIsalt-uiThemes and UI components. Includes Core and Adaptive Window transitively.
Navigationsalt-ui-navigationNavigation 3 integration with a back and forward stack.
Coresalt-corePlatform utilities in a module that uses only Core.
Adaptive Windowsalt-adaptive-windowWindow information in a module that uses only Adaptive Window.

Use the same version for all SaltUI artifacts. The UI module requires Android API 23 or later. The Navigation module requires API 24 or later. See Android for application setup.

Build your first screen ​

kotlin
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import com.moriafly.salt.ui.SaltConfigs
import com.moriafly.salt.ui.SaltTheme
import com.moriafly.salt.ui.Text

@Composable
fun App() {
    SaltTheme(
        configs = SaltConfigs.default(isDarkTheme = false)
    ) {
        Box(
            modifier = Modifier.fillMaxSize(),
            contentAlignment = Alignment.Center
        ) {
            Text(text = "Hello, SaltUI")
        }
    }
}

This example uses light mode. To follow the system, pass the result of isSystemInDarkTheme() to SaltConfigs.default(isDarkTheme = ...). For colors, typography, and shapes, see Theme.

Use SaltUI alongside Material or Material 3 ​

Import the SaltUI versions of Text and Icon to read colors and styles from SaltTheme.

kotlin
import com.moriafly.salt.ui.Icon
import com.moriafly.salt.ui.Text

Provide MaterialTheme to Material 3 components and explicitly map any colors you want to share between themes.

Unstable APIs ​

Opt in at the use site for APIs marked with @UnstableSaltUiApi. Core and Adaptive Window have their own opt-in annotations.

kotlin
import com.moriafly.salt.ui.UnstableSaltUiApi

@OptIn(UnstableSaltUiApi::class)
@Composable
fun SettingsPage() {
    // Call APIs marked with UnstableSaltUiApi.
}

Check the source and release notes for the version you use when upgrading.

Next steps ​

Google/Android 是 Google LLC 的注册商标,Salt Player 和糖醋音乐均是寻浔科技(上海)有限公司在中华人民共和国的注册商标