SkillsCenter wizardSkillsCenter.dev
[SIGN_IN]
Coding

tailwind-rails

djc00p/tailwind-rails

★0

🤖Curated by @curator-ai

INSTALL

$npx skills add djc00p/tailwind-rails

Requires npx skills — the open source skill installer.

INSTALLED_BY

NO_PUBLIC_INSTALLS_YET.

COMPATIBLE_AGENTS

NO_INSTALLS_DETECTED_YET.

SKILL_DESCRIPTION

Tailwind CSS for Rails

Build consistent, dark-mode-ready component patterns in Rails ERB views using Tailwind utilities and reusable partials.

Quick Start

Add a class name helper to collapse conditional logic:

# app/helpers/application_helper.rb
def cn(*classes)
  classes.flatten.compact.join(' ').split.uniq.join(' ')
end

Use it in views to combine base and conditional classes:

<div class="<%= cn('px-4', active ? 'bg-blue-500' : 'bg-gray-200') %>">
  Content
</div>

Standard full-width container with responsive padding:

<div class="mx-auto max-w-7xl px-4 py-8 sm:px-6 lg:px-8">
  <!-- Page content -->
</div>

Badge Pattern

<span class="inline-flex items-center rounded-full bg-green-100 px-3 py-1 text-sm font-medium text-green-800 dark:bg-green-900 dark:text-green-100">
  Label
</span>

Colors: Yellow=warning, Blue=info, Green=success, Red=danger, Gray=neutral
Light: bg-{color}-100 + text-{color}-800 | Dark: dark:bg-{color}-900 + dark:text-{color}-100

Common Components

Card with border and shadow:

<div class="rounded-lg border border-gray-200 bg-white shadow-sm dark:border-gray-800 dark:bg-gray-950">
  <div class="px-6 py-4">
    <!-- content -->
  </div>
</div>

Table wrapper with responsive shadow:

<div class="overflow-hidden shadow ring-1 ring-black ring-opacity-5 md:rounded-lg">
  <table class="w-full divide-y divide-gray-200">
    <thead>...</thead>
    <tbody>...</tbody>
  </table>
</div>

Tab navigation with underline:

<nav class="flex space-x-8 border-b border-gray-300">
  <% tabs.each do |tab| %>
    <% active = current_tab == tab %>
    <%= link_to tab_path(tab),
        class: "py-2 px-1 border-b-2 font-medium text-sm #{active ? 'border-blue-500 text-blue-600' : 'border-transparent text-gray-600 hover:text-gray-700'}" do %>
      <%= tab.humanize %>
    <% end %>
  <% end %>
</nav>

Best Practices

  1. Use the cn() helper for all conditional class logic — it deduplicates and removes blanks.
  2. Pair light and dark classes always — bg-white dark:bg-gray-950, text-gray-900 dark:text-gray-100.
  3. Mobile-first responsive design — use sm:, md:, lg: prefixes for breakpoints.
  4. Extract repeated patterns into partials — _badge.html.erb, _button.html.erb, _card.html.erb.
  5. Use semantic color names — yellow for warnings, green for success, red for errors.
  6. Ensure sufficient contrast in both light and dark modes.
  7. Test accessibility with screen readers and keyboard navigation.

Accessibility

The Tailwind hidden class vs the HTML hidden attribute

These are different mechanisms and they interact in ways that surprise people.

| | Tailwind class | HTML attribute | |---|---|---| | Syntax | class="hidden" | <div hidden> | | Mechanism | display: none via CSS | display: none via the UA stylesheet | | Overridable by CSS? | Yes - any later display: rule wins | No - needs [hidden] { display: none !important } to beat | | Hidden from screen readers? | Yes | Yes | | Removed from tab order? | Yes | Yes |

The trap: the HTML hidden attribute has a lower specificity than almost any Tailwind utility. A Tailwind class like flex or block on the same element overrides it, and the element stays visible while the author believes it is hidden.

<%# BAD - the `flex` utility overrides the `hidden` attribute, element stays visible %>
<div hidden class="flex">
<%# GOOD - use the Tailwind class so the intent is explicit and wins by specificity %>
<div class="hidden">

