Naming
A consistent naming system makes the project predictable from the
outside. Every public surface uses the hc- prefix.
The hc- prefix
Section titled “The hc- prefix”CSS classes: hc-button, hc-field, hc-cardCustom elements: hc-confirm-action, hc-live-searchData attributes: data-hc-confirm, data-hc-close-dialog-on-successCSS custom properties: --hc-color-bg, --hc-button-heightEvents: hc:toast, hc:confirm, hc:close-dialogThe prefix is short, unambiguous, and easy to grep.
CSS classes
Section titled “CSS classes”Component classes are component-oriented, not utility-oriented.
hc-buttonhc-inputhc-fieldhc-cardhc-alerthc-badgehc-tablehc-dialoghc-popoverhc-toolbarhc-paginationWhen a component has stable internal structure, use part-like child
classes (BEM-style __ separator, no modifier classes):
hc-card__headerhc-card__bodyhc-card__footerhc-dialog__titlehc-field__labelhc-field__messageVariants and sizes — not modifier classes
Section titled “Variants and sizes — not modifier classes”Variant and size axes live on data-* attributes, not on extra class
names. This keeps markup short, makes the variant set legible, and lets
servers update visual state by changing a single attribute.
<button class="hc-button" data-variant="primary" data-size="sm"> Save</button>Avoid:
<button class="hc-button hc-button--primary hc-button--sm">Save</button>Recommended variant names (where they apply):
default · primary · secondary · error · warning · success · ghost · linkRecommended size names:
sm · md · lgData attributes
Section titled “Data attributes”Two families:
data-hc-*— Hypermedia Components behavior hooks. Examples:data-hc-confirm,data-hc-close-dialog-on-success.data-hx-*— htmx attributes. Hypermedia Components docs always prefer thedata-hx-*form over the shorterhx-*because it is valid HTML5 syntax and more friendly to template engines.
Keep behavior attributes explicit and readable. Do not invent a
single opaque DSL like data-hc="delete item confirm toast reload" —
each behavior gets its own attribute with a self-evident value.
Custom elements
Section titled “Custom elements”Macros (optional) use the same hc- prefix and are kebab-case:
<hc-confirm-action><hc-live-search><hc-remote-dialog>Every macro must document its expanded HTML so consumers can copy it verbatim and customize.
CSS custom properties
Section titled “CSS custom properties”Custom properties are generated from DTCG tokens and named after the JSON path without the file’s namespace.
semantic.color.bg → --hc-color-bgcomponent.button.primary.bg → --hc-button-primary-bgcomponent.field.label-font-size → --hc-field-label-font-sizeSee Tokens for the layer strategy.
Events
Section titled “Events”Custom events dispatched by behaviors use a colon-separated namespace:
hc:toast — display a transient toasthc:confirm — internal confirm-dialog lifecyclehc:close-dialog — close the nearest dialogCustom events bubble by default so listeners can be attached high in
the tree (typically on document.body).
Things that look similar but are not part of HC
Section titled “Things that look similar but are not part of HC”- htmx classes —
htmx-request,htmx-indicator. These are added by htmx and styled byhc.htmx.css. HC does not own the names. - Browser-native attributes —
disabled,aria-invalid,popover. HC styles these directly so consumers do not need a shadow modifier.