Background, Border & Clip
Add color, outlines, and rounded shapes.
Background, Border & Clip 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.
Decorate with Modifiers
Beyond sizing, modifiers can decorate a Composable. You can paint a background, draw a border, and round its corners. 🎨
Add a Background
background fills a Composable with a solid color. It paints the whole area the element occupies, including its size and fill.
Modifier.background(Color.Blue)Use Theme Colors
Prefer theme colors over raw values. Pulling from MaterialTheme keeps your app consistent in light and dark mode.
Modifier.background(
MaterialTheme.colorScheme.primary
)Draw a Border
Use border to outline a Composable. Give it a thickness in dp and a color, and Compose draws the edge for you.
Modifier.border(2.dp, Color.Gray)Meet Shapes
A Shape describes an outline like rounded or circular. Both background and border accept a shape to change their silhouette.
Rounded Corners
RoundedCornerShape softens corners by a radius in dp. It is the go-to shape for cards, buttons, and chips.
RoundedCornerShape(12.dp)Shaped Background
Pass a shape to background and the color fills only inside that outline, giving you a tidy rounded panel.
Modifier.background(
Color.LightGray,
RoundedCornerShape(12.dp)
)Clip the Content
clip trims anything drawn outside a shape. Use it so images and children respect your rounded corners.
Modifier.clip(RoundedCornerShape(12.dp))Make a Circle
Reach for CircleShape when you want a perfect circle, like a round avatar or a floating button.
Modifier.clip(CircleShape)Clip Before Drawing
Place clip before background so the fill is also rounded. Order in the chain decides what gets clipped.
Modifier
.clip(RoundedCornerShape(12.dp))
.background(Color.Cyan)Combine for a Card
Stack clip, background, and border together to craft a polished card surface in just a few lines.
Modifier
.clip(RoundedCornerShape(16.dp))
.background(Color.White)
.border(1.dp, Color.LightGray)Quick Check
You want a rounded background where the fill itself is also rounded. Which modifier ensures that?
Recap
You can now style any element: background paints it, border outlines it, and clip with a Shape rounds it. 🎉
Frequently asked questions
Is the “Background, Border & Clip” lesson free?
Yes — the full text of “Background, Border & Clip” 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 “Background, Border & Clip”?
Add color, outlines, and rounded shapes. 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 “Background, Border & Clip” 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
- Padding, Size & fillMaxWidth
- Background, Border & Clip
- Why Modifier Order Matters
- weight & Flexible Sizing