shadcn-layouts

shadcn 布局助手:通过应用 CSS 思维模型生成正确的 shadcn/Tailwind 布局。适用于用户请求创建 shadcn 布局、修复布局问题、调试 CSS 高度问题、实现滚动效果或处理 Tailwind 的 flex/grid 相关问题时。关键词:shadcn、Tailwind、布局、CSS、flex、grid、高度、滚动、溢出。

仓库最近推送
GitHub Stars
195
Forks
27
Issues / PRs
2

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "shadcn-layouts":https://skillpi.com/zh/skills/deepskill-8ce1c9b3760b9b04862257ea541086bc1ac480d9b07d01815f8db9fa2f039d97。安装前核对上游来源和版本:https://github.com/jwynia/agent-skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

shadcn 布局助手:通过应用 CSS 思维模型生成正确的 shadcn/Tailwind 布局。适用于用户请求创建 shadcn 布局、修复布局问题、调试 CSS 高度问题、实现滚动效果或处理 Tailwind 的 flex/grid 相关问题时。关键词:shadcn、Tailwind、布局、CSS、flex、grid、高度、滚动、溢出。

0 下载

介绍来源: third_party · jwynia · 1.0 参考来源

SkillPi 解读

能完成的任务
翻译待完成,请参阅来源文档。
适合谁
翻译待完成,请参阅来源文档。
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: shadcn-layouts
description: "Generate correct shadcn/Tailwind layouts by applying CSS mental models. This skill should be used when the user asks to 'create a shadcn layout', 'fix layout issues', 'debug CSS height problems', 'make scrolling work', or has issues with Tailwind flex/grid. Keywords: shadcn, Tailwind, layout, CSS, flex, grid, height, scroll, overflow."
license: MIT
compatibility: Works with shadcn/ui, Tailwind CSS v3/v4, React, Next.js.
metadata:
  author: jwynia
  version: "1.0"
  type: utility
  mode: generative
  domain: development

shadcn/Tailwind Layouts

Help generate shadcn/Tailwind components that render correctly the first time. Most agent-generated UI fails due to missing mental models about how CSS layout works—not syntax errors, but assumption gaps.

When to Use This Skill

Use this skill when:

  • Creating shadcn/Tailwind layouts
  • Debugging height/scroll issues
  • Fixing flex/grid problems
  • Setting up full-page app shells

Do NOT use this skill when:

  • Writing backend code
  • Working on non-Tailwind CSS projects
  • Designing (use frontend-design first)

Core Principle

CSS layout flows from constraints. Height flows down from explicit ancestors. Width flows up from content. Agents fail because they apply classes without understanding the constraint chain.

Critical Mental Models

Model 1: Height Inheritance Chain

h-full means height: 100%. 100% of what? 100% of the parent's computed height.

BROKEN (chain incomplete):
<html>                        <!-- no height -->
  <body>                      <!-- no height -->
    <div class="h-full">      <!-- 100% of nothing = 0 -->

WORKING (chain complete):
<html class="h-full">         <!-- 100% of viewport -->
  <body class="h-full">       <!-- 100% of html -->
    <div class="h-full">      <!-- 100% of body = works -->

Rule: Trace from element up to <html>. Every ancestor needs explicit height, OR use viewport units (h-screen) to break the chain.

Model 2: Flex Overflow Gotcha

Flex children have implicit min-height: auto, preventing shrinking below content size.

// BROKEN (won't scroll)
<div className="flex flex-col h-screen">
  <main className="flex-1 overflow-y-auto">  {/* Can't shrink! */}

// WORKING (scrolls correctly)
<div className="flex flex-col h-screen">
  <main className="flex-1 overflow-y-auto min-h-0">  {/* Can shrink */}

Rule: Flex children that scroll need min-h-0. Children that shouldn't shrink need shrink-0.

Model 3: Grid Parent/Child Separation

Grid is defined on the parent. Children just occupy cells.

// BROKEN
<div className="grid-cols-3">           {/* Missing 'grid'! */}

// WORKING
<div className="grid grid-cols-3">      {/* 'grid' enables grid-cols-* */}

Rule: flex or grid must be declared on parent before direction/template classes work.

Model 4: Scroll Container Dimensions

Scroll containers need explicit dimensions to know when to scroll.

// BROKEN (never scrolls)
<ScrollArea>  {/* No height constraint */}

// WORKING (flex-constrained)
<div className="flex flex-col h-screen">
  <ScrollArea className="flex-1 min-h-0">

Diagnostic States

SL1: Height Chain Broken

