tailwind-rails
БесплатноБез исполняемых скриптовНе проверенTailwind CSS component patterns for Ruby on Rails ERB views. Use when building UI components in Rails, creating shared partials, implementing dark mode…
от djc00p1 161 установка в других каталогахОб этом скилле
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
- Use the
cn()helper for all conditional class logic — it deduplicates and removes blanks. - Pair light and dark classes always —
bg-white dark:bg-gray-950,text-gray-900 dark:text-gray-100. - Mobile-first responsive design — use
sm:,md:,lg:prefixes for breakpoints. - Extract repeated patterns into partials —
_badge.html.erb,_button.html.erb,_card.html.erb. - Use semantic color names — yellow for warnings, green for success, red for errors.
- Ensure sufficient contrast in both light and dark modes.
- 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-400onbg-gray-50is usually around 2.8:1. Disabled controls
Установить tailwind-rails в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл tailwind-rails?
Tailwind CSS component patterns for Ruby on Rails ERB views. Use when building UI components in Rails, creating shared partials, implementing dark mode, writing badge/button/card/table components, setting up a consistent design system, or checking Tailwind markup for contrast and accessibility problems. Trigger phrases: tailwind rails, rails UI components, ERB tailwind, rails dark mode, tailwind badge, tailwind button rails, shared partials tailwind, tailwind hidden class, tailwind contrast.
Как установить скилл tailwind-rails?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл tailwind-rails запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic