styles

Migrate Jetpack Compose UIs to themeable Styles with StyleState.

174|8|Updated Jan 9, 2024
One-click install
npx skills add https://github.com/klxiaoniu/QQVersionList --skill styles-klxiaoniu
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: styles
Source: https://github.com/klxiaoniu/QQVersionList/tree/main/.agents/skills/styles
Command: npx skills add https://github.com/klxiaoniu/QQVersionList --skill styles-klxiaoniu

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Styles help you centralize and theme visual properties in Jetpack Compose, replacing scattered, hard-coded styling with a consistent, theme-driven approach that supports state-based visuals.

Core Features & Use Cases

  • Jetpack Compose Styles API setup: Upgrade dependencies and opt into the required experimental Compose Style APIs to enable the Style pipeline.
  • Themeable component styling: Define reusable component styles (ComponentStyles) and wire them into your custom theme so multiple components share a unified look.
  • Migration workflow from Modifiers/parameters: Replace hard-coded styling parameters with a Style parameter and apply styleable modifiers for components that don’t expose Style parameters.
  • State and interaction styling: Use StyleState-driven state blocks (pressed/hovered/focused/enabled/toggled and custom states) to animate and switch visual properties.

Quick Start

Update your project to the required Compose Foundation Style API versions and experimental opt-in, then create ComponentStyles.kt to define your component Style objects and migrate one custom component at a time by adding style: Style = Style and applying Modifier.styleable with a StyleState linked to your interaction source.

Frequently Asked Questions about styles

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate Jetpack Compose UI to use Styles instead of hard-coded modifiers?

To migrate Jetpack Compose UI to Styles, replace hard-coded styling parameters with a Style parameter and apply Modifier.styleable. Define ComponentStyles objects to centralize visual properties and wire them into your custom theme for a unified look.

What are ComponentStyles in Jetpack Compose and when do I need them?

ComponentStyles in Jetpack Compose are reusable objects that centralize and theme visual properties for UI components. You need them when upgrading custom design systems to resolve inconsistent theming and reduce high boilerplate from scattered, hard-coded styling.

How do I implement state-based visuals using StyleState in Jetpack Compose?

Implement state-based visuals by using StyleState-driven state blocks to animate and switch visual properties. Link StyleState to your interaction source to handle pressed, hovered, focused, enabled, toggled, and custom states within your component styling.

Do I need to enable experimental Compose Foundation APIs to use Styles?

Yes, you must opt into the required experimental Compose Foundation Styles APIs to enable the Style pipeline. Update your project to the required Compose Foundation Style API versions and apply the experimental opt-in before defining ComponentStyles.

How do I apply Styles to Compose components that don't expose Style parameters?

Apply Styles to Compose components lacking Style parameters by using styleable modifiers. Pass the style object and apply Modifier.styleable with a StyleState linked to your interaction source to achieve themeable component styling.

Best way to centralize theming and reduce boilerplate in a Jetpack Compose design system?

The best way to centralize theming is migrating from modifier-only approaches to themeable Styles. Define reusable ComponentStyles and wire them into your custom theme so multiple components share a unified, theme-driven look while reducing boilerplate.