Component Structure Guidelines & Variables Name Convention
Category: Code
Created by: Pacifico
Created At: May 15, 2026
Updated: May 15, 2026
Component Structure Guidelines & Variables Name Convention
Component Structure Guidelines βοΈ
Note: This applies to any kind of component (React, Astro, etc).
- Components should use one type/interface. Extra types only if an array is needed.
1.1 No array needed:
interface Props {
title: string;
paragraphs: string;
propX: string;
propY: string;
propZ: string;
...
}
1.2 Array needed:
interface Props {
title: string;
paragraphs: string;
cardData: Card[];
}
interface Card {
title: string;
paragraphs: string;
cta?: {
url: string;
title: string;
}
}
- Components should name the interface/type
Props. - Components should take only one prop on-page. No need for one const per component prop.
---
const data = {
title: "Enroll Now",
paragraphs: "Lorem ipsum",
propX: "X",
propY: "Y",
propZ: "Z",
}
---
<CTASection props={...data}>
- Component data for props should come from the page frontmatter. No external data.js file for itβs data is needed.
- Component names should follow Pascal Case (ComponentName.astro β | component-name.astro β)
- Components should always use set:html-like strategies to inject props
- Icons on components should be used as tags (<svg>, <FaIconName>, etc) and never as an import (exceptions include svg not provided, obviously)
Recommended Folder Structure π
src/
components/
general/
Hero.astro
Footer.astro
Navbar.astro
NavbarContact.astro
specific/
BlogCard.astro
BlogFeed.astro
BlogRelatedPosts.astro
SectionImageAndDescription.astro
SectionIcons.astro
Bento.astro
Socials.astro
ImageComp.astro
FormattedDate.astro
forms/
FormComp.astro
FormField.astro
FormContact.astro
FormDiscoveryFlight.astro
widgets/
ChatWidget.astro
ElfSightGoogleReviews.astro
GoogleMaps.astro
Variables Namming Convention π
- Heading tags use
title - Text on top of a heading use
upperTitle - Paragraph tags use
paragraphorparagraphs(array) - CTA links use
url - CTA buttons text use
label - Apply this logic recursively
- If more than one title, use
titlesand it becames an array. Same thing for the other variables.
Example:
interface Props {
upperTitle: string;
title: string;
paragraphs: string[];
cardData: Card[]
cta: {
url: string;
label: string;
}
}
interface Card {
title: string;
paragraphs: string[];
cta: {
url: string;
label: string;
}
}