<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: PunkerDuck</title>
    <description>The latest articles on DEV Community by PunkerDuck (@punkerduck).</description>
    <link>https://dev.to/punkerduck</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4179515%2F2f4cb3cd-7e2a-4571-bb1d-3a73b61c7433.png</url>
      <title>DEV Community: PunkerDuck</title>
      <link>https://dev.to/punkerduck</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/punkerduck"/>
    <language>en</language>
    <item>
      <title>From an AI prompt to an SVG icon in React: a tested example</title>
      <dc:creator>PunkerDuck</dc:creator>
      <pubDate>Mon, 12 Oct 2026 15:12:00 +0000</pubDate>
      <link>https://dev.to/punkerduck/from-an-ai-prompt-to-an-svg-icon-in-react-a-tested-example-aeh</link>
      <guid>https://dev.to/punkerduck/from-an-ai-prompt-to-an-svg-icon-in-react-a-tested-example-aeh</guid>
      <description>&lt;p&gt;An SVG export can contain real vector paths and still be a poor fit for a tiny button. This example follows one image from its AI prompt through conversion to a React label, then looks at what survives at interface sizes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Disclosure:&lt;/strong&gt; We build PunkerIcon, which produced the assets used in this experiment. AI assistance was used to draft this article; the SVG measurements and React example were checked against the actual files.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Start with the prompt and inspect the output
&lt;/h2&gt;

&lt;p&gt;We used this description:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Rubber duck wearing coding glasses with laptop&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The settings were Icon artwork, color enabled and pixel art off. Here is the exported SVG rendered as a PNG at &lt;strong&gt;1024 × 1024 pixels&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flxt9t8f03hspdby3zh6s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flxt9t8f03hspdby3zh6s.png" alt="SVG export rendered as a PNG, with flat yellow, orange, gray, black and near-white regions" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The exported SVG contains solid yellow, orange and gray shapes with dark contours. Vector conversion can simplify shading and change edge shapes. Both exports have transparent backgrounds; the React example below supplies white behind the dark contours.&lt;/p&gt;

&lt;p&gt;You can download the &lt;a href="https://icon.punkerduck.com/images/blog/developer-duck-worked-example.svg" rel="noopener noreferrer"&gt;complete SVG&lt;/a&gt; and &lt;a href="https://icon.punkerduck.com/images/blog/developer-duck-worked-example-export.png" rel="noopener noreferrer"&gt;PNG export&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Check what the SVG contains
&lt;/h2&gt;

&lt;p&gt;This file is &lt;strong&gt;13,152 bytes&lt;/strong&gt;, with &lt;strong&gt;16 paths&lt;/strong&gt; and &lt;strong&gt;five explicit fill colors&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#040404  #ababac  #f46d14  #fccb13  #fcfcfc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is no embedded &lt;code&gt;&amp;lt;image&amp;gt;&lt;/code&gt; element. It contains vector geometry rather than a PNG wrapped in an SVG container.&lt;/p&gt;

&lt;p&gt;Its outer structure looks like this. The path data is omitted here; use the downloaded file for the working asset.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;svg&lt;/span&gt; &lt;span class="na"&gt;xmlns=&lt;/span&gt;&lt;span class="s"&gt;"http://www.w3.org/2000/svg"&lt;/span&gt;
  &lt;span class="na"&gt;width=&lt;/span&gt;&lt;span class="s"&gt;"512px"&lt;/span&gt; &lt;span class="na"&gt;height=&lt;/span&gt;&lt;span class="s"&gt;"512px"&lt;/span&gt;
  &lt;span class="na"&gt;viewBox=&lt;/span&gt;&lt;span class="s"&gt;"0 0 1254.000000 1254.000000"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;g&lt;/span&gt; &lt;span class="na"&gt;transform=&lt;/span&gt;&lt;span class="s"&gt;"translate(0.000000,1254.000000) scale(0.100000,-0.100000)"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="c"&gt;&amp;lt;!-- All 16 filled paths belong here. --&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/g&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/svg&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keep the &lt;code&gt;viewBox&lt;/code&gt; and group transform intact. The paths use a larger coordinate scale with an inverted vertical axis. Changing the &lt;code&gt;viewBox&lt;/code&gt; to &lt;code&gt;0 0 24 24&lt;/code&gt; crops the drawing; it does not resize it to 24 pixels. Set the displayed width and height instead.&lt;/p&gt;

