Android Jetpack Compose implementation of the SBB Mobile Design System | Read-only mirror of https://github.com/SchweizerischeBundesbahnen/mds-android-compose — SBB. Issues & pull requests at the source.
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
github-actions[bot] e13c498c6c
chore: update SBB icons to 1.8.40 (#108)
Co-authored-by: rawi-coding <62793354+rawi-coding@users.noreply.github.com>
2026-11-19 17:22:46 +01:00
.github chore(ci): harden nightly icon update (#104) 2026-11-13 13:14:11 +01:00
compose-mds chore: update SBB icons to 1.8.40 (#108) 2026-11-19 17:22:46 +01:00
example docs: use SBBSpacing on all components (#71) (#102) 2026-11-10 11:19:08 +01:00
goldenfiles chore: update SBB icons to 1.8.39 (#106) 2026-11-16 08:50:01 +01:00
gradle chore: format code and update klint rules 2026-11-06 16:42:31 +01:00
tool/sbb-icons chore: update SBB icons to 1.8.40 (#108) 2026-11-19 17:22:46 +01:00
.editorconfig feat: automate icon generation (#97) (#98) 2026-11-06 16:42:31 +01:00
.gitattributes #45 | Enabled git lfs 2025-07-18 09:45:35 +02:00
.gitignore feat: implementation of SBBTheme, SBBColors, SBBIcons and some base components 2024-09-13 10:05:35 +02:00
build.gradle.kts chore: update dependencies 2026-11-06 16:42:31 +01:00
CHANGELOG.md chore: update SBB icons to 1.8.40 (#108) 2026-11-19 17:22:46 +01:00
CODE_OF_CONDUCT.md Initial commit 2024-09-06 13:13:41 +02:00
CODING_STANDARDS.md feat: implementation of SBBTheme, SBBColors, SBBIcons and some base components 2024-09-13 10:05:35 +02:00
COMPONENT_MIGRATION.md chore: remove unused doc files 2026-11-06 16:42:31 +01:00
CONTRIBUTING.md docs: update CONTRIBUTING.md 2026-11-06 16:42:31 +01:00
gradle.properties chore: release 0.2.0 2026-11-06 16:56:16 +01:00
gradlew feat: implementation of SBBTheme, SBBColors, SBBIcons and some base components 2024-09-13 10:05:35 +02:00
gradlew.bat feat: implementation of SBBTheme, SBBColors, SBBIcons and some base components 2024-09-13 10:05:35 +02:00
LICENSE.md feat: implementation of SBBTheme, SBBColors, SBBIcons and some base components 2024-09-13 10:05:35 +02:00
README.md (#10) implementation of chip 2026-06-25 10:40:34 +02:00
RELEASE.md chore(ci): release workflows (#99) 2026-11-06 16:42:31 +01:00
settings.gradle.kts Feature/upgrade agp 9 (#79) 2026-06-05 11:26:24 +02:00

Table Of Contents

Introduction

SBB Design System Mobile in Android Jetpack Compose.

This framework contains SBB (Swiss Federal Railways) UI elements for Android Jetpack Compose Apps. It allows an easy integration of SBB theming to your app.

Note: This plugin is still under development and some APIs might change. Feedback and Pull Requests are most welcome!

Please read CONTRIBUTING, CODING_STANDARDS and CODE_OF_CONDUCT if you want to contribute. Changes can be found in the CHANGELOG.

Getting-Started

To import the SBB Design System Mobile, please add the JitPack repository to your root settings.gradle.kts or build.gradle.kts at the end of repositories:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        ...
         maven {
            url = uri("https://jitpack.io")
        }
    }
}

Next, declare the SBB Design System Mobile artifacts in libs.versions.toml.Check the available versions in JitPack Packages.

[versions]
mds = "0.2.0"

[libraries]
mds-sbb = { group = "com.github.SchweizerischeBundesbahnen", name = "mds-android-compose", version.ref = "mds" }

Add the SBB Design System Mobile dependency to your app/build.gradle.kts:

dependencies {
        implementation(libs.mds.sbb)
}

To use the Components in code, make sure to wrap the the App with a SBBTheme and Scaffold or Surface.

SBBTheme {
    Scaffold {
        MainPage(navController = rememberNavController())
    }
}

To use the Components with the SBB Typography, please find the SBB Font, save it as resources and initialize the SBBTheme

val fontFamily = FontFamily(
    Font(R.font.sbb_web_italic, FontWeight.Normal, FontStyle.Italic),
    Font(R.font.sbb_web_bold, FontWeight.Bold),
    Font(R.font.sbb_web_light, FontWeight.Light),
    Font(R.font.sbb_web_roman, FontWeight.Normal),
    Font(R.font.sbb_web_thin, FontWeight.Thin),
    Font(R.font.sbb_web_ultra_light, FontWeight.ExtraLight)
)
SBBTheme(fontFamily = fontFamily) {
    ...
}

Golden File Screenshot Testing

This project uses Roborazzi for screenshot testing to prevent unintended visual regressions. The tests generate "golden file" images from the @Preview composables located in the example module and compare them against previously recorded versions.

Important:

  • The @Preview composables must not be declared as private, otherwise Roborazzi will ignore them.
  • When wrapping the preview in SBBTheme, set the parameter includeSurface = true — otherwise dark mode rendering will not work correctly.

Example:

@PreviewLightDark
@Composable
fun ExamplePagePreview() {
    SBBTheme(includeSurface = true) {
        ExamplePage()
    }
}

All golden files are stored in the /goldenfiles directory at the root of the project.

Verifying and Updating Golden Files

To verify that your changes have not caused any visual regressions, run the verification task. This will compare newly generated screenshots with the existing golden files.

./gradlew :example:verifyRoborazziDebug

To update the golden files after making an intentional UI change, you must record the new versions. This will overwrite the existing files with the latest output.

./gradlew :example:recordRoborazziDebug

Workflow for UI Changes

Adding a New Component

  1. Create the new component in the compose-mds library.
  2. In the example module, add a new file with one or more @Preview functions to showcase the component's different states.
  3. Generate the initial golden file by running the record task:
    ./gradlew :example:recordRoborazziDebug
    
  4. A new image file will be created in the /goldenfiles directory. Review it to ensure it matches the component's design.
  5. Commit the new component, the preview file, and the generated golden file.

Modifying an Existing Component

  1. Make your intended UI changes to a component in the compose-mds library.
  2. Run the verification task. The test for the component you changed should fail.
    ./gradlew :example:verifyRoborazziDebug
    

    Note: If the test does not fail, your change is likely not covered by the existing @Preview. You may need to adjust the preview to properly display the modification.

  3. After confirming the test failure is expected, record the updated golden file:
    ./gradlew :example:recordRoborazziDebug
    
  4. Review the modified image in the /goldenfiles directory to ensure it correctly reflects your changes.
  5. Commit your code changes along with the updated golden file.

License

This project is licensed under MIT.