Соглашения об именовании компонентов
Узнайте, как понятные и последовательные имена компонентов и их свойств делают библиотеку компонентов удобной для поиска, предсказуемой и поддерживаемой.
«Соглашения об именовании компонентов» — бесплатный урок Design Systems & Component Libraries на CoddyKit. Это урок 4 из 4. Ты можешь прочитать весь урок бесплатно ниже — а потом практиковать его прямо в браузере с встроенным редактором кода и ИИ-репетитором 24/7. Это часть пути обучения Design Systems & Component Libraries, и твой прогресс синхронизируется между веб-версией и приложением CoddyKit. Курс Design Systems & Component Libraries содержит 4 уроков всего.
Части этого урока еще не переведены и отображаются на английском.
Why Names Matter
The hardest problems in component libraries are not technical - they are naming. A poorly named component is hard to find, easy to misuse, and painful to rename later.
Good names act as documentation and reduce the questions teammates ask.
Be Descriptive, Not Clever
Name components by what they are or do, not by clever metaphors.
- Good:
UserAvatar,PrimaryButton - Avoid:
Blob,Sparkle,Thingy
A new teammate should guess the purpose from the name alone.
Consistent Casing
Pick one casing rule and never deviate. The web convention:
- Components: PascalCase (
CardHeader) - Props: camelCase (
isDisabled) - CSS classes: kebab-case (
card-header)
Mixing casing styles erodes trust in the library.
Boolean Props
Boolean props read best with an is, has, or should prefix. They sound like questions and default to false.
The snippet below shows the pattern.
function describe(props) {
return 'disabled=' + props.isDisabled + ', loading=' + props.isLoading;
}
console.log(describe({ isDisabled: true, isLoading: false }));Prop Naming Patterns
Establish predictable prop names across all components:
variantfor visual style (primary, ghost)sizefor scale (sm, md, lg)onChange,onClickfor event handlers
If every component uses the same names, learning one teaches you all.
Avoid Implementation Details
Do not bake fragile details into names. BlueButton becomes a lie the moment the brand color changes.
Prefer intent-based names like PrimaryButton. The intent is stable even when the styling evolves.
Namespacing and Prefixes
Many systems prefix components to avoid clashes and signal origin: DsButton, AcmeCard.
This helps when consuming apps already have their own components. Choose a short prefix and apply it everywhere or nowhere - consistency over preference.
Compound Component Naming
Related parts should share a family name: Card, CardHeader, CardBody, CardFooter.
The shared prefix groups them in autocomplete and signals they belong together. This is far clearer than Card, Heading, Content.
Renaming Is Expensive
Once a component name ships, every consuming app depends on it. Renaming becomes a breaking change requiring deprecation cycles.
Invest time in the name up front. A 10-minute naming discussion saves months of migration pain.
Document the Rules
Write your naming conventions down in the contribution guide. New contributors should not have to reverse-engineer your patterns.
A short, enforced naming doc keeps the library coherent as more people contribute.
Names as a Contract
Ultimately, a component's name and prop names form a public API contract. Treat them with the same care as any API.
Predictable names let developers compose your library confidently without reading the source.
Quick Check
Test your naming instincts.
Recap
You learned naming conventions that keep a component library usable:
- Be descriptive and intent-based, not clever or color-bound.
- Use consistent casing and predictable prop names.
- Group compound components with shared prefixes.
- Document the rules and remember renaming is costly.
Good names are quiet documentation.
Изучай Design Systems & Component Libraries с ИИ-репетитором — бесплатно
Пиши и запускай код прямо в браузере, получай мгновенную помощь от ИИ-репетитора 24/7 и продолжи учиться на сайте или в приложении.
- Курсы
- 12
- Уроки
- 48
Часто задаваемые вопросы
Урок «Соглашения об именовании компонентов» бесплатный?
Да — полный текст урока «Соглашения об именовании компонентов» бесплатно доступен здесь в веб-версии. Чтобы практиковать его интерактивно (встроенный редактор кода и ИИ-репетитор 24/7) и разблокировать остальной курс Design Systems & Component Libraries, подпишись на CoddyKit PRO. Курс Design Systems & Component Libraries содержит 4 уроков всего.
Чему я научусь в уроке «Соглашения об именовании компонентов»?
Узнайте, как понятные и последовательные имена компонентов и их свойств делают библиотеку компонентов удобной для поиска, предсказуемой и поддерживаемой. Ты практикуешь Design Systems & Component Libraries с помощью реального кода, который запускаешь прямо в браузере, и ИИ-репетитор 24/7 отвечает на твои вопросы во время урока.
Нужен ли мне опыт, чтобы начать Design Systems & Component Libraries?
Предыдущий опыт не требуется. Design Systems & Component Libraries на CoddyKit структурирован для всех уровней — от новичков до продвинутых, поэтому ты можешь начать отсюда или с самого начала и учиться в своем темпе. Это урок 4 из 4.
Сколько времени занимает урок «Соглашения об именовании компонентов»?
Большинство уроков CoddyKit занимают около 5–10 минут. Каждый из них компактный и интерактивный, поэтому ты постоянно делаешь прогресс и продолжаешь с того же места в веб-версии и приложении.
Можно ли писать и запускать код в этом уроке Design Systems & Component Libraries?
Да. Каждый урок Design Systems & Component Libraries включает встроенный редактор кода, поэтому ты пишешь и запускаешь реальный код прямо в браузере и получаешь моментальную обратную связь от AI — локальная установка не требуется.
Все уроки этого курса
- Методология атомарного дизайна
- Анатомия и структура компонентов
- Выбор компонентов технологического стека
- Соглашения об именовании компонентов