Rule: pick one mechanism per element. If you use Tailwind for visibility (hidden, md:hidden, block), do not also add the hidden attribute.

Responsive visibility is CSS-only. hidden md:block hides at small widths and shows at md+. The element is never removed from the DOM, so assistive tech sees it at all widths - it is only visually hidden. For content that must be removed from the accessibility tree entirely (not just visually), remove the element from the DOM server-side.

Contrast is measured against the real background

A color pair that passes on white can fail on the actual container. Contrast is computed between the text color and the nearest painted background behind it - not against the page background.

<%# BAD - text-gray-400 on a gray-100 badge passes against white, fails on gray-100 %>
<span class="bg-gray-100 text-gray-400">
<%# GOOD - compute against the container that actually paints behind the text %>
<span class="bg-gray-100 text-gray-800">

WCAG AA thresholds:

| Text size | Minimum ratio | |---|---| | Normal (< 18px, or < 14px bold) | 4.5:1 | | Large (>= 18px, or >= 14px bold) | 3:1 | | UI components & focus indicators | 3:1 |

Common traps:

  • Disabled states. text-gray-400 on bg-gray-50 is usually around 2.8:1. Disabled controls are exempt from WCAG contrast requirements - but "disabled" must be conveyed by more than color alone.
  • Placeholder text. Placeholders are still text and need contrast. Browsers default them to low opacity.
  • Dark mode. Every text-* needs a dark:text-* counterpart, and the ratio must hold in both modes. A pair that passes in light mode can fail in dark.
  • Text over images/gradients. The background varies, so the ratio varies. Use a scrim or a solid backing behind the text.
  • Semantic color tokens. oklch() colors with high chroma saturate and fail more often than the equivalent hex. Chroma above roughly 0.04 on light backgrounds is a reliable failure.

Focus indicators must survive

Tailwind's preflight removes the browser's default outline. If you do not replace it, keyboard users lose focus entirely.

<%# BAD - outline removed, nothing replaces it %>
<a class="focus:outline-none">
<%# GOOD - always pair outline-none with a visible ring %>
<a class="focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2">

Use focus-visible rather than focus so mouse clicks do not show the ring, but keyboard navigation always does.

Never hide content from screen readers with display: none

hidden (the class or the attribute) removes content from the accessibility tree and from the tab order. If the content is still meaningful - for example a label that is visually superseded by an icon - use sr-only instead:

<%# GOOD - visible to screen readers, invisible on screen %>
<button class="p-2">
  <%= render "icon", name: "trash" %>
  <span class="sr-only">Delete item</span>
</button>

Icon-only buttons need an accessible name

<%# BAD - no accessible name %>
<button><svg ...></svg></button>

<%# GOOD %>
<button aria-label="Delete item">
  <svg aria-hidden="true" ...></svg>
</button>

Decorative SVGs need aria-hidden="true" so the screen reader does not announce raw path data.

References

  • references/components.md — Reusable badge, button, and card partials with usage examples.
  • references/dark-mode-responsive.md — Dark mode setup, responsive patterns, and animation utilities.

Last indexed: 6/16/2026

RELATED_SKILLS

langchain

langchain-ai

The agent engineering platform.

✦139,742
$npx skills add langchain-ai/langchain
chroma

chroma-core

Search infrastructure for AI

✦28,503
$npx skills add chroma-core/chroma
aiden

taracodlabs

Aiden — Autonomous AI agent that operates your computer with prompts: browser control, terminal execution, workflows, tools, recovery systems, and persistent memory. Built solo. AGPL-3.0.

✦405
$npx skills add taracodlabs/aiden
vexjoy-agent

notque

VexJoy AI Agent with Intelligent Routing - /do routes plain-English requests to the right specialist agent and gates the work with reviews, tests, and a learning loop.

✦395
$npx skills add notque/vexjoy-agent
late-cli

mlhher

Orchestrate an entire AI dev team on 5GB VRAM. Ephemeral subagents, exact-match diffs. Single static binary, any model. Zero config, zero context bloat.

✦352
$npx skills add mlhher/late-cli

COMMENTS(0)

NO_COMMENTS_YET. BE_THE_FIRST.

SIGN_IN_TO_LEAVE_A_COMMENT

[SIGN_IN]