一键导入
add-component
Add a new UI component to the Layx framework following established CSS/JS patterns
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Add a new UI component to the Layx framework following established CSS/JS patterns
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Add a new optional JavaScript module to layx/others/ (e.g., scroll effects, trackers, utilities)
Add a new utility class group to the Layx framework (layx/utilities/) following established CSS layer patterns
Master reference skill for the Layx CSS-first framework — architecture, file structure, conventions, CSS patterns, JS patterns, CLI, and build system
| name | add_component |
| description | Add a new UI component to the Layx framework following established CSS/JS patterns |
This skill guides you through the process of creating a new UI component in the Layx CSS-first framework.
Components live in layx/components/<name>/ and consist of:
@layer components { ... }layx/layx.css (and layx/layx.js if JS exists)layx/components/<component-name>/
├── <component-name>.css (required)
└── <component-name>.js (optional, for interactivity)
Example for a badge component:
layx/components/badge/
├── badge.css
└── (no JS needed — purely CSS)
Always wrap all styles in @layer components { ... }. Use CSS custom properties for theming. Support light-dark() for automatic dark mode.
Template:
@layer components {
<component-name>, .<component-name> {
/* CSS custom properties (local variables) */
--<component-name>-bg: light-dark(#f0f0f0, #2a2a2a);
--<component-name>-color: light-dark(#111, #eee);
--<component-name>-radius: var(--radius, .5rem);
--<component-name>-padding: var(--space, .5rem);
/* Base styles */
display: block;
background: var(--<component-name>-bg);
color: var(--<component-name>-color);
border-radius: var(--<component-name>-radius);
padding: var(--<component-name>-padding);
transition: var(--duration, .6s);
/* Variants */
&.primary {
--<component-name>-bg: var(--accent-color);
}
}
}
Key Conventions:
var(--base-space) / var(--space) for spacingvar(--base-radius) / var(--radius) for border radiusvar(--base-duration) / var(--duration) for transitionslight-dark(lightVal, darkVal) for color-scheme-aware colors& for variants and states@media (width >= 576px) (sm), @media (width >= 768px) (md), @media (width >= 992px) (lg)Use ES modules only. Keep JS minimal — CSS-first approach. The JS file should handle only behavior that CSS cannot handle alone (e.g., toggle state, events).
Template:
// <ComponentName> - handles interactive behavior
const componentName = document.querySelectorAll('<component-name>, .<component-name>');
componentName.forEach(el => {
// Initialize component
el.addEventListener('click', (e) => {
// Handle interaction
el.toggleAttribute('open');
});
});
Key Conventions:
document.querySelectorAll() to target both custom element and class selectortoggleAttribute('open') for open/close states (see navbar, dialog, sheet)data-* attributes for configurationOpen layx/layx.css and add the import under /* Components */:
/* Components */
@import url(components/<component-name>/<component-name>.css);
Open layx/layx.js and add the import:
import './components/<component-name>/<component-name>.js';
layx/components/button/button.css — no JS needed
layx/components/navbar/navbar.css — styles
layx/components/navbar/navbar.js — toggler, scroll state
[open] attribute to signal open state[open] & or &[open] selectors to show/hide contentel.toggleAttribute('open')badge Componentlayx/components/badge/badge.css:@layer components {
badge, .badge {
--badge-bg: light-dark(#e0e0e0, #333);
--badge-color: inherit;
--badge-radius: 999px;
--badge-padding-x: calc(var(--space, .5rem) * 1.2);
--badge-padding-y: calc(var(--space, .5rem) * .4);
--badge-font-size: .75em;
display: inline-flex;
align-items: center;
background: var(--badge-bg);
color: var(--badge-color);
border-radius: var(--badge-radius);
padding: var(--badge-padding-y) var(--badge-padding-x);
font-size: var(--badge-font-size);
font-weight: 600;
line-height: 1;
&.primary { --badge-bg: var(--accent-color); }
&.success { --badge-bg: light-dark(#d4edda, #1c4a27); }
&.warning { --badge-bg: light-dark(#fff3cd, #4a3800); }
&.danger { --badge-bg: light-dark(#f8d7da, #4a0010); }
}
}
layx/layx.css:/* Components */
@import url(components/badge/badge.css);
<badge>New</badge>
<span class="badge primary">Featured</span>
layx/components/<name>/@layer components { ... }var(--space), var(--radius), var(--duration) tokenslight-dark() for color-scheme-aware coloringlayx/layx.csslayx/layx.js (if JS exists)localhost:81