Authoring Components
You MUST review the component creation guideline before creating or modifying components.
When to Use This Skill
- Creating a new component from scratch
- Understanding the required file structure for components
- Setting up test boilerplate for all 5 test types
- Choosing the appropriate base class or mixin (ButtonFormControlMixin vs LitElement)
- Understanding component metadata and registration patterns
- Setting up JSDoc comments for components
Must Read File
Read the component creation guide to get critical context for component creation guidance.
Workflow
- Gather requirements: confirm the component name (kebab-case), purpose, and whether to use
LitElementdirectly or applyButtonFormControlMixinfor button-like interactive components. - Study a reference: read the closest reference component listed below to understand the pattern in practice.
- Create the 10 required files in
projects/core/src/<component-name>/:component-name.ts:component class with metadata, JSDoc, and render methodcomponent-name.css:styles using CSS custom propertiescomponent-name.examples.ts:example templates with@summaryJSDoccomponent-name.test.ts:unit testscomponent-name.test.axe.ts:accessibility testscomponent-name.test.visual.ts:visual regression testscomponent-name.test.ssr.ts:SSR testscomponent-name.test.lighthouse.ts:lighthouse testsdefine.ts:registration usingdefine()helper withHTMLElementTagNameMapindex.ts:side-effect-free export
- Update shared entry points:
- Add only
import '@nvidia-elements/core/<component-name>/define.js'toprojects/core/src/bundle.tsin alphabetical order. Keep this registration bundle import-only. Export the public API from the componentindex.tsand expose its entry point through the packageexportsmap. - Add the definition import to the
js-moduleslist inprojects/core/src/index.test.lighthouse.tsso the combined direct-import benchmark measures the component.
- Add only
- Measure payloads: run
mise exec -- pnpm run test:lighthousefromprojects/core. Increase a bundle-size limit only when the measured payload exceeds the current limit. - Verify: confirm all files follow the templates in the component creation guide, then run
mise exec -- pnpm run lintandmise exec -- pnpm run testfromprojects/core.
References
- Component Creation Guide - Complete component creation workflow
- TypeScript Guidelines - Type safety patterns
- Examples Guidelines - Example file structure
- Testing Guidelines - Testing strategy
- API Design - Properties - Property design patterns
- API Design - Styles - CSS custom properties
Reference Components
/projects/core/src/button/- ButtonFormControlMixin pattern example/projects/core/src/badge/- LitElement pattern example/projects/core/src/card/- Composition with slots example