name: ncdai-writing-component-docs description: Write and review component documentation (MDX) and registry descriptions. Covers doc structure, description writing, Features, Composition, Credits, and References sections. Use when creating new component docs, updating descriptions, adding Features sections, adding Composition sections, adding Credits sections, adding References sections, or reviewing component documentation quality.
Writing Component Documentation
Guide for writing concise, consistent component documentation for this project's registry. Covers MDX doc structure, description writing, Features sections, Composition sections, Credits sections, and References sections.
Key Files
- Component docs:
src/features/doc/content/{component-name}.mdx - Registry items:
src/registry/components/_registry.ts - Description must be kept in sync between both files.
MDX Document Structure
Component docs follow this section order. Only include sections that are relevant.
---
title: Component Name
description: One concise sentence about what the component does.
image: https://assets.chanhdai.com/images/blog/{component-name}.webp
category: components
createdAt: YYYY-MM-DD
updatedAt: YYYY-MM-DD
---
<ComponentPreview name="{component-name}-demo" />
## Features (optional -- skip if component is self-explanatory)
## Installation
## Usage
## Composition (optional -- only for compound/composable components)
## API Reference (optional)
## Examples (optional)
## Credits (optional -- for inspiration/original sources)
## References (optional -- for technical reading and implementation details)
Writing Descriptions
The description field appears in MDX frontmatter AND the registry item. Both must match.
Rules
- One short sentence -- focus on WHAT the component does, not HOW it is built.
- Start with a verb or noun. Never start with "A", "An", or "A React component for...".
- Drop implementation details like "built with Motion" or "using Tailwind CSS".
- Keep it under ~80 characters when possible.
Good Examples
Toggle between system, light, and dark themes in Next.js apps.
Animated text that cycles through items with a smooth flip transition.
Interactive slider inspired by the classic iPhone "slide to unlock" gesture.
Scrolling marquee to showcase user testimonials.
Display install commands with package manager switcher and copy button.
Copy text to clipboard with visual feedback and animation.
Bad Examples
A React component for managing user consent for cookies and tracking in Next.js applications.
--> Too long, starts with "A React component for..."
Animated text component that cycles through items with a smooth flip transition built with Motion for React.
--> "component" is redundant, "built with Motion for React" is implementation detail
A sleek, interactive slider inspired by the classic iPhone OS "slide to unlock" gesture.
--> Starts with "A sleek", subjective adjective
Writing Features Sections
When to Include
Add ## Features when the component has non-obvious capabilities that the title, description, and preview alone cannot convey. Examples: multi-mode support, special interactions, keyboard navigation, persistence, composability.
When to Skip
Skip ## Features when the component is self-explanatory through its title + description + preview + usage. Examples: Theme Switcher, Shimmering Text, Apple Hello Effect.
Rules
- Use exactly
## Featuresas the heading (not "About", not "Overview"). - Write 2-4 bullet points, one line each.
- Start each bullet with the capability, not filler words.
- End each bullet with a period.
- No emoji.
- Do not repeat information already in Installation, Usage, or API Reference.
Good Example
## Features
- Content fades in and out smoothly as you scroll.
- Supports both vertical and horizontal scrolling.
Bad Example
## About
The Scroll Fade Effect component is built on top of CSS animation-timeline.
- ๐ฑ Smooth scrolling fade effect
- ๐จ Customizable with Tailwind CSS
- โก๏ธ Easy installation via shadcn CLI
Issues: wrong heading name, intro paragraph is unnecessary, emoji, "Easy installation" repeats Installation section.
Writing Composition Sections
When to Include
Add ## Composition when the component uses a compound/composable pattern -- multiple sub-components that need to be assembled together in a specific tree structure. Examples: SlideToUnlock (track, handle, text), Testimonial (quote, author, avatar), GlowCardGrid (grid + cards).
When to Skip
Skip ## Composition when the component is a single element used with props alone, not composed from sub-components. Examples: CopyButton, ShimmeringText, ThemeSwitcher, TextFlip, MiddleTruncation.
Rules
- Use exactly
## Compositionas the heading. - Place it immediately after
## Usage. - Start with the line:
Use the following composition to build a \{ComponentName}`.` - Use a
```textfenced code block for the tree. - Draw the tree using box-drawing characters:
โโโ,โโโ,โ. - Show the full component hierarchy as it appears in the Usage JSX.
- If the component wraps sub-components from another package, include them in the tree.
Good Example
## Composition
Use the following composition to build a `SlideToUnlock`
\```text
SlideToUnlock
โโโ SlideToUnlockTrack
โโโ SlideToUnlockText
โ โโโ ShimmeringText
โโโ SlideToUnlockHandle
\```
Another Example (deeper nesting)
## Composition
Use the following composition to build a `Testimonial`
\```text
Testimonial
โโโ TestimonialQuote
โโโ TestimonialAuthor
โโโ TestimonialAvatar
โ โโโ TestimonialAvatarImg
โ โโโ TestimonialAvatarRing
โโโ TestimonialAuthorName
โ โโโ TestimonialVerifiedBadge
โโโ TestimonialAuthorTagline
\```
Credits vs References
Use this quick intent check before placing a link:
- Put a link in
## Creditswhen it answers: "Who inspired this component?" or "What original source/product is this derived from?" - Put a link in
## Referenceswhen it answers: "How does this work?" or "Where can I learn implementation details/API?" - If one link can fit both, prefer
## Credits. KeepCreditsminimal and place explanatory context in## Referencesonly when needed. - Skip generic links that do not help readers build, understand, or trace origin.
Writing Credits Sections
When to Include
Add ## Credits when the component is inspired by, derived from, or adapted from an original source the reader should be able to trace. Examples: original demo/tweet, source product interaction, canonical inspiration.
When to Skip
Skip ## Credits when there is no meaningful inspiration or origin worth acknowledging.
Rules
- Use exactly
## Creditsas the heading (not "Attribution", not "Thanks", not "Resources"). - Place it near the end, before
## References. - Bullet list of markdown links, one item per line.
- Keep the list short (typically 1-5 items). Every link must add value.
- Credit the original creator whenever possible.
- No emoji.
- Each item must display only the author name/handle, but the URL must point to the exact original source.
Item Formats
Use author-centric display text with source URLs:
| Format | Use For |
|---|---|
- [@handle](source-url) |
Display handle, open the exact source link. |
- [Author Name](source-url) |
Display author name, open the exact source link. |
Good Examples
## Credits
- [@jh3yy](https://x.com/jh3yy)
- [Josh Puckett](https://joshpuckett.me/dialkit)
## Credits
- [@rds_agi](https://x.com/rds_agi)
- [Apple](https://www.figma.com/community/file/1414773009964314315/official-apple-hello-lettering)
Bad Examples
## Credits
- [View Transition API](https://developer.mozilla.org/en-US/docs/Web/API/View_Transition_API)
Issue: this is technical implementation reading, so it belongs in ## References, not ## Credits. It is also not an author label.
## Credits
Thanks to everyone who inspired this component! โค๏ธ
- [Original glow effect demo by @jh3yy](https://x.com/jh3yy/status/1992003440579662211)
Issues: narrative intro is unnecessary, emoji is not allowed, and item should be author-only text with the source URL (for example [@jh3yy](https://x.com/jh3yy/status/1618297458752368640)).
Writing References Sections
When to Include
Add ## References for technical reading that helps readers implement, understand, or extend the component. Examples: library APIs, web platform docs, implementation articles, related primitives used by the component.
When to Skip
Skip ## References when there are no high-value technical links beyond obvious generic docs.
Rules
- Use exactly
## Referencesas the heading (not "Resources", not "See Also"). - Place it as the LAST section in the doc.
- Bullet list of markdown links, one item per line.
- Keep the list short (typically 1-5 items). Every link must add value.
- Focus on technical/implementation value, not attribution.
- No emoji.
Item Formats
Pick the format that matches the kind of link:
| Format | Use For |
|---|---|
- [Title](url) |
Library docs, related component docs, web APIs. |
- [Title](url) โ short context |
Clarify why this reference matters for this component. |
Good Examples
## References
- [View Transition API](https://developer.mozilla.org/en-US/docs/Web/API/View_Transition_API)
- [Motion Layout Animations](https://motion.dev/docs/react-layout-animations) โ layout transition behavior
## References
- [Radix Select](https://www.radix-ui.com/primitives/docs/components/select)
- [shadcn/ui Select](https://ui.shadcn.com/docs/components/select)
Bad Examples
## References
- [Original glow effect demo by @jh3yy](https://x.com/jh3yy/status/1992003440579662211)
Issue: this is attribution/inspiration, so it belongs in ## Credits.
## References
- [React](https://react.dev)
- [Tailwind CSS](https://tailwindcss.com)
Issue: generic links with low signal; add only references with specific relevance.
Registry Item Format
Each component in src/registry/components/_registry.ts must have a description field matching the MDX frontmatter:
{
name: "component-name",
type: "registry:component",
description: "Same one-sentence description as MDX frontmatter.",
title: "Component Name",
author: "ncdai <dai@chanhdai.com>",
// ...
}
Sync Checklist
When creating or updating a component doc:
- Write a concise description following the rules above.
- Set the same description in both MDX frontmatter and registry item.
- Decide whether
## Featuresis needed (non-obvious capabilities). - If adding Features, write 2-4 bullet points following the rules.
- Decide whether
## Compositionis needed (compound/composable components). - If adding Composition, draw the tree matching the Usage JSX structure.
- Decide whether
## Creditsis needed (inspiration/original sources worth acknowledging). - If adding Credits, use only author name/handle as link text, and always point to the exact source URL.
- Decide whether
## Referencesis needed (technical links that help implementation and deeper learning). - If adding References, keep links technical, specific, and high-value.
- Verify section order: Preview -> Features -> Installation -> Usage -> Composition -> API Reference -> Examples -> Credits -> References.