/c2n:c2n-componentsfrom c2n
Build and theme applications using @c2n/* web components (c2-button, c2-text-field, c2-table, etc.) instead of native HTML elements. Detects project setup, theme tokens, and variants, then uses MCP tools to fetch component specs and examples.
Ships in c2n. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Build screens from @c2n/* web components with the least code: theme once, use the tags directly, name what repeats. In a c2n project, a matching c2-* element is the default for controls and interactive widgets: reach for c2-button, c2-text-field, c2-select or c2-modal rather than <button>, <input>, <select> or <dialog>, and c2-table for a data grid (sorting, selection, many rows) rather than a hand-rolled one. Search the components before concluding one is missing; keep native HTML or an app component when no equivalent fits, such as a short static table. Facts about components come from the c2n MCP tools or the component manifests, never from memory. The references in references/ hold the details; read only the one the current step points to.
This workflow expects a JavaScript project and Node.js 20 or newer. The c2n MCP server is recommended; the skill retains a compact discovery index and can inspect installed package manifests when MCP is unavailable.
Inspect the project's package.json with the available filesystem or shell tools. Identify installed @c2n/* packages and the framework before changing dependencies or source files.
Then look for what already exists before adding anything:
--c2-theme-- in the CSS, or an import of @c2n/components/theme.css (or base.css, or @c2n/theme directly);src/components/ui/, src/ui/, files that extends … from '@c2n/, or classes setting --c2-… variables;data-theme, a class, prefers-color-scheme).Reuse an existing variant or token bridge over creating a new one.
When c2n MCP tools are available:
list_components or search_components to pick the component for the need.get_component for attributes, slots, events, documented CSS parts and CSS variables (grouped by semantic target and state, with the theme token each follows).get_examples for real markup. Start with the default example, then pick a look from the docs gallery (§2a). Preserve any accessibility note returned with an example.get_presets when a curated visual treatment is useful. A preset is structured CSS-variable and attribute data suitable for generation; a gallery example is broader usage and composition context.get_theme before writing any CSS, so overrides go on tokens when a token exists.validate_markup on what you wrote, before finishing (§7).generate_variant when a selected preset or gallery look repeats: it validates names and emits the class / HTML / Lit code.get_workflow_guide for the workflow, theming, variant or framework guide text.Each component has a gallery of designed looks on the docs site. Start from one instead of inventing CSS:
get_examples with view: "index" lists every card of a component on one page: label, slug, a summary of what it changes and a screenshot link (light; swap .light.png for .dark.png). Open the screenshots when you can read images.search_examples finds a look across all components by style or situation ("compact", "glass", "pill", "underline", "KPI").get_examples label: "<slug>". Its CSS already uses var(--c2-theme--…, literal) wherever a colour belongs to the theme; a literal left over is the card's own accent, so replace it with the application's token (usually --c2-theme--color-primary…) rather than pasting it.generate_variant with example: "<slug>" turns the card into a class or Lit subclass under the app's prefix.Without the server, use references/component-catalog.md only to identify a likely package. Then read node_modules/@c2n/components/custom-elements.json for the installed version's attributes, slots, events, CSS parts and CSS properties. If the package is not installed, use https://code2nguyen.github.io/web-components/. Never infer an API from the catalog or invent a variable, attribute, slot or event name.
Read references/theming.md.
npm install @c2n/components: it is the one published component package and includes the theme. Import each component you use through its entry — @c2n/components/<name> (@c2n/components/table, @c2n/components/chart for every chart element) — and the theme with @c2n/components/theme.css. Prefer the per-component entries to the @c2n/components barrel, which registers everything; @c2n/components/react and /vue type every tag. Not included: icon sets and the optional chart/code-editor engines (uplot, echarts, CodeMirror) — install those separately. The MCP server prints the matching import lines.@c2n/components/theme.css once at the application root (main.ts, root layout, global stylesheet). If the app already has design tokens, import @c2n/components/base.css alone and bridge the app's tokens onto the --c2-theme--* names on :root.:root (light) and under the app's dark selector. Component variables are never set globally when a token covers the job.import '@c2n/components/button') at the entry or in the module that renders them; icons individually (import '@c2n/feather-icons/icons/search.js').Read references/variant-components.md when creating one.
| Situation | Do |
|---|---|
| Appears once, themed default is right | plain <c2-…> tag |
| Same look repeats, markup otherwise plain | CSS class setting --c2-<component>__… variables (in the app's variants stylesheet) |
| Same attributes / slots / accessible name repeat too | wrapper component in the app's framework rendering the c2 element |
| Must be its own tag (strings, other Lit templates, shipping) | Lit subclass: class X extends Button { static override styles = [Button.styles, css\:host{…}`] }, defined as app-*` |
| Several c2 components + logic repeat | composed component: children's variables on :host/a class, attributes forwarded, events re-emitted |
| No c2 component fits (kbd hint, count pill, …) | app component styled with --c2-theme--* tokens; avoid patching installed @c2n/* packages for app-local behavior |
Naming: the app's prefix (app-*, site-*, my-*), kebab-case with a hyphen, never c2-*. One file per variant in one directory, exported from a barrel, with a short header comment (what it wraps, which variables it fixes, where it is used).
::part() only when get_component documents that native CSS part and variables cannot express the change. Do not repeat inline style="--c2-…".::part() only for the component-owned wrapper, fallback, or state region. Put part selectors in global CSS under Vue scoped styles or Angular Emulated encapsulation, and never assume a part crosses a nested component's shadow root.--c2-<component>__<part>[__<state>]--<property>; states hover | active | focus | selected | disabled | open | error | read-only.disabled, running, selected), and disabled="false" reads as false rather than true, so a value bound by a framework behaves; slots by name (prefix-icon, suffix-icon, header, footer, description…).rows, columns, items, options, series, steps) take the value itself, or a JSON string in the attribute and on the property — JSON.stringify(rows) is one binding that survives server rendering.readOnly is readonly, rowKey is row-key. Manifests give the real attribute as name and the property as fieldName.--c2-text-field--border-top: none on the wrapper class) and re-emit events (redispatchEvent from @c2n/core/dom-helper.js in Lit).c2-x:not(:defined) { visibility: hidden }.Read references/frameworks.md for details.
<script type="module"> or the entry module.redispatchEvent for child events.@astrojs/lit islands (<Button client:load>, kebab-case attributes only; a client:only island must not contain islands) or plain tags plus a client <script> for repeated markup; variant styles need is:global.ref.addEventListener; older React needs string attributes and refs. Server-rendered (Next.js): kebab-case attribute names (min-width, not minWidth) and objects through a ref.compilerOptions.isCustomElement = (tag) => tag.startsWith('c2-'); .prop for arrays/objects.validate_markup on every file you wrote, passing its filename so CSS and JSX/Vue/Angular syntax are read as such (or npx -y @c2n/mcp validate src without MCP), and fix what it reports: native controls with a c2-* replacement; unknown c2-* tags and unknown attributes, slots, events and --c2-* variables of c2 elements; box styling on a c2-* host. It does not check other tags. A deliberate native element gets a c2n-ignore comment.HTMLUnknownElement); the theme (@c2n/components/theme.css or base.css) imported exactly once.get_component / the manifest.::part() name exists in get_component; no repeated inline variable styles; repeated looks became variants.c2-.List the packages added, where the theme is imported and which tokens are set, each variant created (name → base tag, file), composed components, and the gaps left as plain app components.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
web-components, ui-components, design-system, component-library, theming
Other plugins' skills for the same job
npx claudepluginhub code2nguyen/web-components --plugin c2n