KButton - farimarwat/KrossUi GitHub Wiki

📘 KButton Component Documentation

A cross-platform customizable button for Kotlin Multiplatform apps.


🔹 Overview

Element Type Description
KButton Composable Public API for showing a customizable cross-platform button.
KButtonColors Data Class Encapsulates button color options for enabled/disabled states.
KButtonDefaults Object Provides default values and utilities for KButton configuration.

🧩 KButton

Definition:
A cross-platform button composable that adapts to the native design on each platform.

Parameters

Parameter Type Description
modifier Modifier Modifier applied to the button.
text String The text displayed inside the button.
onClick () -> Unit Lambda invoked when the button is clicked.
colors KButtonColors Defines enabled/disabled color styles.
fontSize TextUnit Font size of the button text.
cornerRadius Double Corner radius of the button, in dp.
isEnabled Boolean Whether the button is clickable or not.

🎨 KButtonColors

Represents the color configuration for a KButton in both enabled and disabled states.

Properties

Property Type Description
containerColor Color Background color when the button is enabled.
contentColor Color Text color when the button is enabled.
disabledContainerColor Color Background color when the button is disabled.
disabledContentColor Color Text color when the button is disabled.

⚙️ KButtonDefaults

Provides default configuration values for the KButton.

🎛️ colors(...)

Creates a KButtonColors instance with customizable colors.

Parameter Type Default Description
containerColor Color PlatformColors.systemBlue Background when enabled.
contentColor Color Color.White Text color when enabled.
disabledBackgroundColor Color containerColor.copy(0.3f) Background when disabled.
disabledTextColor Color contentColor.copy(0.3f) Text color when disabled.

🔤 DefaultFontSize

Value Description
14.sp Default font size used in button text.

🟦 CornerRadius

Value Description
8.0 Default corner radius of the button in dp.

✅ Usage Example

KButton(
    modifier = Modifier
        .fillMaxWidth(),
    text = "Press Me",
    onClick = {
        // Your click logic here
    }
)