JSDoc Component Guide
JSDoc in vapor-ui is user-facing UI, not internal code comments. Write it for developers who encounter the component for the first time via documentation sites (Storybook Autodocs, etc.).
Core rules
- Language: English only. No Korean in JSDoc blocks.
- Format: Put
/**on its own line and start the text on the next line. Never write a one-line/** ... */block, and don't add an empty*line before the text. - Placement: Write the component summary directly above the
export const X = forwardRef(...)statement — the extractor reads the JSDoc on that statement. Write individual prop descriptions inside the Props interface/type, not on the component.
Where to write
Placement depends on the component pattern. See references/guide.md for detailed patterns and examples.
| Target | File | Location |
| ----------------- | -------------------- | ----------------------------------------------------- |
| Component summary | {component}.tsx | Above export const X = forwardRef(...) |
| Individual props | {component}.tsx | Inside the interface or namespace Props |
| Variant groups | {component}.css.ts | On each variant key object inside componentRecipe() |
Do NOT write JSDoc on:
- Individual variant values (
sm,md,primary,fill, etc.) — the variant key description is sufficient export type XxxVariants— tooling derives this from the recipe automatically
Pattern quick-reference
- Standalone — no JSDoc on namespace
Propsitself; write variant group docs incomponentRecipe()in.css.ts - Compound Root (custom props via
interface) — write on theinterface, namespace wraps it - Compound Root with context (
Assign<…, Context>pattern) — write only on custom props - Compound sub-part (
Omit<…, keyof Context>pattern) — write only on remaining props
Component summary rules
- One single line — no line breaks inside the summary
- User perspective: what it is → when to use it
- No internal terms (
memoized,wrapper,token-based, etc.) - End with the rendered HTML element using backticks around the tag: "Renders a
<button>element." or "Doesn't render its own HTML element.". - Primitive vs combined part — a
XxxPrimitivepart describes the part itself. A part that assembles primitives (e.g.Tooltip.PopupoverPortalPrimitive,PositionerPrimitive,PopupPrimitive) starts with "CombinesA,B, andCinto a single part.", then names thexxxElementprops that replace each piece (if it has any), then the rendered element. See references/guide.md.
Prop description rules
- Don't repeat the prop name or its type
- Describe side effects and interactions with other props
- For numeric props: include unit and valid range
- For event handlers: specify the exact trigger condition, not just "handler"
- Put a default in code, not in JSDoc. The docs table reads
defaultValuefrom code: the component's destructuring defaults, a literal written before the props spread, then thedefaultVariantsof the recipe that declares the variant. For a Base UI prop vapor-ui passes through untouched, it falls back to Base UI's own@default(seescripts/docs-extractor/README.md"Default values"). Never write inlineDefault:text; it stays in the description and repeats the table. Write an@defaulttag only when the extractor can't read the default from code, such as a prop forwarded to another vapor-ui component. A vapor-ui@defaultis dropped from the description and not read as a default, so it shows only in editor hover. children— say what goes in the slot, with an example ("Content shown inside the badge, such as a label or count."). For a function child, describe its arguments. Never write just "Children of the component" or restateReactNode.- Inherited Base UI props with no description (e.g.
children,onClick) — re-declare the prop in the part's Propsinterfacewith the Base UI type (children?: BaseMenu.Trigger.Props['children']) and write the JSDoc there. The extractor prefers vapor-ui's own declaration. Turnexport type Props = …intoexport interface Props extends … {}when needed. - Repeated props (
size,invalid,portalElement, …) — start from the shared phrase in references/guide.md and add only what differs for that component.
Review checklist
See the full checklist in references/guide.md.
Quick checklist:
- [ ] All JSDoc in English
- [ ]
/**on its own line, text starts on the next line, no one-line/** */blocks - [ ] Summary is one line, complete sentence, HTML element in backticks (e.g. `
<button>`) - [ ] Combined parts start with "Combines …" and name their
xxxElementprops - [ ] No prop name repetition in descriptions
- [ ]
childrensays what goes in the slot - [ ] Event handlers describe exact trigger condition
- [ ] Numeric props include unit and range
- [ ] Shared props (
size,invalid, …) follow the shared phrases - [ ] No JSDoc on individual variant values (
sm,md,fill,primary, etc.) - [ ] No JSDoc on
export type XxxVariants - [ ] No inline
Default:text;@defaultonly where the extractor can't read the default from code