Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/content/docs/en/guides/images.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,29 @@ import Logo from '../assets/logo.svg';
<Logo width={64} height={64} fill="currentColor" />
```

#### `SvgComponent` Type

You can also enforce type safety for your `.svg` assets using the `SvgComponent` type:

```astro title="src/components/Logo.astro"
import type { SvgComponent } from "astro/types";
import HomeIcon from './Home.svg'

interface Link {
url: string
text: string
icon: SvgComponent
}

const links: Link[] = [
{
url: '/',
text: 'Home',
icon: HomeIcon
}
]
```

### Creating custom image components

You can create a custom, reusable image component by wrapping the `<Image />` or `<Picture/>` component in another Astro component. This allows you to set default attributes and styles only once.
Expand Down