ButtonDefaults
object ButtonDefaults
Contains the default values used by Button
Summary
Constants |
|
---|---|
const Float |
The default color opacity used for an |
Public functions |
|
---|---|
@Composable ButtonColors |
buttonColors( Creates a |
@Composable ButtonElevation |
elevation( Creates a |
@Composable ButtonColors |
outlinedButtonColors( Creates a |
@Composable ButtonColors |
textButtonColors( Creates a |
Public properties |
|
---|---|
PaddingValues |
The default content padding used by |
Dp |
The default size of the icon when used inside a |
Dp |
The default size of the spacing between an icon and a text when they used inside a |
Dp |
The default min height applied for the |
Dp |
The default min width applied for the |
Dp |
The default |
PaddingValues |
The default content padding used by |
BorderStroke |
The default disabled content color used by all types of |
Constants
OutlinedBorderOpacity
const val OutlinedBorderOpacity: 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 |
contentColor: Color = contentColorFor(backgroundColor) |
the content color of this |
disabledBackgroundColor: Color = MaterialTheme.colors.onSurface.copy(alpha = 0.12f)
.compositeOver(MaterialTheme.colors.surface) |
the background color of this |
disabledContentColor: Color = MaterialTheme.colors.onSurface
.copy(alpha = ContentAlpha.disabled) |
the content color of this |
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 |
pressedElevation: Dp = 8.dp |
the elevation to use when the |
disabledElevation: Dp = 0.dp |
the elevation to use when the |
hoveredElevation: Dp = 4.dp |
the elevation to use when the |
focusedElevation: Dp = 4.dp |
the elevation to use when the |
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 |
contentColor: Color = MaterialTheme.colors.primary |
the content color of this |
disabledContentColor: Color = MaterialTheme.colors.onSurface
.copy(alpha = ContentAlpha.disabled) |
the content color of this |
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 |
contentColor: Color = MaterialTheme.colors.primary |
the content color of this |
disabledContentColor: Color = MaterialTheme.colors.onSurface
.copy(alpha = ContentAlpha.disabled) |
the content color of this |
Public properties
IconSize
val IconSize: Dp
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.Icon import androidx.compose.material.Text Button(onClick = { /* Do something! */ }) { Icon( Icons.Filled.Favorite, contentDescription = null, modifier = Modifier.size(ButtonDefaults.IconSize) ) Spacer(Modifier.size(ButtonDefaults.IconSpacing)) Text("Like") }
IconSpacing
val IconSpacing: Dp
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.Icon import androidx.compose.material.Text Button(onClick = { /* Do something! */ }) { Icon( Icons.Filled.Favorite, contentDescription = null, modifier = Modifier.size(ButtonDefaults.IconSize) ) Spacer(Modifier.size(ButtonDefaults.IconSpacing)) Text("Like") }
MinHeight
val MinHeight: Dp
The default min height applied for the Button
. Note that you can override it by applying Modifier.heightIn directly on Button
.
MinWidth
val MinWidth: Dp
The default min width applied for the Button
. Note that you can override it by applying Modifier.widthIn directly on Button
.
TextButtonContentPadding
val TextButtonContentPadding: PaddingValues
The default content padding used by TextButton
outlinedBorder
val outlinedBorder: BorderStroke
The default disabled content color used by all types of Button
s