Android Design System
ASecurityKeep palette values in `Color.kt`, map semantic roles separately for light and dark schemes, and choose the scheme once in `Theme.kt`. Composables should only read `MaterialTheme.colorScheme`. ```kotlin // ui/theme/Color.kt private val BrandLight = Color(0xFF6750A4) private val BrandDark = Color(0xFFD0BCFF) private val OnBrandLight = Color(0xFFFFFFFF) private val OnBrandDark = Color(0xFF381E72) val LightColors = lightColorScheme( primary = BrandLight, onPrimary = OnBrandLight, ) val DarkColor...
- 584 stars
- 0 votes
- 0 copies
- 4 views
- Added September 5, 2026
Works with
Security analysis
100/100Pro scans all 18 files and shows the line behind each finding
npx -y skills add HoangNguyen0403/agent-skills-standard --skill android-design-system --agent claude-codeAre you the author of Android Design System?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/hoangnguyen0403-android-design-system-b904996f)# Supporting dark mode with one theme API
Keep palette values in `Color.kt`, map semantic roles separately for light and dark schemes, and choose the scheme once in `Theme.kt`. Composables should only read `MaterialTheme.colorScheme`.
```kotlin
// ui/theme/Color.kt
private val BrandLight = Color(0xFF6750A4)
private val BrandDark = Color(0xFFD0BCFF)
private val OnBrandLight = Color(0xFFFFFFFF)
private val OnBrandDark = Color(0xFF381E72)
val LightColors = lightColorScheme(
primary = BrandLight,
onPrimary = OnBrandLight,
)
val DarkColors = darkColorScheme(
primary = BrandDark,
onPrimary = OnBrandDark,
)
```
The palette constants are defined once; only the semantic role mapping differs where contrast requires a different tone. Add all app-specific colors to both scheme definitions instead of scattering light/dark checks through screens.
```kotlin
// ui/theme/Theme.kt
@Composable
fun AppTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
content: @Composable () -> Unit,
) {
val colors = if (darkTheme) DarkColors else LightColors
MaterialTheme(
colorScheme = colors,
typography = AppTypography,
content = content,
)
}
```
Now every screen automatically follows the selected scheme:
```kotlin
@Composable
fun SurfaceContent() {
Surface(color = MaterialTheme.colorScheme.background) {
Text(
text = "Content",
color = MaterialTheme.colorScheme.onBackground,
style = MaterialTheme.typography.bodyLarge,
)
}
}
```
`isSystemInDarkTheme()` responds to the system setting, while a caller can pass `darkTheme` explicitly for an in-app preference or preview. The UI remains unchanged because it consumes semantic tokens rather than duplicating color definitions or branching on dark mode.
Files in this skill
- eval-1.baseline.md
- eval-1.with-skill.md
- eval-2.baseline.md
- eval-2.with-skill.md
- eval-3.baseline.md
- eval-3.with-skill.md
- trigger-1.md
- trigger-10.md
- trigger-11.md
- trigger-2.md
- trigger-3.md
- trigger-4.md
- trigger-5.md
- trigger-6.md
- trigger-7.md
- trigger-8.md
- trigger-9.md
Attribution
Related skills
View all in development →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.