x
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<div class="midwest-rating size-default" role="radiogroup" aria-label="Rating" data-controller=midwest-rating> <input class="midwest-rating__input sr-only" type="radio" name="playground_rating" id="playground_rating-1" value="1" > <label class="midwest-rating__label" for="playground_rating-1" data-midwest-rating-target="star" data-value="1" data-action="mouseenter->midwest-rating#preview mouseleave->midwest-rating#resetPreview click->midwest-rating#select"> <span class="sr-only">1 star</span> <span class="midwest-rating__icon" aria-hidden="true"> <div class="midwest-icon " aria-hidden="true"> <div class="midwest-icon-inner"> <svg xmlns="http://www.w3.org/2000/svg" class="Midwest-Icon__Svg" viewbox="0 0 512 512" focusable="false" aria-hidden="true"><path d="M480 208H308L256 48l-52 160H32l140 96-54 160 138-100 138 100-54-160z" fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32"></path></svg> </div> </div> </span> <span class="midwest-rating__icon midwest-rating__icon--filled" aria-hidden="true"> <div class="midwest-icon " aria-hidden="true"> <div class="midwest-icon-inner"> <svg xmlns="http://www.w3.org/2000/svg" class="Midwest-Icon__Svg" viewbox="0 0 512 512" focusable="false" aria-hidden="true"><path d="M394 480a16 16 0 01-9.39-3L256 383.76 127.39 477a16 16 0 01-24.55-18.08L153 310.35 23 221.2a16 16 0 019-29.2h160.38l48.4-148.95a16 16 0 0130.44 0l48.4 149H480a16 16 0 019.05 29.2L359 310.35l50.13 148.53A16 16 0 01394 480z"></path></svg> </div> </div> </span> </label> <input class="midwest-rating__input sr-only" type="radio" name="playground_rating" id="playground_rating-2" value="2" > <label class="midwest-rating__label" for="playground_rating-2" data-midwest-rating-target="star" data-value="2" data-action="mouseenter->midwest-rating#preview mouseleave->midwest-rating#resetPreview click->midwest-rating#select"> <span class="sr-only">2 stars</span> <span class="midwest-rating__icon" aria-hidden="true"> <div class="midwest-icon " aria-hidden="true"> <div class="midwest-icon-inner"> <svg xmlns="http://www.w3.org/2000/svg" class="Midwest-Icon__Svg" viewbox="0 0 512 512" focusable="false" aria-hidden="true"><path d="M480 208H308L256 48l-52 160H32l140 96-54 160 138-100 138 100-54-160z" fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32"></path></svg> </div> </div> </span> <span class="midwest-rating__icon midwest-rating__icon--filled" aria-hidden="true"> <div class="midwest-icon " aria-hidden="true"> <div class="midwest-icon-inner"> <svg xmlns="http://www.w3.org/2000/svg" class="Midwest-Icon__Svg" viewbox="0 0 512 512" focusable="false" aria-hidden="true"><path d="M394 480a16 16 0 01-9.39-3L256 383.76 127.39 477a16 16 0 01-24.55-18.08L153 310.35 23 221.2a16 16 0 019-29.2h160.38l48.4-148.95a16 16 0 0130.44 0l48.4 149H480a16 16 0 019.05 29.2L359 310.35l50.13 148.53A16 16 0 01394 480z"></path></svg> </div> </div> </span> </label> <input class="midwest-rating__input sr-only" type="radio" name="playground_rating" id="playground_rating-3" value="3" > <label class="midwest-rating__label" for="playground_rating-3" data-midwest-rating-target="star" data-value="3" data-action="mouseenter->midwest-rating#preview mouseleave->midwest-rating#resetPreview click->midwest-rating#select"> <span class="sr-only">3 stars</span> <span class="midwest-rating__icon" aria-hidden="true"> <div class="midwest-icon " aria-hidden="true"> <div class="midwest-icon-inner"> <svg xmlns="http://www.w3.org/2000/svg" class="Midwest-Icon__Svg" viewbox="0 0 512 512" focusable="false" aria-hidden="true"><path d="M480 208H308L256 48l-52 160H32l140 96-54 160 138-100 138 100-54-160z" fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32"></path></svg> </div> </div> </span> <span class="midwest-rating__icon midwest-rating__icon--filled" aria-hidden="true"> <div class="midwest-icon " aria-hidden="true"> <div class="midwest-icon-inner"> <svg xmlns="http://www.w3.org/2000/svg" class="Midwest-Icon__Svg" viewbox="0 0 512 512" focusable="false" aria-hidden="true"><path d="M394 480a16 16 0 01-9.39-3L256 383.76 127.39 477a16 16 0 01-24.55-18.08L153 310.35 23 221.2a16 16 0 019-29.2h160.38l48.4-148.95a16 16 0 0130.44 0l48.4 149H480a16 16 0 019.05 29.2L359 310.35l50.13 148.53A16 16 0 01394 480z"></path></svg> </div> </div> </span> </label> <input class="midwest-rating__input sr-only" type="radio" name="playground_rating" id="playground_rating-4" value="4" > <label class="midwest-rating__label" for="playground_rating-4" data-midwest-rating-target="star" data-value="4" data-action="mouseenter->midwest-rating#preview mouseleave->midwest-rating#resetPreview click->midwest-rating#select"> <span class="sr-only">4 stars</span> <span class="midwest-rating__icon" aria-hidden="true"> <div class="midwest-icon " aria-hidden="true"> <div class="midwest-icon-inner"> <svg xmlns="http://www.w3.org/2000/svg" class="Midwest-Icon__Svg" viewbox="0 0 512 512" focusable="false" aria-hidden="true"><path d="M480 208H308L256 48l-52 160H32l140 96-54 160 138-100 138 100-54-160z" fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32"></path></svg> </div> </div> </span> <span class="midwest-rating__icon midwest-rating__icon--filled" aria-hidden="true"> <div class="midwest-icon " aria-hidden="true"> <div class="midwest-icon-inner"> <svg xmlns="http://www.w3.org/2000/svg" class="Midwest-Icon__Svg" viewbox="0 0 512 512" focusable="false" aria-hidden="true"><path d="M394 480a16 16 0 01-9.39-3L256 383.76 127.39 477a16 16 0 01-24.55-18.08L153 310.35 23 221.2a16 16 0 019-29.2h160.38l48.4-148.95a16 16 0 0130.44 0l48.4 149H480a16 16 0 019.05 29.2L359 310.35l50.13 148.53A16 16 0 01394 480z"></path></svg> </div> </div> </span> </label> <input class="midwest-rating__input sr-only" type="radio" name="playground_rating" id="playground_rating-5" value="5" > <label class="midwest-rating__label" for="playground_rating-5" data-midwest-rating-target="star" data-value="5" data-action="mouseenter->midwest-rating#preview mouseleave->midwest-rating#resetPreview click->midwest-rating#select"> <span class="sr-only">5 stars</span> <span class="midwest-rating__icon" aria-hidden="true"> <div class="midwest-icon " aria-hidden="true"> <div class="midwest-icon-inner"> <svg xmlns="http://www.w3.org/2000/svg" class="Midwest-Icon__Svg" viewbox="0 0 512 512" focusable="false" aria-hidden="true"><path d="M480 208H308L256 48l-52 160H32l140 96-54 160 138-100 138 100-54-160z" fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32"></path></svg> </div> </div> </span> <span class="midwest-rating__icon midwest-rating__icon--filled" aria-hidden="true"> <div class="midwest-icon " aria-hidden="true"> <div class="midwest-icon-inner"> <svg xmlns="http://www.w3.org/2000/svg" class="Midwest-Icon__Svg" viewbox="0 0 512 512" focusable="false" aria-hidden="true"><path d="M394 480a16 16 0 01-9.39-3L256 383.76 127.39 477a16 16 0 01-24.55-18.08L153 310.35 23 221.2a16 16 0 019-29.2h160.38l48.4-148.95a16 16 0 0130.44 0l48.4 149H480a16 16 0 019.05 29.2L359 310.35l50.13 148.53A16 16 0 01394 480z"></path></svg> </div> </div> </span> </label></div>1
2
3
4
5
6
7
8
<%= midwest_rating( name: "playground_rating", value: params[:value].presence&.to_f, max: params[:max].presence&.to_i || 5, readonly: params[:readonly] == true, size: params[:size]&.to_sym || :default, label: params[:label].presence || "Rating") %>Playground
Explore the component with live parameters.
| Param | Description | Input |
|---|---|---|
|
Initial selected value |
|
|
|
Number of stars |
|
|
|
Display-only mode |
|
|
|
Size |
|
|
|
Accessible label for the radiogroup |
|
No assets to display.
Add a .js or .css file alongside the component to see it here.
Figma embed for Rating/playground
Annotate a preview to embed its Figma design here:
@figma "https://figma.com/..."