How to change LargeStep property in the Range Slider when changing the window width
Hi,
I use the Interoply library to fetch an event when the width of the window is changed.
Now I want to change the LargeStep property of the Range Slider when the width of the window is smaller then 800 px. This is necessary because there are a lot of steps in my Range Slider which becomes ugly when there is little space.
I am using variable SliderLargeStepValue for the LargeStep property of the Range Slider. The next code is
fetching the change of the window width and changes the
variable SliderLargeStepValue but the Range Slider is not changed:
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await Interoply.RegisterOnResizeListnerAsync(UpdateWidth);
}
}
ValueTask UpdateWidth(int w)
{
width = w;
if (width < 800)
{
SliderLargeStepValue = 10;
}
else
{
SliderLargeStepValue = 5;
}
StateHasChanged();
return ValueTask.CompletedTask;
}
How do I need to change this code to achieve my goal?
Best regards,
Vince
Hi Vince,
Currently we don’t have support for dynamically changing the Ticks properties value of the Blazor Slider component. So, we have considered your requirement as a usability improvement for the Range Slider component. You can track the status of this feature by using the following feedback report link.
Feedback link: https://www.syncfusion.com/feedback/68743/need-to-provide-dynamically-value-changing-support-for-tick-properties-in-the
We will include the feature in our upcoming weekly patch release which was schedule on end of July. We appreciate your patience until then.
You will be informed regarding this once the fix is published.
Regards,
YuvanShankar A
Hi Vince,
Sorry for the inconvenience. The feature “Need to provide dynamically value-changing support for tick properties in the slider" is required to ensure the dynamically changing behavior that maintains the proper rendering in the slider. So, it needs additional time to implement this feature. And the feature will be available in our volume 3 main release. We appreciate your patience and still track the status of this feature using the below feedback link.
Feedback link: https://www.syncfusion.com/feedback/68743/need-to-provide-dynamically-value-changing-support-for-tick-properties-in-the
Regards,
YuvanShankar A
Hi Vince,
We apologize for any inconvenience this may cause. The feature “Need to
provide dynamically value-changing support for tick properties in the slider”
needs to ensure multiple scenarios and needs to prevent the unnecessary
re-render at the component level. So, it needs additional time to implement
this feature. And the feature will be available in our Volume 3 SP release.
Thank you for your understanding, and you can continue to monitor the status of
this feature using the feedback link provided below.
Feedback link: https://www.syncfusion.com/feedback/68743/need-to-provide-dynamically-value-changing-support-for-tick-properties-in-the
Regards,
YuvanShankar A
Hallo,
Can you give me an update about the usability improvement for the Range Slider component to solve the problem?
Best regards,
Vince
Hi Vince,
Sorry for the inconvenience. We have considered “Need to provide dynamically value-changing support for tick properties in the slider” as a uncertain feature from our end, but we do not have any immediate plan to implement this feature. At the planning stage for every release cycle, we review all open features and implement the features based on feature rank, customer requested count and volume wish-list.
The status of implementation can be tracked through the below portal link:
You can also communicate with us regarding the open features any time using the “Contact” option.
Regards,
Priyanka K
Hallo,
Thanks for your reply.
I can understand that this issue has no priority for Suncfusion but I still need a solution or work around. A work around could be a page reload after changing the window width and render the Range Slider with different step settings. Is that possible? If so, do you have a code sample?
Hi Vince,
Thank you for your patience. We’ve prepared a simple demo-level workaround that shows how you can dynamically change the LargeStep property of the Range Slider when the window width changes.
- The LargeStep value is bound to a variable (SliderLargeStepValue) inside the <SliderTicks> tag.
- A JavaScript helper (resizeHelper.js) listens for window resize events and calls back into Blazor using [JSInvokable].
- The UpdateWidth method updates both the width and the SliderLargeStepValue depending on the current window size.
- Finally, StateHasChanged() forces the UI to re-render so the slider ticks reflect the new step size.
[Home.razor]
|
@page "/"
@using Microsoft.JSInterop @inject IJSRuntime JS
<PageTitle>Range Slider Demo</PageTitle>
<SfSlider TValue="int" Min="0" Max="100" Value="50" Step="1" ShowButtons="true"> <SliderTicks Placement="Placement.After" LargeStep="@SliderLargeStepValue" ShowSmallTicks="true" SmallStep="10"> </SliderTicks> </SfSlider>
<p>Current Window Width: @width px</p> <p>Current LargeStep: @SliderLargeStepValue</p>
@code { private int width; private int SliderLargeStepValue = 5;
private DotNetObjectReference<Home>? _dotNetRef;
protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { _dotNetRef = DotNetObjectReference.Create(this); await JS.InvokeVoidAsync("Interoply.RegisterOnResizeListnerAsync", _dotNetRef); } }
[JSInvokable] public Task UpdateWidth(int w) { width = w; if (width < 600) SliderLargeStepValue = 15; else if (width < 800) SliderLargeStepValue = 10; else SliderLargeStepValue = 5; StateHasChanged(); return Task.CompletedTask; } } |
[resizeHelper.js]
|
window.Interoply = { RegisterOnResizeListnerAsync: function (dotNetHelper) { const handler = () => { dotNetHelper.invokeMethodAsync("UpdateWidth", window.innerWidth); }; handler(); window.addEventListener("resize", handler); } }; |
- When the window width is below 800px, the LargeStep becomes 10.
- When the width is 800px or more, the LargeStep resets to 5.
- You can also extend this logic with more conditions if you want different breakpoints (e.g., <600px → 15, <800px → 10, else → 5).
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/BlazorApp1
Gif:
The feature is scheduled to be included by end of January 2026.
Regards,
K N Siddartha.
Hallo,
Thanks for your reply.
In your demo the variable SliderLargeStepValue is changing when I change the windows width. Unfortunetly the visible Steps in the Range Slider component stays the same (all the time 10) and it seems that it is not rerendered when changing the windows width.
What I want to achieve is that the visible rendered steps in the component are 0-10-20-30-40-50-60-70-80-90-100 when the windows width is maximum and 0-20-40-60-80-100 when the windows width is less then 50%.
Is that possible?
Hi Vince,
We understand your requirement to dynamically adjust the visible tick marks on the Range Slider component based on window width changes displaying ticks at 0-10-20-30-40-50-60-70-80-90-100 at full width, and 0-20-40-60-80-100 when the window is at 50% width.
The @key attribute is the recommended solution here. It instructs Blazor to treat the component as a new instance whenever the key value changes, ensuring the slider properly reinitializes with the updated tick configuration.
Here's the refined implementation for your scenario:
[Home.razor]
@page "/"
@using Microsoft.JSInterop @inject IJSRuntime JS @using Syncfusion.Blazor.Inputs
<PageTitle>Range Slider Demo</PageTitle>
<SfSlider TValue="int" @key="SliderLargeStepValue" Min="0" Max="100" Value="50" Step="1" ShowButtons="true"> <SliderTicks Placement="Placement.After" LargeStep="@SliderLargeStepValue"ShowSmallTicks="true" SmallStep="10"> </SliderTicks> </SfSlider>
<p>Current Window Width: @width px</p>
<p>Current LargeStep: @SliderLargeStepValue</p>
@code {
private int width;
private int SliderLargeStepValue = 10; private DotNetObjectReference<Home>? _dotNetRef;
protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { _dotNetRef = DotNetObjectReference.Create(this); await JS.InvokeVoidAsync("Interoply.RegisterOnResizeListnerAsync", _dotNetRef); } }
[JSInvokable] public Task UpdateWidth(int w) { width = w; if (width < 600) SliderLargeStepValue = 30; else if (width < 800) SliderLargeStepValue = 20; else SliderLargeStepValue = 10;
StateHasChanged();
return Task.CompletedTask;
}
} |
This implementation should provide the responsive tick behavior you're looking for. The @key directive ensures the component fully re-renders with the new tick spacing as the window size changes.
For your reference we have included the runnable sample with a gif demonstration below:
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/BlazorApp
Gif:
Regards,
K N Siddartha.
Hallo,
Thanks for your reply.
Your latest code sample works perfect. Thanks a lot!
Hi Vince
Glad to know the issue has been resolved. Please get back to us for assistance in the future.
Regards,
Shereen
- 11 Replies
- 5 Participants
-
VI Vince
- Jul 2, 2025 09:01 AM UTC
- Dec 3, 2025 12:55 PM UTC