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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
<div class="flex flex-col gap-8 p-8 max-w-2xl"> <div> <h3 class="text-sm font-medium text-gray-11 mb-2">Rouge theme (default)</h3> <article data-controller="midwest-card midwest-code-block" class="midwest-card padding-none midwest-code-block theme-rouge"> <div class="wrap"> <header class="flex px-4"> <div class="code-block-meta"> <span class="midwest-badge size-sm theme-primary"> <span class="value">ruby</span> </span> </div> <span class="midwest-tooltip" data-controller="midwest-tooltip"> <span id="tooltip-trigger-de00" class="midwest-tooltip-trigger" style="anchor-name: --tooltip-de00" data-action="mouseenter->midwest-tooltip#show mouseleave->midwest-tooltip#hide focus->midwest-tooltip#show blur->midwest-tooltip#hide" aria-describedby="tooltip-de00"> <button aria-label="Copy code" data-action="midwest-code-block#copy" class="midwest-button variant-ghost size-small theme-primary code-block-copy" name="button"> <span class="midwest-button-content"> <span class="copy-icon"> <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="M368 48h-11.41a8 8 0 01-7.44-5.08A42.18 42.18 0 00309.87 16H202.13a42.18 42.18 0 00-39.28 26.92 8 8 0 01-7.44 5.08H144a64 64 0 00-64 64v320a64 64 0 0064 64h224a64 64 0 0064-64V112a64 64 0 00-64-64zm-48.13 64H192.13a16 16 0 010-32h127.74a16 16 0 010 32z"></path></svg> </div> </div> </span> <span class="check-icon"> <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 fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M416 128L192 384l-96-96"></path></svg> </div> </div> </span> </span> <div class="midwest-loading-icon" role="img" aria-label="Loading" aria-hidden="true" style="display: none"> <div class="midwest-loading-icon-inner"> <!-- By Sam Herbert (@sherb), for everyone. More @ http://goo.gl/7AJzbL --> <svg viewbox="0 0 120 30" xmlns="http://www.w3.org/2000/svg" fill="currentColor" class="Midwest-LoadingIcon__Svg" focusable="false" aria-hidden="true"> <circle cx="15" cy="15" r="15"> <animate attributename="r" from="15" to="15" begin="0s" dur="0.8s" values="15;9;15" calcmode="linear" repeatcount="indefinite"></animate> <animate attributename="fill-opacity" from="1" to="1" begin="0s" dur="0.8s" values="1;.5;1" calcmode="linear" repeatcount="indefinite"></animate> </circle> <circle cx="60" cy="15" r="9" fill-opacity="0.3"> <animate attributename="r" from="9" to="9" begin="0s" dur="0.8s" values="9;15;9" calcmode="linear" repeatcount="indefinite"></animate> <animate attributename="fill-opacity" from="0.5" to="0.5" begin="0s" dur="0.8s" values=".5;1;.5" calcmode="linear" repeatcount="indefinite"></animate> </circle> <circle cx="105" cy="15" r="15"> <animate attributename="r" from="15" to="15" begin="0s" dur="0.8s" values="15;9;15" calcmode="linear" repeatcount="indefinite"></animate> <animate attributename="fill-opacity" from="1" to="1" begin="0s" dur="0.8s" values="1;.5;1" calcmode="linear" repeatcount="indefinite"></animate> </circle> </svg> </div> </div> </button> </span> <span id="tooltip-de00" popover="manual" role="tooltip" class="midwest-tooltip-popover placement-top" style="position-anchor: --tooltip-de00" data-midwest-tooltip-target="popover"> Copy code </span></span></header> <section> <div class="code-block-body" data-midwest-code-block-target="source"> <pre class="highlight"><code><span class="k">class</span> <span class="nc">Greeting</span> <span class="k">def</span> <span class="nf">initialize</span><span class="p">(</span><span class="nb">name</span><span class="p">)</span> <span class="vi">@name</span> <span class="o">=</span> <span class="nb">name</span> <span class="k">end</span> <span class="k">def</span> <span class="nf">say</span> <span class="nb">puts</span> <span class="s2">"Hello, </span><span class="si">#{</span><span class="vi">@name</span><span class="si">}</span><span class="s2">!"</span> <span class="c1"># prints greeting</span> <span class="k">end</span><span class="k">end</span><span class="no">Greeting</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="s2">"world"</span><span class="p">).</span><span class="nf">say</span></code></pre> </div> </section> </div> </article> </div> <div> <h3 class="text-sm font-medium text-gray-11 mb-2">Midwest theme</h3> <article data-controller="midwest-card midwest-code-block" class="midwest-card padding-none midwest-code-block theme-midwest"> <div class="wrap"> <header class="flex px-4"> <div class="code-block-meta"> <span class="midwest-badge size-sm theme-primary"> <span class="value">ruby</span> </span> </div> <span class="midwest-tooltip" data-controller="midwest-tooltip"> <span id="tooltip-trigger-de08" class="midwest-tooltip-trigger" style="anchor-name: --tooltip-de08" data-action="mouseenter->midwest-tooltip#show mouseleave->midwest-tooltip#hide focus->midwest-tooltip#show blur->midwest-tooltip#hide" aria-describedby="tooltip-de08"> <button aria-label="Copy code" data-action="midwest-code-block#copy" class="midwest-button variant-ghost size-small theme-primary code-block-copy" name="button"> <span class="midwest-button-content"> <span class="copy-icon"> <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="M368 48h-11.41a8 8 0 01-7.44-5.08A42.18 42.18 0 00309.87 16H202.13a42.18 42.18 0 00-39.28 26.92 8 8 0 01-7.44 5.08H144a64 64 0 00-64 64v320a64 64 0 0064 64h224a64 64 0 0064-64V112a64 64 0 00-64-64zm-48.13 64H192.13a16 16 0 010-32h127.74a16 16 0 010 32z"></path></svg> </div> </div> </span> <span class="check-icon"> <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 fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M416 128L192 384l-96-96"></path></svg> </div> </div> </span> </span> <div class="midwest-loading-icon" role="img" aria-label="Loading" aria-hidden="true" style="display: none"> <div class="midwest-loading-icon-inner"> <!-- By Sam Herbert (@sherb), for everyone. More @ http://goo.gl/7AJzbL --> <svg viewbox="0 0 120 30" xmlns="http://www.w3.org/2000/svg" fill="currentColor" class="Midwest-LoadingIcon__Svg" focusable="false" aria-hidden="true"> <circle cx="15" cy="15" r="15"> <animate attributename="r" from="15" to="15" begin="0s" dur="0.8s" values="15;9;15" calcmode="linear" repeatcount="indefinite"></animate> <animate attributename="fill-opacity" from="1" to="1" begin="0s" dur="0.8s" values="1;.5;1" calcmode="linear" repeatcount="indefinite"></animate> </circle> <circle cx="60" cy="15" r="9" fill-opacity="0.3"> <animate attributename="r" from="9" to="9" begin="0s" dur="0.8s" values="9;15;9" calcmode="linear" repeatcount="indefinite"></animate> <animate attributename="fill-opacity" from="0.5" to="0.5" begin="0s" dur="0.8s" values=".5;1;.5" calcmode="linear" repeatcount="indefinite"></animate> </circle> <circle cx="105" cy="15" r="15"> <animate attributename="r" from="15" to="15" begin="0s" dur="0.8s" values="15;9;15" calcmode="linear" repeatcount="indefinite"></animate> <animate attributename="fill-opacity" from="1" to="1" begin="0s" dur="0.8s" values="1;.5;1" calcmode="linear" repeatcount="indefinite"></animate> </circle> </svg> </div> </div> </button> </span> <span id="tooltip-de08" popover="manual" role="tooltip" class="midwest-tooltip-popover placement-top" style="position-anchor: --tooltip-de08" data-midwest-tooltip-target="popover"> Copy code </span></span></header> <section> <div class="code-block-body" data-midwest-code-block-target="source"> <pre class="highlight"><code><span class="k">class</span> <span class="nc">Greeting</span> <span class="k">def</span> <span class="nf">initialize</span><span class="p">(</span><span class="nb">name</span><span class="p">)</span> <span class="vi">@name</span> <span class="o">=</span> <span class="nb">name</span> <span class="k">end</span> <span class="k">def</span> <span class="nf">say</span> <span class="nb">puts</span> <span class="s2">"Hello, </span><span class="si">#{</span><span class="vi">@name</span><span class="si">}</span><span class="s2">!"</span> <span class="c1"># prints greeting</span> <span class="k">end</span><span class="k">end</span><span class="no">Greeting</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="s2">"world"</span><span class="p">).</span><span class="nf">say</span></code></pre> </div> </section> </div> </article> </div> <div class="theme-green"> <h3 class="text-sm font-medium text-gray-11 mb-2">Midwest theme (with <code>.theme-green</code>)</h3> <article data-controller="midwest-card midwest-code-block" class="midwest-card padding-none midwest-code-block theme-midwest"> <div class="wrap"> <header class="flex px-4"> <div class="code-block-meta"> <span class="midwest-badge size-sm theme-primary"> <span class="value">ruby</span> </span> </div> <span class="midwest-tooltip" data-controller="midwest-tooltip"> <span id="tooltip-trigger-de10" class="midwest-tooltip-trigger" style="anchor-name: --tooltip-de10" data-action="mouseenter->midwest-tooltip#show mouseleave->midwest-tooltip#hide focus->midwest-tooltip#show blur->midwest-tooltip#hide" aria-describedby="tooltip-de10"> <button aria-label="Copy code" data-action="midwest-code-block#copy" class="midwest-button variant-ghost size-small theme-primary code-block-copy" name="button"> <span class="midwest-button-content"> <span class="copy-icon"> <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="M368 48h-11.41a8 8 0 01-7.44-5.08A42.18 42.18 0 00309.87 16H202.13a42.18 42.18 0 00-39.28 26.92 8 8 0 01-7.44 5.08H144a64 64 0 00-64 64v320a64 64 0 0064 64h224a64 64 0 0064-64V112a64 64 0 00-64-64zm-48.13 64H192.13a16 16 0 010-32h127.74a16 16 0 010 32z"></path></svg> </div> </div> </span> <span class="check-icon"> <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 fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M416 128L192 384l-96-96"></path></svg> </div> </div> </span> </span> <div class="midwest-loading-icon" role="img" aria-label="Loading" aria-hidden="true" style="display: none"> <div class="midwest-loading-icon-inner"> <!-- By Sam Herbert (@sherb), for everyone. More @ http://goo.gl/7AJzbL --> <svg viewbox="0 0 120 30" xmlns="http://www.w3.org/2000/svg" fill="currentColor" class="Midwest-LoadingIcon__Svg" focusable="false" aria-hidden="true"> <circle cx="15" cy="15" r="15"> <animate attributename="r" from="15" to="15" begin="0s" dur="0.8s" values="15;9;15" calcmode="linear" repeatcount="indefinite"></animate> <animate attributename="fill-opacity" from="1" to="1" begin="0s" dur="0.8s" values="1;.5;1" calcmode="linear" repeatcount="indefinite"></animate> </circle> <circle cx="60" cy="15" r="9" fill-opacity="0.3"> <animate attributename="r" from="9" to="9" begin="0s" dur="0.8s" values="9;15;9" calcmode="linear" repeatcount="indefinite"></animate> <animate attributename="fill-opacity" from="0.5" to="0.5" begin="0s" dur="0.8s" values=".5;1;.5" calcmode="linear" repeatcount="indefinite"></animate> </circle> <circle cx="105" cy="15" r="15"> <animate attributename="r" from="15" to="15" begin="0s" dur="0.8s" values="15;9;15" calcmode="linear" repeatcount="indefinite"></animate> <animate attributename="fill-opacity" from="1" to="1" begin="0s" dur="0.8s" values="1;.5;1" calcmode="linear" repeatcount="indefinite"></animate> </circle> </svg> </div> </div> </button> </span> <span id="tooltip-de10" popover="manual" role="tooltip" class="midwest-tooltip-popover placement-top" style="position-anchor: --tooltip-de10" data-midwest-tooltip-target="popover"> Copy code </span></span></header> <section> <div class="code-block-body" data-midwest-code-block-target="source"> <pre class="highlight"><code><span class="k">class</span> <span class="nc">Greeting</span> <span class="k">def</span> <span class="nf">initialize</span><span class="p">(</span><span class="nb">name</span><span class="p">)</span> <span class="vi">@name</span> <span class="o">=</span> <span class="nb">name</span> <span class="k">end</span> <span class="k">def</span> <span class="nf">say</span> <span class="nb">puts</span> <span class="s2">"Hello, </span><span class="si">#{</span><span class="vi">@name</span><span class="si">}</span><span class="s2">!"</span> <span class="c1"># prints greeting</span> <span class="k">end</span><span class="k">end</span><span class="no">Greeting</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="s2">"world"</span><span class="p">).</span><span class="nf">say</span></code></pre> </div> </section> </div> </article> </div> <div class="theme-purple"> <h3 class="text-sm font-medium text-gray-11 mb-2">Midwest theme (with <code>.theme-purple</code>)</h3> <article data-controller="midwest-card midwest-code-block" class="midwest-card padding-none midwest-code-block theme-midwest"> <div class="wrap"> <header class="flex px-4"> <div class="code-block-meta"> <span class="midwest-badge size-sm theme-primary"> <span class="value">ruby</span> </span> </div> <span class="midwest-tooltip" data-controller="midwest-tooltip"> <span id="tooltip-trigger-de18" class="midwest-tooltip-trigger" style="anchor-name: --tooltip-de18" data-action="mouseenter->midwest-tooltip#show mouseleave->midwest-tooltip#hide focus->midwest-tooltip#show blur->midwest-tooltip#hide" aria-describedby="tooltip-de18"> <button aria-label="Copy code" data-action="midwest-code-block#copy" class="midwest-button variant-ghost size-small theme-primary code-block-copy" name="button"> <span class="midwest-button-content"> <span class="copy-icon"> <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="M368 48h-11.41a8 8 0 01-7.44-5.08A42.18 42.18 0 00309.87 16H202.13a42.18 42.18 0 00-39.28 26.92 8 8 0 01-7.44 5.08H144a64 64 0 00-64 64v320a64 64 0 0064 64h224a64 64 0 0064-64V112a64 64 0 00-64-64zm-48.13 64H192.13a16 16 0 010-32h127.74a16 16 0 010 32z"></path></svg> </div> </div> </span> <span class="check-icon"> <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 fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M416 128L192 384l-96-96"></path></svg> </div> </div> </span> </span> <div class="midwest-loading-icon" role="img" aria-label="Loading" aria-hidden="true" style="display: none"> <div class="midwest-loading-icon-inner"> <!-- By Sam Herbert (@sherb), for everyone. More @ http://goo.gl/7AJzbL --> <svg viewbox="0 0 120 30" xmlns="http://www.w3.org/2000/svg" fill="currentColor" class="Midwest-LoadingIcon__Svg" focusable="false" aria-hidden="true"> <circle cx="15" cy="15" r="15"> <animate attributename="r" from="15" to="15" begin="0s" dur="0.8s" values="15;9;15" calcmode="linear" repeatcount="indefinite"></animate> <animate attributename="fill-opacity" from="1" to="1" begin="0s" dur="0.8s" values="1;.5;1" calcmode="linear" repeatcount="indefinite"></animate> </circle> <circle cx="60" cy="15" r="9" fill-opacity="0.3"> <animate attributename="r" from="9" to="9" begin="0s" dur="0.8s" values="9;15;9" calcmode="linear" repeatcount="indefinite"></animate> <animate attributename="fill-opacity" from="0.5" to="0.5" begin="0s" dur="0.8s" values=".5;1;.5" calcmode="linear" repeatcount="indefinite"></animate> </circle> <circle cx="105" cy="15" r="15"> <animate attributename="r" from="15" to="15" begin="0s" dur="0.8s" values="15;9;15" calcmode="linear" repeatcount="indefinite"></animate> <animate attributename="fill-opacity" from="1" to="1" begin="0s" dur="0.8s" values="1;.5;1" calcmode="linear" repeatcount="indefinite"></animate> </circle> </svg> </div> </div> </button> </span> <span id="tooltip-de18" popover="manual" role="tooltip" class="midwest-tooltip-popover placement-top" style="position-anchor: --tooltip-de18" data-midwest-tooltip-target="popover"> Copy code </span></span></header> <section> <div class="code-block-body" data-midwest-code-block-target="source"> <pre class="highlight"><code><span class="k">class</span> <span class="nc">Greeting</span> <span class="k">def</span> <span class="nf">initialize</span><span class="p">(</span><span class="nb">name</span><span class="p">)</span> <span class="vi">@name</span> <span class="o">=</span> <span class="nb">name</span> <span class="k">end</span> <span class="k">def</span> <span class="nf">say</span> <span class="nb">puts</span> <span class="s2">"Hello, </span><span class="si">#{</span><span class="vi">@name</span><span class="si">}</span><span class="s2">!"</span> <span class="c1"># prints greeting</span> <span class="k">end</span><span class="k">end</span><span class="no">Greeting</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="s2">"world"</span><span class="p">).</span><span class="nf">say</span></code></pre> </div> </section> </div> </article> </div></div>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
<%ruby_code = <<~RUBY class Greeting def initialize(name) @name = name end def say puts "Hello, \#{@name}!" # prints greeting end end Greeting.new("world").sayRUBY%><div class="flex flex-col gap-8 p-8 max-w-2xl"> <div> <h3 class="text-sm font-medium text-gray-11 mb-2">Rouge theme (default)</h3> <%= render Midwest::CodeBlockComponent.new(ruby_code, language: :ruby, theme: :rouge) %> </div> <div> <h3 class="text-sm font-medium text-gray-11 mb-2">Midwest theme</h3> <%= render Midwest::CodeBlockComponent.new(ruby_code, language: :ruby, theme: :midwest) %> </div> <div class="theme-green"> <h3 class="text-sm font-medium text-gray-11 mb-2">Midwest theme (with <code>.theme-green</code>)</h3> <%= render Midwest::CodeBlockComponent.new(ruby_code, language: :ruby, theme: :midwest) %> </div> <div class="theme-purple"> <h3 class="text-sm font-medium text-gray-11 mb-2">Midwest theme (with <code>.theme-purple</code>)</h3> <%= render Midwest::CodeBlockComponent.new(ruby_code, language: :ruby, theme: :midwest) %> </div></div>Themes
Use theme: :rouge for the default GitHub/Monokai theme, or
theme: :midwest to use the design system's theme/complement colors.
No params configured.
No assets to display.
Add a .js or .css file alongside the component to see it here.
Figma embed for Code Block/themes
Annotate a preview to embed its Figma design here:
@figma "https://figma.com/..."