OudsButton

fun OudsButton(text: String, onClick: () -> Unit, modifier: Modifier = Modifier, enabled: Boolean = true, style: OudsButton.Style = OudsButtonDefaults.Style, hierarchy: OudsButton.Hierarchy = OudsButtonDefaults.Hierarchy)

An OUDS button which displays text only.

In the case it is used in an OudsColoredBox, its monochrome variant is automatically displayed. Some tokens associated with these specific colors can be customized and are identified with the Mono suffix (for instance OudsButtonTokens.colorBgDefaultEnabledMono).

Parameters

text

Text displayed in the button.

onClick

Callback invoked when the button is clicked.

modifier

Modifier applied to the button.

enabled

Controls the enabled state of the button when style is equal to OudsButton.Style.Default. When false, this button will not be clickable. Has no effect when style is equal to OudsButton.Style.Loading.

style

The button style.

hierarchy

The button hierarchy. A button with OudsButton.Hierarchy.Negative hierarchy is not allowed as a direct or indirect child of an OudsColoredBox and will throw an IllegalStateException.

Samples

import androidx.compose.runtime.Composable
import androidx.compose.ui.res.painterResource
import com.orange.ouds.core.component.button.OudsButton
import com.orange.ouds.core.component.coloredbox.OudsColoredBox

fun main() { 
   //sampleStart 
   OudsButton(
    text = "Text",
    onClick = { /* Do something! */ }
) 
   //sampleEnd
}
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.painterResource
import com.orange.ouds.core.component.button.OudsButton
import com.orange.ouds.core.component.coloredbox.OudsColoredBox

fun main() { 
   //sampleStart 
   OudsColoredBox(color = OudsColoredBox.Color.StatusInfoEmphasized) {
    // The colors of this button are automatically adjusted to maximize the contrast with the colored background.
    OudsButton(
        text = "Text",
        onClick = { /* Do something! */ }
    )
} 
   //sampleEnd
}

fun OudsButton(icon: OudsButton.Icon, onClick: () -> Unit, modifier: Modifier = Modifier, enabled: Boolean = true, style: OudsButton.Style = OudsButtonDefaults.Style, hierarchy: OudsButton.Hierarchy = OudsButtonDefaults.Hierarchy)

An OUDS button which displays an icon only.

In the case it is used in an OudsColoredBox, its monochrome variant is automatically displayed. Some tokens associated with these specific colors can be customized and are identified with the Mono suffix (for instance OudsButtonTokens.colorBgDefaultEnabledMono).

Parameters

icon

Icon displayed in the button.

onClick

Callback invoked when the button is clicked.

modifier

Modifier applied to the button.

enabled

Controls the enabled state of the button when style is equal to OudsButton.Style.Default. When false, this button will not be clickable. Has no effect when style is equal to OudsButton.Style.Loading.

style

The button style.

hierarchy

The button hierarchy. A button with OudsButton.Hierarchy.Negative hierarchy is not allowed as a direct or indirect child of an OudsColoredBox and will throw an IllegalStateException.

Samples

import androidx.compose.runtime.Composable
import androidx.compose.ui.res.painterResource
import com.orange.ouds.core.component.button.OudsButton
import com.orange.ouds.core.component.coloredbox.OudsColoredBox

fun main() { 
   //sampleStart 
   OudsButton(
    icon = OudsButton.Icon(
        painterResource(id = android.R.drawable.star_on),
        "Content description"
    ),
    onClick = { /* Do something! */ }
) 
   //sampleEnd
}
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.painterResource
import com.orange.ouds.core.component.button.OudsButton
import com.orange.ouds.core.component.coloredbox.OudsColoredBox

fun main() { 
   //sampleStart 
   OudsColoredBox(color = OudsColoredBox.Color.StatusInfoEmphasized) {
    // The colors of this button are automatically adjusted to maximize the contrast with the colored background.
    OudsButton(
        icon = OudsButton.Icon(
            painterResource(id = android.R.drawable.star_on),
            "Content description"
        ),
        onClick = { /* Do something! */ }
    )
} 
   //sampleEnd
}

fun OudsButton(icon: OudsButton.Icon, text: String, onClick: () -> Unit, modifier: Modifier = Modifier, enabled: Boolean = true, style: OudsButton.Style = OudsButtonDefaults.Style, hierarchy: OudsButton.Hierarchy = OudsButtonDefaults.Hierarchy)

An OUDS button which displays an icon and text.

In the case it is used in an OudsColoredBox, its monochrome variant is automatically displayed. Some tokens associated with these specific colors can be customized and are identified with the Mono suffix (for instance OudsButtonTokens.colorBgDefaultEnabledMono).

Parameters

icon

Icon displayed in the button.

text

Text displayed in the button.

onClick

Callback invoked when the button is clicked.

modifier

Modifier applied to the button.

enabled

Controls the enabled state of the button when style is equal to OudsButton.Style.Default. When false, this button will not be clickable. Has no effect when style is equal to OudsButton.Style.Loading.

style

The button style.

hierarchy

The button hierarchy. A button with OudsButton.Hierarchy.Negative hierarchy is not allowed as a direct or indirect child of an OudsColoredBox and will throw an IllegalStateException.

Samples

import androidx.compose.runtime.Composable
import androidx.compose.ui.res.painterResource
import com.orange.ouds.core.component.button.OudsButton
import com.orange.ouds.core.component.coloredbox.OudsColoredBox

fun main() { 
   //sampleStart 
   OudsButton(
    icon = OudsButton.Icon(
        painterResource(id = android.R.drawable.star_on),
        "Content description"
    ),
    text = "Text",
    onClick = { /* Do something! */ }
) 
   //sampleEnd
}
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.painterResource
import com.orange.ouds.core.component.button.OudsButton
import com.orange.ouds.core.component.coloredbox.OudsColoredBox

fun main() { 
   //sampleStart 
   OudsColoredBox(color = OudsColoredBox.Color.StatusInfoEmphasized) {
    // The colors of this button are automatically adjusted to maximize the contrast with the colored background.
    OudsButton(
        icon = OudsButton.Icon(
            painterResource(id = android.R.drawable.star_on),
            "Content description"
        ),
        text = "Text",
        onClick = { /* Do something! */ }
    )
} 
   //sampleEnd
}