Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Jetpack Compose: Can't find OutlinedTextField in Empty Compose Activity (Material3)

When I create new project and select "Empty Compose Activity (Material3)", I can't use OutlinedTextField.

OutlinedTextField not shown

When I create new project and select "Empty Compose Activity" it's Ok OutlinedTextField shown

Why there is a different and how can I fix this?

like image 398
Yaniv Avatar asked Oct 17 '25 13:10

Yaniv


1 Answers

In your build.gradle upgrade the Material3 dependency to the latest as below.

implementation 'androidx.compose.material3:material3:1.0.1'

This shows OutlinedTextField in the project.

You must also add the @OptIn(ExperimentalMaterial3Api::class) to your function as below.

@OptIn(ExperimentalMaterial3Api::class)
OutlinedTextField(
    value = text,
    onValueChange = { text = it },
)
like image 191
Shaik MD Ashiq Avatar answered Oct 20 '25 10:10

Shaik MD Ashiq



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!