htmlcssasp.net-coreblazorblazor-server-side

Blazor Icons Not Displaying


I cannot, for the life of me, get Bootstrap icons 1.11.3 to display at all. I am using a Blazor SSR project. I have this link setup in App.razor:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css" />

I have tried numerous approaches to getting the bi-alarm image to display. I have even downloaded the alarm.svg file and placed it into my “images” folder. Even using <img src="~/images/alarm.svg" />, the image will not display.

What could I be doing wrong?


Solution

  • To use picture in wwwroot folder, delete the "~" symbol will work. Try following:

    @page "/"
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css">
    <h1>Hello, world!</h1>
    <img src="/favicon.png"/>
    <span class="bi-alarm"></span>
    

    Test result:

    enter image description here enter image description here