about summary refs log tree commit diff
path: root/MatrixRoomUtils.Web/Shared/SimpleComponents/ToggleSlider.razor
blob: 49a363d3738434a368e8d031182411a3b23007d8 (plain) (blame)
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
60
61
62
63
64
65
66
67
68
69
70
<input type="checkbox"/><span>@ChildContent</span>

<div class="container">
    <label class="switch" for="checkbox">
        <input type="checkbox" id="checkbox" @bind="Value"/>
        <div class="slider round"></div>
    </label>
</div>

<style>
    .switch {
      display: inline-block;
      height: 16px;
      position: relative;
      width: 32px;
    }
    
    .switch input {
      display:none;
    }
    
    .slider {
      background-color: #ccc;
      bottom: 0;
      cursor: pointer;
      left: 0;
      position: absolute;
      right: 0;
      top: 0;
      transition: .4s;
    }
    
    .slider:before {
      background-color: #fff;
      bottom: -5px;
      content: "";
      height: 26px;
      left: -8px;
      position: absolute;
      transition: .4s;
      width: 26px;
    }
    
    input:checked + .slider {
      background-color: #66bb6a;
    }
    
    input:checked + .slider:before {
      transform: translateX(24px);
    }
    
    .slider.round {
      border-radius: 24px;
    }
    
    .slider.round:before {
      border-radius: 50%;
    }
</style>

@code {
    [Parameter]
    public RenderFragment? ChildContent { get; set; }
    
    [Parameter]
    public bool Value { get; set; }
    [Parameter]
    public EventCallback<bool> ValueChanged { get; set; }
    
}