PSC.Blazor.Components.AnchorLink 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package PSC.Blazor.Components.AnchorLink --version 1.0.2                
NuGet\Install-Package PSC.Blazor.Components.AnchorLink -Version 1.0.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PSC.Blazor.Components.AnchorLink" Version="1.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PSC.Blazor.Components.AnchorLink --version 1.0.2                
#r "nuget: PSC.Blazor.Components.AnchorLink, 1.0.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install PSC.Blazor.Components.AnchorLink as a Cake Addin
#addin nuget:?package=PSC.Blazor.Components.AnchorLink&version=1.0.2

// Install PSC.Blazor.Components.AnchorLink as a Cake Tool
#tool nuget:?package=PSC.Blazor.Components.AnchorLink&version=1.0.2                

An anchor link is a web link that allows users to leapfrog to a specific point on a website page. It saves them the need to scroll and skim read and makes navigation easier.

We have anchor (HTML tag a) everywhere and it is quite easy to create one

<a href="https://yourlink">Try me</a>

In HTML, you can add links in the same page using the # for example:

<a href="#chaper1">Jump to Chapter 1</a>

<h2 id="chapter1">Chapter 1</h2>
<p style="margin-bottom: 120px;">
    A paragraph with a huge bottom margin to make the page scroll.
</p>

When you click on the first link, the browser jumps to the h2 with id chapter1. Easy right? Unfortunately, we can't use this kind of link in Blazor.

How to use it

This component uses a bit of JavaScript to jump to the position with the requested id. For that, in the index.html you have to add in the script section at the end of the page the following line:

<script src="_content/PSC.Blazor.Components.AnchorLink/js/anchorLink.js"></script>

Then, in your page you have to replace the a with the component AnchorLink. Using the example above, the code becomes:

<AnchorLink href="#chaper1">Jump to Chapter 1</AnchorLink>

<h2 id="chapter1">Chapter 1</h2>
<p style="margin-bottom: 120px;">
    A paragraph with a huge bottom margin to make the page scroll.
</p>

Easy peasy!

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.3 270 11/13/2023
1.0.2 143 10/3/2023