Passing Classes to Components in Astro

Updated on

{...Astro.props} is a way to forward all received props from a parent component to an element inside your Astro component. This is useful for passing classes, styles, or other attributes without having to specify each one.

<!-- src/components/Button.astro -->
<button {...Astro.props}>My Button</button>
<Button class="primary" />

The <button> receives class="primary" automatically.