Hello and welcome! 🎉
Our project components are designed using the Windows UI Kit Figma guidelines. Therefore, the layout and style of the components must strictly adhere to this design guide. Additionally, the components showcased in the Gallery should align as closely as possible with this design guide.
We are thrilled to have you considering contributing to Compose-Fluent-UI. Contributions are what make the open-source community such an incredible place to learn, inspire, and create. Here are some guidelines to help you get started:
- Fork this repository: Click on the "Fork" button at the top right of this page. This will create a copy of the repository in your account.
- Select the Dev branch: Choose the
devbranch as your base branch. - Create a new branch: Create a new branch from
devfor your feature or bug fix usinggit checkout -b your-branch-name. - Base all development work on your new branch: Ensure that all your development work is committed to the branch you just created from
dev.
- Create the source code: In the
fluent/componentsdirectory, create the source code for the component that corresponds to the Windows UI Kit.
// Button.kt
package io.github.composefluent.components- Handle internal classes: If your component involves internal classes that may be used by other components (such as
OverflowRow), create the relevant classes in the appropriate package (e.g.,/layout).
// OverflowRow.kt
package io.github.composefluent.layout.overflow
@Composable
internal fun OverflowRow(
modifier: Modifier = Modifier,
overflow: OverflowPosition = OverflowPosition.End,
state: OverflowRowState = rememberOverflowRowState(),
horizontalArrangement: Arrangement.Horizontal = Arrangement.Start,
verticalAlignment: Alignment.Vertical = Alignment.CenterVertically,
overflowAction: @Composable OverflowActionScope.() -> Unit = {},
contentPadding: PaddingValues = PaddingValues(),
alwaysShowOverflowAction: Boolean = false,
content: OverflowRowScope.() -> Unit
)- Adhere to guidelines: When developing, strictly follow the Windows UI Kit for layout, typography, and color.
- Include TODOs for animations: If your component involves animations and you're unsure of the specific parameters to use, add a
TODOnote.
The Gallery app uses KSP and KotlinPoet to automatically generate a navigation tree and Kotlin example source code. Below are the steps to add a component example page in the Gallery:
- Create [YourComponent]Screen.kt: In the package corresponding to the component group, create a
[YourComponent]Screen.ktfile.
// ButtonScreen.kt
package io.github.composefluent.gallery.screen.basicinput- Create a method with @Component annotation: Create a method named
[YourComponent]Screenand annotate it with@Component, providing the relevantdescriptionandindex.
// ButtonScreen.kt
@Component(index = 0, description = "A control that responds to user input")
@Composable
fun ButtonScreen() {
}- Use GalleryPage method: In this method, use the
GalleryPagemethod to create a uniform component example page layout. TheGalleryPagemethod takescomponentPathandgalleryPathas parameters, which are provided by theFluentSourceFileandComponentPagePathclasses generated by KSP, indicating the source code path of the component and the corresponding Gallery example code path.
// ButtonScreen.kt
@Component(index = 0, description = "A control that responds to user input")
@Composable
fun ButtonScreen() {
GalleryPage(
componentPath = FluentSourceFile.Button,
galleryPath = ComponentPagePath.ButtonScreen,
) {
// Sample sections.
}
}- Use Section method in GalleryPage: Within
GalleryPage, use theSectionmethod for each component example. TheSectionmethod providesoutputandoptionsparameters for adjusting options and display output. ThesourceCodeparameter should be the global variable generated by the@Sampleannotation (which contains the component source code).
// ButtonScreen.kt
@Component(index = 0, description = "A control that responds to user input")
@Composable
fun ButtonScreen() {
GalleryPage(
componentPath = FluentSourceFile.Button,
galleryPath = ComponentPagePath.ButtonScreen,
) {
val clickTextContent = remember { mutableStateOf("") }
val buttonEnabled = remember { mutableStateOf(true) }
Section(
title = "A simple Button with text content.",
content = {
ButtonSample(enabled = buttonEnabled.value) { clickTextContent.value = "You clicked: Button 1" }
},
output = {
if (clickTextContent.value.isNotBlank()) {
Text(clickTextContent.value)
}
},
options = {
CheckBox(
checked = !buttonEnabled.value,
onCheckStateChange = { buttonEnabled.value = !it },
label = "Disable button"
)
},
sourceCode = sourceCodeOfButtonSample
)
}
}- Create an example: In the
[YourComponent]Screen.ktfile, add a new method named[YourComponentCase]Samplewith a private visibility modifier, and annotate this method with@Sample. This will generate a global variablesourceCodeOf[YourComponentCase]Sample, which should be assigned to thesourceCodeparameter in the correspondingSection.
//ButtonScreen.kt
@Sample
@Composable
private fun ButtonSample(enabled: Boolean = true, onClick: () -> Unit) {
Button(disabled = !enabled, onClick = onClick) {
Text("Standard Compose Button")
}
}- Add new groups if needed: If you cannot find the appropriate group for the component, add a new group in the
ComponentGroupInfoobject, following the format of the existing groups. After adding the group, place the Screen file in the corresponding package.
// ComponentGrupInfo.kt
package io.github.composefluent.gallery.component
object ComponentGroupInfo {
prival const val screenPackage: String = "io.github.composefluent.gallery.screen"
// Basic Input is group name, ChckboxChecked is icon, packageMap is the component screens under this group were placed, like ButtonScreen
@ComponentGroup("CheckboxChecked", index = 2, packageMap = "$screenPackage.basicinput")
const val BasicInput = "Basic input"
//other groups
//....
}-
At the end, you should see the component example page you've created in the Gallery, ready for demonstration and testing.

-
Debugging components with scale mode if needed: If you need to debug your component with scale mode, you can test it in
TestComponentScreen. Navigate to this test page in the Gallery app throughSettings > Test Component.
If you have any questions or need assistance, feel free to open an issue or reach out to the maintainers. We’re here to help!
Thank you for considering contributing to Compose-Fluent-UI. We can’t wait to see what you’ll create!