styling

Apply Tailwind/CSS styling guidelines to UI components with minimal wrappers.

4.7k|374|Updated Mar 16, 2023
One-click install
npx skills add https://github.com/EpicenterHQ/epicenter --skill styling-epicenterhq
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: styling
Source: https://github.com/EpicenterHQ/epicenter/tree/main/.agents/skills/styling
Command: npx skills add https://github.com/EpicenterHQ/epicenter --skill styling-epicenterhq

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Inconsistent styling and bloated DOM arise when building UI components, making maintenance costly and error-prone. This guide provides concise rules to apply styles with minimal wrappers, consistent utility usage, and themed design.

Core Features & Use Cases

  • Minimize wrapper elements by applying classes to the target element when semantically appropriate.
  • Tailwind best practices:
    • Use cn() utility from $lib/utils to compose classes conditionally
    • Prefer utility classes over custom CSS
    • Use tailwind-variants for component variants
    • Follow the background/foreground convention for colors
    • Leverage CSS variables for theme consistency
  • Use Case: When building a reusable button component, apply styling directly to the button element and use utility classes to adjust variants.

Quick Start

Apply these guidelines when styling components to ensure accessible, responsive, and consistent UI.

Frequently Asked Questions about styling

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

FAQPage Schema
How do I maintain consistent UI styling across multiple components?

Maintain UI consistency by applying styling guidelines across components to enforce utility-first practices, minimize wrapper elements, and promote theme-driven design. This approach reduces bloated DOM and ensures consistent interfaces during development.

What's the best way to conditionally apply Tailwind classes to UI components?

The best way to conditionally apply Tailwind classes is using the cn() utility from $lib/utils to compose classes. This minimizes wrapper elements by allowing direct conditional class composition on target elements instead of adding extra DOM nodes.

How do I manage component variants without writing custom CSS?

Manage component variants without custom CSS by using tailwind-variants to define styles. Prefer Tailwind utility classes over custom CSS and follow the background/foreground color convention to ensure accessibility and theme consistency.

Why does my UI design system have bloated DOM and inconsistent styling?

Bloated DOM and inconsistent styling arise when building UI components with excessive wrapper elements and ad-hoc CSS. Applying concise utility-first styling rules directly to target elements minimizes wrappers and ensures themed design consistency.

Can I use CSS variables for theme consistency in Tailwind?

Yes, you can leverage CSS variables for theme consistency in Tailwind. Combine CSS variables with the background/foreground color convention and tailwind-variants to ensure accessible, responsive, and consistent UI across your component library.

When should I not use wrapper elements for styling UI components?

Avoid wrapper elements for styling when you can apply classes directly to the target element semantically. Minimizing wrapper elements reduces DOM bloat and maintenance costs, applying utility-first practices directly to elements like reusable button components.