Skip to content

Commit 0f9a7b4

Browse files
committed
fix(radio): add and document custom properties
references #14850
1 parent 3042f57 commit 0f9a7b4

File tree

5 files changed

+41
-5
lines changed

5 files changed

+41
-5
lines changed

core/src/components/radio/radio.ios.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55
// --------------------------------------------------
66

77
:host {
8+
--color-checked: #{ion-color(primary, base)};
89
--width: #{$radio-ios-icon-width};
910
--height: #{$radio-ios-icon-height};
1011
}
1112

13+
:host(.ion-color.radio-checked) .radio-inner {
14+
border-color: current-color(base);
15+
}
1216

1317
.item-radio.item-ios ion-label {
1418
@include margin-horizontal(0, null);
@@ -32,7 +36,7 @@
3236
border-top-width: 0;
3337
border-left-width: 0;
3438
border-style: $radio-ios-icon-border-style;
35-
border-color: $radio-ios-color-on;
39+
border-color: var(--color-checked);
3640
}
3741

3842

core/src/components/radio/radio.md.scss

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,20 @@
55
// --------------------------------------------------
66

77
:host {
8+
--color: #{$radio-md-color-off};
9+
--color-checked: #{ion-color(primary, base)};
810
--width: #{$radio-md-icon-width};
911
--height: #{$radio-md-icon-height};
1012
}
1113

14+
:host(.ion-color) .radio-inner {
15+
background: current-color(base);
16+
}
17+
18+
:host(.ion-color.radio-checked) .radio-icon {
19+
border-color: current-color(base);
20+
}
21+
1222
// Material Design Radio Outer Circle: Unchecked
1323
// -----------------------------------------
1424

@@ -19,7 +29,7 @@
1929

2030
border-width: $radio-md-icon-border-width;
2131
border-style: $radio-md-icon-border-style;
22-
border-color: $radio-md-color-off;
32+
border-color: var(--color);
2333
}
2434

2535

@@ -39,15 +49,15 @@
3949

4050
transition: transform $radio-md-transition-duration $radio-md-transition-easing;
4151

42-
background-color: $radio-md-color-on;
52+
background: var(--color-checked);
4353
}
4454

4555

4656
// Material Design Radio Outer Circle: Checked
4757
// -----------------------------------------
4858

4959
:host(.radio-checked) .radio-icon {
50-
border-color: $radio-md-color-on;
60+
border-color: var(--color-checked);
5161
}
5262

5363

core/src/components/radio/radio.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
// --------------------------------------------------
55

66
:host {
7-
--ion-color-base: #{ion-color(primary, base)};
7+
/**
8+
* @prop --color: Color of the radio
9+
* @prop --color-checked: Color of the checked radio
10+
*/
811

912
display: inline-block;
1013
position: relative;

core/src/components/radio/readme.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ An `ion-radio-group` can be used to group a set of radios. When radios are insid
3434
| `ionStyle` | Emitted when the styles change. |
3535

3636

37+
## CSS Custom Properties
38+
39+
| Name | Description |
40+
| ----------------- | -------------------------- |
41+
| `--color` | Color of the radio |
42+
| `--color-checked` | Color of the checked radio |
43+
44+
3745
----------------------------------------------
3846

3947
*Built with [StencilJS](https://stenciljs.com/)*

core/src/components/radio/test/standalone/index.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,23 @@
4040
<ion-radio checked color="secondary" disabled></ion-radio>
4141
</p>
4242

43+
<p>
44+
<ion-radio class="custom"></ion-radio>
45+
<ion-radio class="custom" checked></ion-radio>
46+
<ion-radio class="custom" checked color="primary"></ion-radio>
47+
</p>
48+
4349
<style>
4450
/* to be able to see the radio buttons */
4551
.radio-ios {
4652
border: 1px solid #dedede;
4753
padding: 10px 5px;
4854
}
55+
56+
.custom {
57+
--color: orange;
58+
--color-checked: hotpink;
59+
}
4960
</style>
5061
</body>
5162
</html>

0 commit comments

Comments
 (0)