ButtonDefaults


Contains the default values used by Button

Summary

Constants

const Float

The default color opacity used for an OutlinedButton's border color

Cmn

Public functions

ButtonColors
@Composable
buttonColors(
    backgroundColor: Color,
    contentColor: Color,
    disabledBackgroundColor: Color,
    disabledContentColor: Color
)

Creates a ButtonColors that represents the default background and content colors used in a Button.

Cmn
ButtonElevation
@Composable
elevation(
    defaultElevation: Dp,
    pressedElevation: Dp,
    disabledElevation: Dp,
    hoveredElevation: Dp,
    focusedElevation: Dp
)

Creates a ButtonElevation that will animate between the provided values according to the Material specification for a Button.

Cmn
ButtonColors
@Composable
outlinedButtonColors(
    backgroundColor: Color,
    contentColor: Color,
    disabledContentColor: Color
)

Creates a ButtonColors that represents the default background and content colors used in an OutlinedButton.

Cmn
ButtonColors
@Composable
textButtonColors(
    backgroundColor: Color,
    contentColor: Color,
    disabledContentColor: Color
)

Creates a ButtonColors that represents the default background and content colors used in a TextButton.

Cmn

Public properties

PaddingValues

The default content padding used by Button

Cmn
Dp

The default size of the icon when used inside a Button.

Cmn
Dp

The default size of the spacing between an icon and a text when they used inside a Button.

Cmn
Dp

The default min height applied for the Button.

Cmn
Dp

The default min width applied for the Button.

Cmn
Dp

The default OutlinedButton's border size

Cmn
PaddingValues

The default content padding used by TextButton

Cmn
BorderStroke

The default disabled content color used by all types of Buttons

Cmn

Constants

OutlinedBorderOpacity

const val OutlinedBorderOpacity = 0.12f: Float

The default color opacity used for an OutlinedButton's border color

Public functions

buttonColors

@Composable
fun buttonColors(
    backgroundColor: Color = MaterialTheme.colors.primary,
    contentColor: Color = contentColorFor(backgroundColor),
    disabledBackgroundColor: Color = MaterialTheme.colors.onSurface .copy(alpha = 0.12f) .compositeOver(MaterialTheme.colors.surface),
    disabledContentColor: Color = MaterialTheme.colors.onSurface.copy(alpha = ContentAlpha.disabled)
): ButtonColors

Creates a ButtonColors that represents the default background and content colors used in a Button.

Parameters
backgroundColor: Color = MaterialTheme.colors.primary

the background color of this Button when enabled

contentColor: Color = contentColorFor(backgroundColor)

the content color of this Button when enabled

disabledBackgroundColor: Color = MaterialTheme.colors.onSurface .copy(alpha = 0.12f) .compositeOver(MaterialTheme.colors.surface)

the background color of this Button when not enabled

disabledContentColor: Color = MaterialTheme.colors.onSurface.copy(alpha = ContentAlpha.disabled)

the content color of this Button when not enabled

elevation

@Composable
fun elevation(
    defaultElevation: Dp = 2.dp,
    pressedElevation: Dp = 8.dp,
    disabledElevation: Dp = 0.dp,
    hoveredElevation: Dp = 4.dp,
    focusedElevation: Dp = 4.dp
): ButtonElevation

Creates a ButtonElevation that will animate between the provided values according to the Material specification for a Button.

Parameters
defaultElevation: Dp = 2.dp

the elevation to use when the Button is enabled, and has no other Interactions.

pressedElevation: Dp = 8.dp

the elevation to use when the Button is enabled and is pressed.

disabledElevation: Dp = 0.dp

the elevation to use when the Button is not enabled.

hoveredElevation: Dp = 4.dp

the elevation to use when the Button is enabled and is hovered.

focusedElevation: Dp = 4.dp

the elevation to use when the Button is enabled and is focused.

outlinedButtonColors

@Composable
fun outlinedButtonColors(
    backgroundColor: Color = MaterialTheme.colors.surface,
    contentColor: Color = MaterialTheme.colors.primary,
    disabledContentColor: Color = MaterialTheme.colors.onSurface.copy(alpha = ContentAlpha.disabled)
): ButtonColors

Creates a ButtonColors that represents the default background and content colors used in an OutlinedButton.

Parameters
backgroundColor: Color = MaterialTheme.colors.surface

the background color of this OutlinedButton

contentColor: Color = MaterialTheme.colors.primary

the content color of this OutlinedButton when enabled

disabledContentColor: Color = MaterialTheme.colors.onSurface.copy(alpha = ContentAlpha.disabled)

the content color of this OutlinedButton when not enabled

textButtonColors

@Composable
fun textButtonColors(
    backgroundColor: Color = Color.Transparent,
    contentColor: Color = MaterialTheme.colors.primary,
    disabledContentColor: Color = MaterialTheme.colors.onSurface.copy(alpha = ContentAlpha.disabled)
): ButtonColors

Creates a ButtonColors that represents the default background and content colors used in a TextButton.

Parameters
backgroundColor: Color = Color.Transparent

the background color of this TextButton

contentColor: Color = MaterialTheme.colors.primary

the content color of this TextButton when enabled

disabledContentColor: Color = MaterialTheme.colors.onSurface.copy(alpha = ContentAlpha.disabled)

the content color of this TextButton when not enabled

Public properties

ContentPadding

val ContentPaddingPaddingValues

The default content padding used by Button

IconSize

val IconSizeDp

The default size of the icon when used inside a Button.

import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.size
import androidx.compose.material.Button
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.Icon
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Favorite
import androidx.compose.ui.Modifier

Button(onClick = { /* Do something! */ }) {
    Icon(
        Icons.Filled.Favorite,
        contentDescription = null,
        modifier = Modifier.size(ButtonDefaults.IconSize)
    )
    Spacer(Modifier.size(ButtonDefaults.IconSpacing))
    Text("Like")
}

IconSpacing

val IconSpacingDp

The default size of the spacing between an icon and a text when they used inside a Button.

import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.size
import androidx.compose.material.Button
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.Icon
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Favorite
import androidx.compose.ui.Modifier

Button(onClick = { /* Do something! */ }) {
    Icon(
        Icons.Filled.Favorite,
        contentDescription = null,
        modifier = Modifier.size(ButtonDefaults.IconSize)
    )
    Spacer(Modifier.size(ButtonDefaults.IconSpacing))
    Text("Like")
}

MinHeight

val MinHeightDp

The default min height applied for the Button. Note that you can override it by applying Modifier.heightIn directly on Button.

MinWidth

val MinWidthDp

The default min width applied for the Button. Note that you can override it by applying Modifier.widthIn directly on Button.

OutlinedBorderSize

val OutlinedBorderSizeDp

The default OutlinedButton's border size

TextButtonContentPadding

val TextButtonContentPaddingPaddingValues

The default content padding used by TextButton

outlinedBorder

val outlinedBorderBorderStroke

The default disabled content color used by all types of Buttons