Custom Component
For use cases that cannot be handled by standard components, you can create custom components.
The implementation of standard components is self-contained within each component’s .astro
file, and you can trace all the APIs used from the imports.
<Image>
componentastro-image-processor/components/Image.astro
<Picture>
componentastro-image-processor/components/Picture.astro
<Background>
componentastro-image-processor/components/Background.astro
Example
As an example, consider the case of changing the CSS output by the <Image>
component.
Define CustomImageSource
class that extends the ImageSource
class and overrides the cssObj
method to change the CSS output.
Duplicate Image.astro
and create a CustomImage
component that uses the CustomImageSource
class instead of the ImageSource
class.
Use the CustomImage
component instead of the Image
component.