home / skills / hoangnguyen0403 / agent-skills-standard / android-design-system
This skill enforces Material Design 3 tokens in Jetpack Compose apps using MaterialTheme for consistent theming and typography.
npx playbooks add skill hoangnguyen0403/agent-skills-standard --skill android-design-systemReview the files below or copy the command above to add this skill to your agents.
---
name: Android Design System (Jetpack Compose)
description: Enforce Material Design 3 and design token usage in Jetpack Compose apps.
metadata:
labels: [android, compose, dls, material-design, design-tokens]
triggers:
files: ['**/*Screen.kt', '**/ui/theme/**', '**/compose/**']
keywords: [MaterialTheme, Color, Typography, Modifier, Composable]
---
# Android Design System (Jetpack Compose)
## **Priority: P2 (OPTIONAL)**
Enforce Material Design 3 tokens in Jetpack Compose. Use `MaterialTheme` for consistency.
## Token Structure
```kotlin
// ui/theme/Color.kt
val Primary = Color(0xFF2196F3)
val Secondary = Color(0xFF9C27B0)
val Background = Color(0xFFFFFFFF)
// ui/theme/Theme.kt
private val LightColorScheme = lightColorScheme(
primary = Primary,
secondary = Secondary,
background = Background
)
// ui/theme/Type.kt
val Typography = Typography(
headlineLarge = TextStyle(fontSize = 32.sp, fontWeight = FontWeight.Bold),
bodyMedium = TextStyle(fontSize = 16.sp, fontWeight = FontWeight.Normal)
)
```
## Usage
```kotlin
// ❌ FORBIDDEN
Box(modifier = Modifier.background(Color(0xFF2196F3)))
Text("Title", fontSize = 32.sp, color = Color.Black)
// ✅ ENFORCED
Box(modifier = Modifier.background(MaterialTheme.colorScheme.primary))
Text("Title", style = MaterialTheme.typography.headlineLarge)
Spacer(modifier = Modifier.height(16.dp)) // Use dp units
```
## Anti-Patterns
- **No Hardcoded Colors**: Use `Color(0xFF...)` → Error. Use `MaterialTheme.colorScheme.*`.
- **No Inline Typography**: Define `fontSize = 32.sp` → Error. Use `MaterialTheme.typography.*`.
- **No Magic Spacing**: Use `padding = 16.dp` inline → Acceptable, but consider tokens.
## Related Topics
mobile-ux-core | android/compose
This skill enforces Material Design 3 and design token usage in Jetpack Compose applications. It guides developers to centralize colors, typography, and spacing into a theme using MaterialTheme and design tokens. The goal is consistent UI, easier theming, and fewer visual regressions across the app.
The skill inspects Compose code to detect hardcoded Color, inline TextStyle, and ad-hoc spacing values. It flags violations and recommends replacing literals with MaterialTheme.colorScheme, MaterialTheme.typography, and tokenized dp values. It also provides concrete examples showing forbidden patterns and the enforced alternatives.
What happens if I need a one-off color?
Prefer adding a token to the theme; reserve true one-offs for rare cases and document them. Adding tokens keeps the system predictable and easier to maintain.
Are magic dp values forbidden?
Magic dp values are allowed but discouraged for repeated values. Prefer spacing tokens for consistency; occasional inline dp for unique layouts is acceptable.