Docs
Basic Usage
Basic Usage
How to import and use the scaffolded SVGM.tsx Typescript component in your project
Basic Usage
Here's a quick example of how to use svgMagic in Typescript
1
import SVGM from "../svgm/SVGM"
2
<SVGM kind="svgm"/>
example.tsx
import React from 'react';
import SVGM from "@/components/svgm/SVGM";
const ExampleComponent = () => (
<div>
<SVGM kind="svgm-mark" className="h-8 w-8 text-white" />
</div>
);
export default ExampleComponent;That's it! One import, one line of code, and you're set, change it as you see fit - no extra configuration steps required.
- To change the
.svgfile being rendered, simply change thekindproperty to another file name in your directory.
Let's not forget about MDX, here's the SVGM.tsx component in an .mdx document, after importing it into your mdx-components.
example.mdx
---
title: svgMagic Documentation
---
<SVGM kind="example-icon" className="h-8 w-8 text-current" />If your .svg isn't rendering properly, take a look at our SVG Preparation, and then Styling