
Timer
For time countdown
Set the countdown time by setting the Value
attribute
Demo
- 0
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 0
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 0
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
Set the circular progress bar color by setting the Color
property
Demo
- 0
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 0
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 0
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
Attributes
@page "/timers"
@inject IStringLocalizer<Timers> Localizer
<h3>Timer</h3>
<h4>For time countdown</h4>
<DemoBlock Title="Basic usage" Introduction="Set the countdown time by setting the <code>Value</code> attribute" Name="Normal">
<Timer OnTimeout="@OnTimeout" OnCancel="OnCancel" />
<BlockLogger @ref="Trace" class="mt-3" />
</DemoBlock>
<DemoBlock Title="Color" Introduction="Set the circular progress bar color by setting the <code>Color</code> property" Name="Color">
<Timer Color="Color.Warning" />
</DemoBlock>
<AttributeTable Items="@GetAttributes()" />
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/
namespace BootstrapBlazor.Shared.Samples;
/// <summary>
///
/// </summary>
public sealed partial class Timers
{
[NotNull]
private BlockLogger? Trace { get; set; }
private Task OnTimeout()
{
Trace.Log("timer time up");
return Task.CompletedTask;
}
private Task OnCancel()
{
Trace?.Log("timer canceled");
return Task.CompletedTask;
}
private static IEnumerable<AttributeItem> GetAttributes()
{
return new AttributeItem[]
{
new AttributeItem()
{
Name = "Width",
Description = "Component width",
Type = "int",
ValueList = " — ",
DefaultValue = "300"
},
new AttributeItem()
{
Name = "StrokeWidth",
Description = "Progress bar width",
Type = "int",
ValueList = " — ",
DefaultValue = "6"
},
new AttributeItem()
{
Name = "IsVibrate",
Description = "Device vibrates when countdown ends",
Type = "bool",
ValueList = "true/false",
DefaultValue = "true"
},
new AttributeItem()
{
Name = "Value",
Description = "Countdown time",
Type = "Timespan",
ValueList = " — ",
DefaultValue = " — "
},
new AttributeItem()
{
Name = "Color",
Description = "Progress bar color",
Type = "Color",
ValueList = "Primary / Secondary / Success / Danger / Warning / Info / Dark",
DefaultValue = "Primary"
}
};
}
}