--- title: Use PascalCase for Component Names impact: LOW impactDescription: Improves code clarity and IDE support, but both cases work type: best-practice tags: [vue3, component-registration, naming-conventions, pascalcase, ide-support] --- # Use PascalCase for Component Names **Impact: LOW** - Vue supports both PascalCase (``) and kebab-case (``) in templates, but PascalCase is recommended. It provides better IDE support, clearly distinguishes Vue components from native HTML elements, and avoids confusion with web components (custom elements). ## Task Checklist - [ ] Name component files in PascalCase (e.g., `UserProfile.vue`) - [ ] Use PascalCase when referencing components in templates - [ ] Use kebab-case only when required (in-DOM templates) - [ ] Be consistent across the entire codebase **Less Ideal:** ```vue ``` **Recommended:** ```vue ``` ## Why PascalCase? ### 1. Visual Distinction ```vue ``` ### 2. IDE Auto-completion PascalCase names are valid JavaScript identifiers, enabling better IDE support: - Auto-import suggestions - Go-to-definition - Refactoring tools ### 3. Avoids Web Component Confusion Web Components (custom elements) require kebab-case with a hyphen. Using PascalCase for Vue components avoids any confusion: ```vue ``` ## Exception: In-DOM Templates When using in-DOM templates (HTML files without build step), you MUST use kebab-case because HTML is case-insensitive: ```html
``` ## Vue's Automatic Resolution Vue automatically resolves PascalCase components to both casings: ```vue ``` ## Reference - [Vue.js Component Registration - Component Name Casing](https://vuejs.org/guide/components/registration.html#component-name-casing)