#Compound Components

3 messages · Page 1 of 1 (latest)

raw dome
#

Does Astro support compound components e.g. Component.Subcomponent

long oracleBOT
#

Hi @raw dome. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Astro supports the concept of reusable and composable components. This means you can use components inside of other components to build more advanced UI. For example, a Button component could be used to create a ButtonGroup component:

---import Button from './Button.astro';---
<div> 
  <Button title="Button 1" /> 
  <Button title="Button 2" /> 
  <Button title="Button 3" />
</div>

(Source: Astro Documentation (https://docs.astro.build/en/core-concepts/astro-components/))

However, the extracts provided do not specifically mention the concept of "compound components" in the form of Component.Subcomponent. It's important to note that Astro's component model is a bit different from JavaScript frameworks like React. Astro components are more akin to HTML and don't inherently support the Component.Subcomponent syntax.

If you're looking to create a hierarchy of components, you might consider organizing your components into separate files and importing them as needed. This is a common pattern in Astro and allows for a high degree of modularity and reusability.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: