File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 14
14
<div style =" display: flex; align-items: center;" >
15
15
<IconButton class ="material-icons" on:click ={() => clicked ++ } ripple ={false }>add_shopping_cart</IconButton > (no ripple)
16
16
</div >
17
+
18
+ Toggle buttons:
17
19
<div style =" display: flex; align-items: center;" >
18
20
<IconButton on:click ={() => clicked ++ } toggle bind:pressed ={initialOff }>
19
21
<Icon class =" material-icons" on >star</Icon >
20
22
<Icon class =" material-icons" >star_border</Icon >
21
23
</IconButton >
22
- {initialOff ? ' (on)' : ' (off)' }
23
24
</div >
24
25
<div style =" display: flex; align-items: center;" >
25
26
<IconButton on:click ={() => clicked ++ } toggle bind:pressed ={initialOn }>
26
27
<Icon class =" material-icons" on >alarm_on</Icon >
27
28
<Icon class =" material-icons" >alarm_off</Icon >
28
29
</IconButton >
29
- {initialOn ? ' (on)' : ' (off)' }
30
-
31
30
<Button on:click ={() => initialOn = ! initialOn }><Label >Toggle Programmatically</Label ></Button >
32
31
</div >
32
+ <div style =" display: flex; align-items: center;" >
33
+ <IconButton on:click ={() => clicked ++ } on:click ={() => usingEvents = ! usingEvents } pressed ={usingEvents }>
34
+ <Icon class =" material-icons" on >bookmark</Icon >
35
+ <Icon class =" material-icons" >bookmark_border</Icon >
36
+ </IconButton >
37
+ (Using events instead of bound variables. Note: don't use <code >toggle</code > prop in this case.)
38
+ </div >
33
39
34
40
<pre class ="status" >Clicked: {clicked }</pre >
35
41
</section >
41
47
let clicked = 0 ;
42
48
let initialOff = false ;
43
49
let initialOn = true ;
50
+ let usingEvents = false ;
44
51
</script >
You can’t perform that action at this time.
0 commit comments