We use cookies to ensure you get the best experience on our website. Read our privacy policy

Skip to main content

Directory

Comments Section

Enable user engagement and discussion with a fully-featured comments system. Our Comments components provide everything you need to create an interactive commenting experience, including comment display, submission forms, and proper accessibility features.

The Comments system consists of three main components:

  • CommentSection: Container for displaying multiple comments
  • CommentForm: User interface for submitting new comments
  • Comment: Individual comment display component
---
const comments = [
{
name: 'Sarah Chen',
date: new Date('2024-03-15'),
comment: 'This is exactly what I was looking for!',
},
];
---
<CommentSection {comments} />
<CommentForm />

Individual comment displays with support for:

<Comment name="John Doe" date={new Date()} comment="This is a great feature!" />
Prop Type Default Description
name string Anonymous Name of the commenter
date Date undefined Timestamp of the comment
comment string required Comment content

User interface for submitting new comments:

<CommentForm title="Join the Discussion" name="blog-comments" />
Prop Type Default Description
title string Leave a comment Form header text
name string comment-form Form identifier

Container for displaying multiple comments:

<CommentSection comments={comments} title="Community Feedback" />
Prop Type Default Description
comments Comment[] [] Array of comment objects
title string What Others are Saying Section header text

Comments are designed with a clean, modern aesthetic that:

  • Uses consistent spacing and typography
  • Adapts to light and dark themes
  • Maintains readability at all screen sizes
  • Provides clear visual hierarchy
  • Semantic HTML structure
  • Proper form labeling
  • ARIA attributes where needed
  • Keyboard navigation support
  • Screen reader-friendly content structure
  1. Comment Management

    • Implement appropriate moderation
    • Consider pagination for large numbers of comments
    • Sort comments chronologically by default
    • Provide clear commenting guidelines
  2. User Experience

    • Show immediate feedback on submission
    • Validate input in real-time
    • Preserve form data on failed submissions
    • Consider authentication requirements
  3. Performance

    • Lazy load comments below the fold
    • Implement pagination or infinite scroll
    • Optimize images in user content
    • Cache comment data appropriately
Page.astro
---
const existingComments = [
{
name: 'Alex Thompson',
date: new Date('2024-03-10'),
comment: 'Great article! Very informative.',
},
{
name: 'Maria Garcia',
date: new Date('2024-03-11'),
comment: 'Thanks for sharing these insights.',
},
];
---
<article>
<h1>Blog Post Title</h1>
<!-- Post content -->
<div class="comments-wrapper">
<CommentSection comments={existingComments} title="Join the Discussion" />
<CommentForm title="Add Your Thoughts" name="post-comments" />
</div>
</article>
  • Custom comment sorting
  • Reply threading
  • User avatars
  • Reaction/voting systems
  • Comment editing
  • Rich text formatting
  • @mentions support
  • File attachments
  • Form - Base form functionality
  • Input - Text input fields
  • TextArea - Multi-line text input
  • Button - Form submission
  • Avatar - User images
  • Badge - Comment status indicators

Limited Time Launch Sale

Ready to add engaging comments to your content? Get our AstroJS starter template now and implement a full-featured commenting system in minutes.

GET 60% OFF!
North Star Themes Logo

Subscribe to our newsletter

Get the latest AstroJS tips and tricks right to your inbox

Email: [email protected]

© 2025 North Star Themes

Web Kit Provided By North Star Themes