Symptoms: Elements collapse, h-full not working Fix: Trace to html, add heights or use h-screen

SL2: Flex Overflow Blocked

Symptoms: Scroll doesn't work, content overflows Fix: Add min-h-0 to flex children that scroll

SL3: Grid Structure Wrong

Symptoms: Items stack vertically instead of columns Fix: Ensure grid grid-cols-* on parent

SL4: Styles Not Applying

Symptoms: Unstyled components, colors wrong Fix: Check Tailwind content paths, CSS variables in globals.css

SL5: Component Dependencies Missing

Symptoms: "Module not found", functionality broken Fix: npx shadcn add [component], install peer deps

Common Layout Patterns

Full-Page App Shell

// layout.tsx
<html lang="en" className="h-full">
  <body className="h-full">{children}</body>
</html>

// page.tsx
<div className="flex h-full">
  <aside className="w-64 shrink-0 border-r overflow-y-auto">
    <nav>...</nav>
  </aside>
  <main className="flex-1 min-w-0 overflow-y-auto">
    {children}
  </main>
</div>

Dashboard with Header

<div className="flex flex-col h-screen">
  <header className="h-16 shrink-0 border-b">...</header>
  <div className="flex flex-1 min-h-0">
    <aside className="w-64 shrink-0 border-r overflow-y-auto">...</aside>
    <main className="flex-1 min-w-0 overflow-y-auto p-6">
      {children}
    </main>
  </div>
</div>

Card Grid

<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
  {items.map(item => (
    <Card key={item.id}>
      <CardHeader><CardTitle>{item.title}</CardTitle></CardHeader>
      <CardContent>{item.content}</CardContent>
    </Card>
  ))}
</div>

Anti-Patterns

The Height Assumption

Using h-full without verifying ancestor chain. Fix: Trace to html. Use h-screen to break chain.

The Overflow Ignorance

Adding overflow-y-auto without min-h-0 on flex children. Fix: Flex children need min-h-0 to shrink.

The Import Guess

Guessing import paths like shadcn/ui. Fix: Check components.json for alias. Usually @/components/ui/*.

The Flat Compound

Flattening compound components (Dialog without DialogTrigger/DialogContent). Fix: Maintain required nesting structure.

Pre-Generation Checklist

  • [ ] Import alias known (@/components/ui/*)
  • [ ] html has h-full
  • [ ] body has h-full or min-h-full
  • [ ] Scroll containers have explicit height
  • [ ] Flex scroll children have min-h-0
  • [ ] Fixed elements have shrink-0

Related Skills

  • frontend-design - Design decisions before implementation
  • react-pwa - PWA features for React apps

当前收录版本

1.0

核对来源版本 ↗

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值92/100

亮点

  • 针对 shadcn/Tailwind 布局开发中的高频痛点提供系统性解决方案
  • 涵盖高度继承、Flex 溢出、Grid 结构等核心 CSS 思维模型
  • 适用于大量 React/Next.js 开发者,具有明确的高频刚需价值
触发精准95/100

亮点

  • 触发词覆盖全面且边界清晰(shadcn、Tailwind、布局、CSS、flex、grid、高度、滚动、溢出)
  • 能精准匹配用户创建布局、修复问题、调试 CSS 等相关需求
结构规范95/100

待提升项

  • description 内容重复 原报告严重程度:轻微

    顶层 frontmatter 和 skill_body 内部均包含 description 字段,存在冗余

    改进建议:建议移除 skill_body 内部的 description 字段,保持唯一性

  • When to Use 章节标题层级不统一 原报告严重程度:轻微

    When to Use 内容存在但标题层级与其他章节不一致

    改进建议:统一使用二级标题 '## When to Use This Skill' 格式

  • 文档长度优化 原报告严重程度:轻微

    文档内容较丰富,建议考虑适当拆分或添加目录导航

    改进建议:可考虑添加目录或拆分为多个子章节提升可读性

亮点

  • 文档结构完整,包含核心原则、诊断状态、常见模式、反模式等清晰章节
  • 提供具体代码示例和预生成检查清单,便于执行
  • frontmatter 元数据完整,包含兼容性、作者、版本等信息
执行可靠90/100

亮点

  • 代码示例参数正确,覆盖主要异常场景并提供明确修复方案
  • 工具来源明确(shadcn/ui、Tailwind CSS),兼容性说明清晰
  • 提供了完整的诊断状态和修复规则,降低执行失败风险
证据可验 (前四项均值)93/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

  • 安装或获取外部依赖

    使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。

    主文档提及 · 第 118 行

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。