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
<div class="flex flex-col gap-6 p-8 max-w-2xl"> <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-11b00" class="midwest-tooltip-trigger" style="anchor-name: --tooltip-11b00" data-action="mouseenter->midwest-tooltip#show mouseleave->midwest-tooltip#hide focus->midwest-tooltip#show blur->midwest-tooltip#hide" aria-describedby="tooltip-11b00"> <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-11b00" popover="manual" role="tooltip" class="midwest-tooltip-popover placement-top" style="position-anchor: --tooltip-11b00" 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">User</span> <span class="o"><</span> <span class="no">ApplicationRecord</span> <span class="n">validates</span> <span class="ss">:name</span><span class="p">,</span> <span class="ss">presence: </span><span class="kp">true</span> <span class="n">validates</span> <span class="ss">:email</span><span class="p">,</span> <span class="ss">format: </span><span class="p">{</span> <span class="ss">with: </span><span class="no">URI</span><span class="o">::</span><span class="no">MailTo</span><span class="o">::</span><span class="no">EMAIL_REGEXP</span> <span class="p">}</span> <span class="k">def</span> <span class="nf">full_name</span> <span class="p">[</span><span class="n">first_name</span><span class="p">,</span> <span class="n">last_name</span><span class="p">].</span><span class="nf">compact</span><span class="p">.</span><span class="nf">join</span><span class="p">(</span><span class="s2">" "</span><span class="p">)</span> <span class="k">end</span><span class="k">end</span></code></pre> </div> </section> </div> </article></div>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<%ruby_code = <<~RUBY class User < ApplicationRecord validates :name, presence: true validates :email, format: { with: URI::MailTo::EMAIL_REGEXP } def full_name [first_name, last_name].compact.join(" ") end endRUBY%><div class="flex flex-col gap-6 p-8 max-w-2xl"> <%= render Midwest::CodeBlockComponent.new(ruby_code, language: :ruby) %></div>Default
Syntax-highlighted code block with copy-to-clipboard. Highlighting is server-side via Rouge — no JavaScript required.
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/default
Annotate a preview to embed its Figma design here:
@figma "https://figma.com/..."