UNPKG

3.83 kBSCSSView Raw
1@import '../../css/variables';
2@import '../../css/mixins';
3@import '../../css/icons';
4@import 'css/variables';
5@import 'css/colors';
6@import 'css/sizes';
7
8.radio {
9 position: relative;
10 display: inline-flex;
11 align-items: center;
12 white-space: nowrap;
13 outline: none;
14 cursor: pointer;
15 margin-right: var(----margin-right);
16
17 &:last-child {
18 margin-right: 0;
19 }
20
21 input {
22 top: 0;
23 left: 0;
24 position: absolute;
25 z-index: 0; // Put the input behind the label so it doesn't overlay text
26 opacity: 0;
27 height: 0;
28 width: 0;
29
30 &:focus,
31 &:active {
32 outline: none;
33 }
34
35 &:checked {
36 ~ .radio-label {
37 &::before {
38 ----border-color: var(----border-color--checked);
39 ----background: var(----background--checked);
40 }
41
42 &::after {
43 content: '';
44 mask-image: url($ink-circle);
45 mask-position: center center;
46 mask-repeat: no-repeat;
47 }
48 }
49 }
50
51 &:disabled,
52 &[readonly] {
53 ~ .radio-label {
54 ----label--color: var(----label--color--disabled);
55 }
56
57 &:checked {
58 ~ .radio-label {
59 &::before {
60 ----border-color: var(----border-color--checked-disabled);
61 ----background: var(----background--checked-disabled);
62 }
63
64 &::after {
65 ----background: var(----color--disabled);
66 }
67 }
68 }
69 }
70 }
71
72 .radio-label {
73 margin-bottom: 0;
74 display: inline-flex;
75 align-items: center;
76 position: relative;
77 transition-property: color;
78 transition-duration: var(--transition-duration);
79 transition-timing-function: var(--transition-easing);
80 color: var(----label--color);
81 font-size: var(----label--font-size);
82
83 &::before,
84 &::after {
85 display: inline-flex;
86 justify-content: center;
87 align-items: center;
88 cursor: pointer;
89 width: var(----size);
90 height: var(----size);
91 }
92
93 &::before {
94 border-radius: 100%;
95 content: "";
96 user-select: none;
97 transition-property: background-color, border-color;
98 transition-duration: var(--transition-duration);
99 transition-timing-function: var(--transition-easing);
100 margin-right: var(----margin-right);
101 border-color: var(----border-color);
102 border-style: var(----border-style);
103 border-width: var(----border-width);
104 background-color: var(----background);
105 }
106
107 &::after {
108 position: absolute;
109 top: 50%;
110 left: 0;
111 z-index: 1;
112 text-align: center;
113 background-color: var(----color);
114 margin-top: calc(#{var(----size)} / -2);
115 mask-size: var(----checkmark--size) var(----checkmark--size);
116 }
117 }
118
119 &.-disabled {
120 cursor: default;
121
122 .radio-label {
123 &::before,
124 &::after {
125 cursor: default;
126 }
127 }
128 }
129
130 &.-native {
131 input {
132 top: auto;
133 left: auto;
134 position: relative;
135 opacity: 1;
136 height: auto;
137 width: auto;
138 margin-right: var(----margin-right);
139 }
140
141 .radio-label {
142 &::after,
143 &::before {
144 display: none;
145 }
146 }
147 }
148}