New to Telerik UI for Blazor? Start a free 30-day trial
Center Telerik Window Horizontally and Keep Fixed Top Position
Updated on Dec 18, 2025
Environment
| Product | Window for Blazor |
Description
I want to center a Telerik Window horizontally in my Blazor application but keep it at a fixed distance from the top without using JavaScript for calculations.
This knowledge base article answers the following questions:
- How can I center a Telerik Window only horizontally in Blazor?
- Is it possible to position a Telerik Window at a fixed distance from the top in Blazor while centering it horizontally?
Solution
To center a Telerik Window horizontally while maintaining a fixed distance from the top, follow these steps:
- Apply a custom CSS class to the Window.
- Use this CSS class to set the initial top value, manage the horizontal centering and override the default vertical transformation.
Telerik Blazor Window Centered Horizontally with Fixed Top Value
<TelerikButton OnClick="@(() => WindowVisible = !WindowVisible)">Toggle Window</TelerikButton>
<TelerikButton OnClick="@OnResetButtonClick">Reset Position</TelerikButton>
<style>
.k-centered.centered-top {
top: 100px;
transform: translate(-50%, -0);
}
</style>
<TelerikWindow @ref="@WindowRef"
Class="centered-top"
@bind-Top="@WindowTop"
@bind-Left="@WindowLeft"
@bind-Visible="@WindowVisible">
<WindowActions>
<WindowAction Name="Minimize" />
<WindowAction Name="Close" />
</WindowActions>
<WindowTitle>
Window Title
</WindowTitle>
<WindowContent>
Window Content
</WindowContent>
</TelerikWindow>
@code {
private TelerikWindow? WindowRef { get; set; }
private bool WindowVisible { get; set; } = true;
private string WindowTop { get; set; } = string.Empty;
private string WindowLeft { get; set; } = string.Empty;
private void OnResetButtonClick()
{
WindowTop = string.Empty;
WindowLeft = string.Empty;
WindowRef!.Refresh();
}
}