&lt;p&gt;The dark contours are filled shapes, not adjustable strokes. Adding &lt;code&gt;strokeWidth&lt;/code&gt; will not turn them into thinner outlines.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Use the file in React
&lt;/h2&gt;

&lt;p&gt;In a Next.js project, save the complete SVG as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public/images/blog/developer-duck-worked-example.svg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It will be served at &lt;code&gt;/images/blog/developer-duck-worked-example.svg&lt;/code&gt;. Other React setups can use the same component as long as your public asset folder serves that URL.&lt;/p&gt;

&lt;p&gt;This is the component rendered in the worked example. It needs no SVG loader or extra library:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;DeveloperProjectLabel&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;span&lt;/span&gt;
      &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;inline-flex&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;alignItems&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;center&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;gap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;backgroundColor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#fff&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#111827&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;8px 12px&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;borderRadius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;img&lt;/span&gt;
        &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"/images/blog/developer-duck-worked-example.svg"&lt;/span&gt;
        &lt;span class="na"&gt;width&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;32&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
        &lt;span class="na"&gt;height&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;32&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
        &lt;span class="na"&gt;alt&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;""&lt;/span&gt;
      &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
      Developer project
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;span&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The empty &lt;code&gt;alt&lt;/code&gt; makes the image decorative because the adjacent text names the project. If the image conveys information that the text does not, give it an appropriate description instead. Explicit dimensions reserve its space in the layout.&lt;/p&gt;

&lt;p&gt;The white background and dark text keep this particular label readable across themes. Its artwork palette stays fixed: changing the parent’s text color does not recolor the SVG loaded through &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt;. An external image does not inherit the page’s &lt;code&gt;currentColor&lt;/code&gt; into its paths. For path-level styling, you would need an inline SVG and suitable fill values.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Test the size you actually need
&lt;/h2&gt;

&lt;p&gt;This PNG comparison is rendered directly from the exported SVG at three times resolution. The labels show the intended display sizes at 1× scale: 24, 32, 64 and 128 pixels. DEV resizes the inline preview, preserving the relative sizes; use the full-resolution link below for a sharper view.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F430xnnysdvxr6csjk220.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F430xnnysdvxr6csjk220.png" alt="High-resolution PNG comparison rendered from the SVG at intended display sizes of 24, 32, 64 and 128 pixels" width="800" height="288"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev-to-uploads.s3.us-east-2.amazonaws.com/uploads/articles/zm0749ayjsapm84wrfmd.png" rel="noopener noreferrer"&gt;Open the full-resolution comparison (1920 × 690)&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;At the smaller sizes, the yellow duck and dark glasses remain recognizable, but the eyes and laptop details are harder to distinguish. At 64 and 128 pixels, those details have more room.&lt;/p&gt;

&lt;p&gt;Vector scaling keeps shapes sharp. It cannot make a detailed illustration as legible as a simple interface symbol. This duck is a better fit for a larger avatar or project illustration; keep accompanying text when using it in compact controls. Check it on your actual background, too.&lt;/p&gt;

&lt;p&gt;To repeat the size check locally, change both &lt;code&gt;width&lt;/code&gt; and &lt;code&gt;height&lt;/code&gt; in the component to 24, 64 or 128. Leave the source file unchanged. Compare whether the laptop remains understandable, whether the contours blend together and whether the image still supports the label at normal viewing distance.&lt;/p&gt;

&lt;p&gt;The useful check is the rendered result in its intended context. A valid SVG and a small path count tell you about the file’s structure; they do not establish that its details work at every display size.&lt;/p&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>ai</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
