Formatting in Blazor Range Slider Component
9 Jan 20251 minute to read
The Format
feature is used to customize the display of Slider values in a desired format. This formatting applies to the slider ticks, tooltip, and ARIA attributes. The Format
property can be set for both SliderTicks
and SliderTooltip
to achieve consistent formatting across the Slider component.
NOTE
Use the
Format
API of slider which utilizes our Internationalization to format values.
@using Syncfusion.Blazor.Inputs
<SfSlider @bind-Value="@CurrencyValue">
<SliderTooltip IsVisible="true" ShowOn="TooltipShowOn.Always" Format="C2" Placement="TooltipPlacement.Before"></SliderTooltip>
<SliderTicks Placement="Placement.Before" Format="C2" ShowSmallTicks="true" LargeStep="20" SmallStep="10"></SliderTicks>
</SfSlider>
@code {
int CurrencyValue = 30;
}
Using format API
Slider provides different predefined formatting styles like Numeric (N), Percentage (P), Currency (C) and # specifiers.
@using Syncfusion.Blazor.Inputs
<SfSlider Min="1" Max="10" @bind-Value="@PercentageValue">
<SliderTicks Placement="Placement.After" Format="P0" ShowSmallTicks="true" LargeStep="2" SmallStep="1"></SliderTicks>
<SliderTooltip IsVisible="true" ShowOn="TooltipShowOn.Always" Format="P0" Placement="TooltipPlacement.Before"></SliderTooltip>
</SfSlider>
@code {
int PercentageValue = 3;
}