Stupid basic question but … is it possible anyhow ...
# compose
j
Stupid basic question but … is it possible anyhow to change cursor color of basic text field?
c
Yes, there’s a colors parameter that allows you to change several colors of the component
j
Copy code
BasicTextField(
        value = value,
        onValueChange = onChangeText,
        modifier = modifier.then(
            Modifier
                .fillMaxWidth()
                .background(
                    if (isFocused.value) Style.colors.inputActive else Style.colors.inputIdle
                )
                .onFocusChanged {
                    isFocused.value = it.isFocused
                }
        ),
        interactionSource = interactionSource,
        enabled = true,
        singleLine = singleLine,
        textStyle = textStyle,
    ) {
        TextFieldDefaults.TextFieldDecorationBox(
            value = value,
            innerTextField = it,
            singleLine = singleLine,
            visualTransformation = visualTransformation,
            interactionSource = interactionSource,
            leadingIcon = leadingIcon,
            enabled = true,
            trailingIcon = trailingIcon,
            colors = TextFieldDefaults.textFieldColors(
                containerColor = if (isFocused.value) Style.colors.inputActive else Style.colors.inputIdle,
                cursorColor = Style.colors.textLink,
                focusedIndicatorColor = Color.Transparent,
                unfocusedIndicatorColor = Color.Transparent,
            ),
            contentPadding = contentPaddingValues,
            placeholder = placeholder,
        )
    }
}
have this and it just does not work 😞
c
Oh I see - hmm that should in theory work on BasicTextField
j
This does not change cursor color at all so that is why i am completely confused
c
Yeah looking through the implementation it’s not immediately clear how the
cursorBrush
parameter on BasicTextField intersects with TextFieldColors on the inner decoration box. I assume you’ve tried changing cursorBrush on BasicTextField already?
cc @Zach Klippenstein (he/him) [MOD]
z
Cc @Halil Ozercan
In BasicTextField it is a param named cursorBrush
This is how it is set in TextField
In general i think code search might help a lot, and might be easier to understand than the documentation for engineers :)
a
Another e.g..:

here

we’re using BasicTextField’s cursorBrush param with a gradient brush
j
Thx guys a lot this works.