--- name: pf-component-check description: Audit PatternFly React component nesting, wrapper hierarchies, and layout structure. Use when scanning for hierarchy violations or debugging spacing caused by missing wrapper components. --- Use this skill when you need a **structural audit** of PatternFly usage, or when fixing layouts caused by skipped wrappers. For day-to-day composition rules while writing UI, use the **pf-component-structure-audit** agent (react plugin) or your client’s equivalent subagent for PatternFly structure. ## PatternFly MCP If `@patternfly/patternfly-mcp` is available, use it for current props, examples, and new components. This skill and the reference files define **nesting and wrapper rules**; the MCP fills in API details. ## Why structure matters Layout CSS targets specific parent-child trees. Skipping wrappers (`ToolbarContent`, `CardBody`, `PageSection`, etc.) breaks spacing and alignment; custom CSS is usually papering over a wrong tree. **Use every structural wrapper PatternFly provides for that region.** ## Where the hierarchies live Reference files hold trees, props notes, examples, and anti-patterns — not duplicated here: | Area | File | |------|------| | Page, PageSection, PageGroup, PageSidebar, Masthead | `references/page-layout.md` | | Card, Modal, Drawer, EmptyState, Sidebar | `references/containers.md` | | Table, DataList, DescriptionList | `references/data-components.md` | | Nav, Tabs, Toolbar | `references/navigation-toolbar.md` | Read the relevant file before suggesting structure for that family. ## Auditing component structure ### How to run 1. Ask the user which directory or files to audit. Default to the current working directory. 2. Search for files importing from `@patternfly/react-core` or `@patternfly/react-table`. 3. For each file, check for the violations below. 4. Report findings grouped by file, with line numbers and the specific violation. 5. If the user requests fixes, apply them. Only fix unambiguous structural issues — if a fix would change behavior or needs a design decision, report it and ask. ### Violations to detect Use the same structural rules as the **pf-component-structure-audit** agent; during a scan, flag the issues below. **Anti-pattern examples** live in the reference files for each family. | Area | Flag | |------|------| | Page layout | Direct `` children that aren’t `` / ``; `` without ``; `` without `` (info) | | Masthead | `` / `` not under ``; `` outside `` | | Toolbar | `` children aren’t ``; controls in `` / `` without `` | | Card | Raw content in `` outside `` / `` / ``; expandable card missing `` | | Modal | Missing `` / `` / ``; missing `aria-labelledby` or `aria-label` | | Drawer | `` as child of `` instead of `panelContent`; `` without ``; `` not under `` in `` | | Navigation | `` not under ``; extra `` inside `` | | Table | `` direct under ``; `` / ``. **Needs user input:** New `aria-label` / `aria-labelledby` text; choosing `titleText` vs ``; unclear nested intent. ### Custom CSS **During an audit:** If spacing or padding overrides sit next to a structural issue, add an info line, e.g.: ``` [INFO] file/path.tsx:42 - Custom CSS spacing override near structural violation .my-toolbar-fix { padding: 8px } may compensate for missing ``` **Before suggesting new overrides:** Map the symptom to a missing wrapper when possible — page content → `PageSection` / `PageBody`; toolbar → `ToolbarContent` / `ToolbarItem`; card → `CardBody`; nav → `NavList`; description list → `DescriptionListGroup`; drawer panel → `panelContent` prop (see reference files for full trees).
` in body rows or `` in header rows; `` without `dataLabel` (**WARN**) | | DataList | Missing `aria-label` on ``; item without ``; row without ``; `` inside `` (should be sibling) | | Tabs | Tab label as children instead of `title`; `` without `eventKey` | | EmptyState | `` directly under ``; mixing `titleText`/`icon` with explicit `` | | DescriptionList | Terms/descriptions directly under `` without `` | ### Report format For each violation: ``` [ERROR|WARN] file/path.tsx:42 - has direct children that are not Found: