OtpInputDefaults

Default values for OtpInputField and the built-in cells.

Each function takes every value as an optional argument, so you can change one thing and keep the rest:

OtpInputDefaults.colors(focusedBorderColor = Color(0xFF00D4FF))

Properties

Link copied to clipboard

A number pad with autocorrect off.

Functions

Link copied to clipboard
fun animationSpec(shakeOnError: Boolean = true, cellEntryAnimation: CellAnimation = CellAnimation.Scale, animationDuration: Int = OtpTokens.ANIMATION_DURATION, shakeAmplitude: Dp = OtpTokens.ShakeAmplitude, shakeStepDuration: Int = OtpTokens.SHAKE_STEP_DURATION, shakeRepeatCount: Int = OtpTokens.SHAKE_REPEAT_COUNT): OtpAnimationSpec
Link copied to clipboard
fun colors(focusedBorderColor: Color = MaterialTheme.colorScheme.primary, unfocusedBorderColor: Color = MaterialTheme.colorScheme.outline, errorBorderColor: Color = MaterialTheme.colorScheme.error, filledBorderColor: Color = MaterialTheme.colorScheme.primary.copy(alpha = 0.7f), focusedContainerColor: Color = MaterialTheme.colorScheme.surface, unfocusedContainerColor: Color = MaterialTheme.colorScheme.surface, errorContainerColor: Color = MaterialTheme.colorScheme.errorContainer, filledContainerColor: Color = MaterialTheme.colorScheme.primaryContainer.copy(alpha = 0.3f), textColor: Color = MaterialTheme.colorScheme.onSurface, cursorColor: Color = MaterialTheme.colorScheme.primary, placeholderColor: Color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.38f)): OtpCellColors

Colors taken from the current MaterialTheme.

Link copied to clipboard
fun contentPadding(horizontal: Dp = OtpTokens.ContentPaddingHorizontal, vertical: Dp = OtpTokens.ContentPaddingVertical): OtpCellPadding
Link copied to clipboard
fun cursorConfig(color: Color = MaterialTheme.colorScheme.primary, width: Dp = OtpTokens.CursorWidth, height: Dp = OtpTokens.CursorHeight, cornerRadius: Dp = OtpTokens.CursorCornerRadius, blinkInterval: Long = OtpTokens.CURSOR_BLINK_INTERVAL): OtpCursorConfig

A cursor in the theme's primary color.

Link copied to clipboard
fun dimensions(cellWidth: Dp = OtpTokens.CellWidth, cellHeight: Dp = OtpTokens.CellHeight, borderWidth: Dp = OtpTokens.BorderWidth, focusedBorderWidth: Dp = OtpTokens.FocusedBorderWidth, cornerRadius: Dp = OtpTokens.CornerRadius, spacing: Dp = OtpTokens.Spacing, textSize: TextUnit = OtpTokens.TextSize): OtpCellDimensions
Link copied to clipboard
fun maskConfig(isMasked: Boolean = false, maskCharacter: Char = OtpTokens.MASK_CHARACTER, maskDelay: Long = OtpTokens.MASK_DELAY): OtpMaskConfig

Masking is off by default. Turn it on for codes that shouldn't stay visible on screen.

Link copied to clipboard
fun shape(cornerRadius: Dp = OtpTokens.CornerRadius): Shape
Link copied to clipboard
fun textStyles(textSize: TextUnit = OtpTokens.TextSize, filledTextStyle: TextStyle = TextStyle(fontSize = textSize, fontWeight = FontWeight.Bold), placeholderTextStyle: TextStyle = TextStyle(fontSize = textSize, fontWeight = FontWeight.Light)): OtpTextStyles