0Pricing
Jetpack Compose Academy · Lesson

Labels, Placeholders & Leading Icons

Make inputs clear and friendly.

Labels, Placeholders & Leading Icons is a free Jetpack Compose Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Jetpack Compose Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Make Inputs Friendly

A bare box leaves users guessing. Labels, placeholders, and icons turn a plain field into one that guides the user. 🧭

The label Slot

The label names the field. It sits inside when empty, then floats up to the border once the field is focused or filled.

OutlinedTextField(
    value = email,
    onValueChange = { email = it },
    label = { Text("Email") }
)

Add a Placeholder

A placeholder is hint text shown only while the field is empty. Use it for an example, not for the field's name.

placeholder = { Text("you@example.com") }

Label vs Placeholder

The label always stays visible to identify the field. The placeholder vanishes the instant the user starts typing. Use both together.

Leading Icons

A leadingIcon sits at the start of the field. An envelope next to an email box makes its purpose obvious at a glance.

leadingIcon = {
    Icon(Icons.Default.Email, contentDescription = null)
}

Trailing Icons Too

A trailingIcon sits at the end. It is perfect for a clear button or a password visibility toggle.

trailingIcon = {
    Icon(Icons.Default.Clear, contentDescription = "Clear")
}

Always Describe Icons

Give each Icon a contentDescription so screen readers can announce it. Pass null only when the icon is purely decorative.

Make the Trailing Icon Tappable

Wrap a trailing icon in an IconButton so users can tap it, for example to clear the field in one touch.

trailingIcon = {
    IconButton(onClick = { email = "" }) {
        Icon(Icons.Default.Clear, "Clear")
    }
}

Supporting Text

supportingText shows a small hint below the field, like a format reminder or a character limit, without crowding the input.

supportingText = { Text("We never share your email.") }

Combine Them Thoughtfully

Label plus icon plus a short placeholder is plenty. Too many hints add noise, so keep each field calm and clear.

Slots Are Just Composables

Every slot, like label and leadingIcon, is a lambda holding Composables. That means you can put any UI you want inside them.

Quick Check

When does a placeholder disappear from a text field?

Recap

You dressed up inputs with a label, placeholder hints, leading and trailing icons, and supporting text. Friendly fields, happy users. 😊

Frequently asked questions

Is the “Labels, Placeholders & Leading Icons” lesson free?

Yes — the full text of “Labels, Placeholders & Leading Icons” is free to read here on the web, and the Jetpack Compose Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Jetpack Compose Academy course, upgrade to CoddyKit PRO.

What will I learn in “Labels, Placeholders & Leading Icons”?

Make inputs clear and friendly. You practise Jetpack Compose Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Jetpack Compose Academy?

No prior experience is required. Jetpack Compose Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Labels, Placeholders & Leading Icons” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Jetpack Compose Academy lesson?

Yes. Every Jetpack Compose Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. TextField & OutlinedTextField
  2. Labels, Placeholders & Leading Icons
  3. Keyboard Types & IME Actions
  4. Inline Validation & Error States
← Back to Jetpack Compose Academy