BlazorCssTransitions 0.0.2

dotnet add package BlazorCssTransitions --version 0.0.2
                    
NuGet\Install-Package BlazorCssTransitions -Version 0.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="BlazorCssTransitions" Version="0.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BlazorCssTransitions" Version="0.0.2" />
                    
Directory.Packages.props
<PackageReference Include="BlazorCssTransitions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BlazorCssTransitions --version 0.0.2
                    
#r "nuget: BlazorCssTransitions, 0.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.
#:package BlazorCssTransitions@0.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BlazorCssTransitions&version=0.0.2
                    
Install as a Cake Addin
#tool nuget:?package=BlazorCssTransitions&version=0.0.2
                    
Install as a Cake Tool

BlazorCssTransitions

The code isn't entirely stable yet. Errors might occur.

Introduction

Library simplifies adding animations to blazor apps. Using C#/Blazor code create animations of visibility, content change, size change and other (TBA).

The API was inspired by Jetpack Compose's (kotlin) animations API.

Usage

  • Transition descriptors

To compose a enter/exit transition you should use interfaces EnterTransition and ExitTransition. Transition's timing is defined with Spec.

Example:

private readonly static EnterTransition _myElementEnterTrans
  = EnterTransition.SlideInVertically(Spec.EaseOut(TimeSpan.FromMilliseconds(200)), initialY: "20px")
    + EnterTransition.FadeIn(Spec.EaseIn(TimeSpan.FromMilliseconds(200)));

private readonly static ExitTransition _myElementExitTrans
  = ExitTransition.SlideOutHorizontally(Spec.EaseIn(TimeSpan.FromMilliseconds(200), delay: TimeSpan.FromMilliseconds(300)), finishX: "-20px")
    + ExitTransition.FadeOut(Spec.EaseIn(TimeSpan.FromMilliseconds(200), delay: TimeSpan.FromMilliseconds(300)));
  • Animated visibility

Blazor component AnimatedVisibility can be used to animate entrance and exit of content.

Example:

<AnimatedVisibility Visible=@(true)
                    Enter=@_myElementEnterTrans
                    Exit=@_myElementExitTrans
                    StartWithTransition
                    OnHidden=@(() => {})
                    OnShown=@(() => {})
                    Style="height: 100%"
                    Class="process-animation">
    <div> MY ELEMENT </div>
</AnimatedVisibility>
  • Animated content

Blazor component AnimatedContent can be used to animate changes of content.

Example:

<AnimatedContent TState="bool"
                 TargetState=@(true)
                 TransitionsProvider=@GetTransitions>
    @if (context)
    {
       <span> YES! </span>
    }


    else
    {
        <span> NO! </span>
    }
</AnimatedContent>

@code {
    private AnimatedContent<bool>.InterstateTransitions? GetTransitions(bool fromState, bool toState)
    {
        if (fromState)
            return GetTransitionsWithOffset("40px", "-40px");
        if (!fromState)
            return GetTransitionsWithOffset("-40px", "40px");

        return null; // null can be returned when no transitions should be applied

        static AnimatedContent<bool>.InterstateTransitions GetTransitionsWithOffset(CssLength offsetEnter, CssLength offsetExit)
        {
            return new AnimatedContent<bool>.InterstateTransitions
            {
                FromPreviousStateEnter = EnterTransition.FadeIn(Spec.EaseOut(TimeSpan.FromMilliseconds(150)))
                    + EnterTransition.SlideInHorizontally(Spec.EaseOut(TimeSpan.FromMilliseconds(150)), initialX: offsetEnter),
                ToNextStateExit = ExitTransition.FadeOut(Spec.EaseIn(TimeSpan.FromMilliseconds(150)))
                    + ExitTransition.SlideOutHorizontally(Spec.EaseIn(TimeSpan.FromMilliseconds(150)), finishX: offsetExit)
            };
        }
    }
}
  • Animated size container

Blazor component AnimatedSizeContainer can be used to animate size changes.

Example:

<AnimatedSizeContainer Spec=@Spec.EaseInOut(TimeSpan.FromMilliseconds(100))
                       FillWidth
                       OnResized=@(() => {})>
  <span> Element that can change it's content </span>
</AnimatedSizeContainer>
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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
0.0.2 86 5/31/2026
0.0.1 85 5/31/2026