This repository was archived by the owner on Jan 13, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +79
-1
lines changed Expand file tree Collapse file tree 5 files changed +79
-1
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,30 @@ <h2>CSS Only</h2>
81
81
< button type ="button " onclick ="document.querySelector('.mdc-form-field').classList.toggle('mdc-form-field--align-end'); "> Toggle Align End</ button >
82
82
< button type ="button " onclick ="document.getElementById('basic-checkbox').disabled = !document.getElementById('basic-checkbox').disabled; "> Toggle Disabled</ button >
83
83
</ section >
84
+
85
+ < section >
86
+ < h2 > CSS Only - Disabled</ h2 >
87
+ < div class ="mdc-form-field ">
88
+ < div class ="mdc-checkbox mdc-checkbox--disabled ">
89
+ < input type ="checkbox "
90
+ id ="basic-disabled-checkbox "
91
+ class ="mdc-checkbox__native-control "
92
+ disabled />
93
+ < div class ="mdc-checkbox__background ">
94
+ < svg class ="mdc-checkbox__checkmark "
95
+ viewBox ="0 0 24 24 ">
96
+ < path class ="mdc-checkbox__checkmark__path "
97
+ fill ="none "
98
+ stroke ="white "
99
+ d ="M1.73,12.91 8.1,19.28 22.79,4.59 "/>
100
+ </ svg >
101
+ < div class ="mdc-checkbox__mixedmark "> </ div >
102
+ </ div >
103
+ </ div >
104
+ < label for ="basic-disabled-checkbox " id ="basic-disabled-checkbox-label "> This is my disabled checkbox</ label >
105
+ </ div >
106
+ </ section >
107
+
84
108
< section >
85
109
< h2 > With Javascript</ h2 >
86
110
< div class ="mdc-form-field ">
Original file line number Diff line number Diff line change @@ -69,6 +69,30 @@ <h2>CSS Only</h2>
69
69
</ div >
70
70
</ section >
71
71
72
+ < section >
73
+ < h2 > CSS Only - Disabled</ h2 >
74
+ < div class ="mdc-form-field ">
75
+ < div class ="mdc-radio mdc-radio--disabled " data-demo-no-js >
76
+ < input class ="mdc-radio__native-control " type ="radio " id ="ex2-radio1 " checked name ="ex2 " disabled >
77
+ < div class ="mdc-radio__background ">
78
+ < div class ="mdc-radio__outer-circle "> </ div >
79
+ < div class ="mdc-radio__inner-circle "> </ div >
80
+ </ div >
81
+ </ div >
82
+ < label id ="ex2-radio1-label " for ="ex2-radio1 "> Radio 1</ label >
83
+ </ div >
84
+ < div class ="mdc-form-field ">
85
+ < div class ="mdc-radio mdc-radio--disabled " data-demo-no-js >
86
+ < input class ="mdc-radio__native-control " type ="radio " id ="ex2-radio2 " name ="ex2 " disabled >
87
+ < div class ="mdc-radio__background ">
88
+ < div class ="mdc-radio__outer-circle "> </ div >
89
+ < div class ="mdc-radio__inner-circle "> </ div >
90
+ </ div >
91
+ </ div >
92
+ < label id ="ex2-radio2-label " for ="ex2-radio2 "> Radio 2</ label >
93
+ </ div >
94
+ </ section >
95
+
72
96
< section >
73
97
< h2 > With Javascript</ h2 >
74
98
< div class ="mdc-form-field ">
Original file line number Diff line number Diff line change @@ -63,6 +63,30 @@ easily position checkboxes and their labels.
63
63
</div >
64
64
```
65
65
66
+ #### Disabled Checkboxes
67
+
68
+ ``` html
69
+ <div class =" mdc-checkbox mdc-checkbox--disabled" >
70
+ <input type =" checkbox"
71
+ id =" basic-disabled-checkbox"
72
+ class =" mdc-checkbox__native-control"
73
+ disabled />
74
+ <div class =" mdc-checkbox__background" >
75
+ <svg class =" mdc-checkbox__checkmark"
76
+ viewBox =" 0 0 24 24" >
77
+ <path class =" mdc-checkbox__checkmark__path"
78
+ fill =" none"
79
+ stroke =" white"
80
+ d =" M1.73,12.91 8.1,19.28 22.79,4.59" />
81
+ </svg >
82
+ <div class =" mdc-checkbox__mixedmark" ></div >
83
+ </div >
84
+ </div >
85
+ <label for =" basic-disabled-checkbox" id =" basic-disabled-checkbox-label" >This is my disabled checkbox</label >
86
+ ```
87
+
88
+ Note that ` mdc-checkbox--disabled ` is necessary on the root element to prevent hover states from activating.
89
+
66
90
### Using the JS Component
67
91
68
92
MDC Checkbox ships with a Component / Foundation combo which progressively enhances the checkbox
Original file line number Diff line number Diff line change @@ -252,6 +252,11 @@ fieldset:disabled .mdc-checkbox__native-control,
252
252
}
253
253
}
254
254
255
+ .mdc-checkbox--disabled {
256
+ cursor : default ;
257
+ pointer-events : none ;
258
+ }
259
+
255
260
.mdc-checkbox--upgraded {
256
261
.mdc-checkbox__background ,
257
262
.mdc-checkbox__checkmark ,
Original file line number Diff line number Diff line change @@ -48,7 +48,8 @@ npm install --save @material/radio
48
48
```
49
49
50
50
Note that ` mdc-radio--disabled ` is necessary on the root element in order to avoid having the ripple
51
- elements intercept pointer events when using JS.
51
+ elements intercept pointer events when using JS. When using the CSS-only variation, this is also
52
+ necessary to prevent hover states from activating.
52
53
53
54
### Using the JS Component
54
55
You can’t perform that action at this time.
0 commit comments