Sparsh Dutta
Sparsh Dutta

Reputation: 2970

Change size of cursor in TextField (Jetpack Compose)

I want to decrease the 'height' of cursor in my TextField. How do I do that?

My TextField with default cursor height looks like:

My TextField

Upvotes: 2

Views: 3686

Answers (1)

Samnang CHEA
Samnang CHEA

Reputation: 651

We can custom the text field cursor via CoreTextField.cursorBrush, with Brush.verticalGradient and colorStops argument.

BasicTextField(
    cursorBrush = Brush.verticalGradient(
        0.00f to Color.Transparent,
        0.35f to Color.Transparent,
        0.35f to Color.Green,
        0.90f to Color.Green,
        0.90f to Color.Transparent,
        1.00f to Color.Transparent
    )
)

Upvotes: 1

Related Questions