x
1
2
3
4
5
<span data-view-component="true" class="Truncate"> <span style="max-width: 300px;" data-view-component="true" class="Truncate-text"> <span data-view-component="true" class="position-relative"><a id="truncate-link-300" href="#" data-view-component="true" class="Link">branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long</a> <tool-tip id="tooltip-d895d8a5-64e7-45dd-8ac5-ba8a01f91666" for="truncate-link-300" popover="manual" data-direction="s" data-type="description" data-view-component="true" class="sr-only position-absolute">branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long</tool-tip></span></span> <span style="max-width: 200px;" data-view-component="true" class="Truncate-text"> <span data-view-component="true" class="position-relative"><a id="truncate-link-200" href="#" data-view-component="true" class="Link">branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long</a> <tool-tip id="tooltip-212b1f31-b960-452e-8c17-5a7d8fa0f0b5" for="truncate-link-200" popover="manual" data-direction="s" data-type="description" data-view-component="true" class="sr-only position-absolute">branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long</tool-tip></span></span> <span style="max-width: 100px;" data-view-component="true" class="Truncate-text"> <span data-view-component="true" class="position-relative"><a id="truncate-link-100" href="#" data-view-component="true" class="Link">branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long</a> <tool-tip id="tooltip-2c8e3af8-00c2-4a2b-ad2f-4bbbdba0d6c0" for="truncate-link-100" popover="manual" data-direction="s" data-type="description" data-view-component="true" class="sr-only position-absolute">branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long</tool-tip></span></span></span>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<% long_text = "branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long" %><%= render(Primer::Beta::Truncate.new) do |component| %> <% component.with_item(max_width: 300) do %> <%= render(Primer::Beta::Link.new(href: "#", id: "truncate-link-300")) do |link| %> <% link.with_tooltip(text: long_text) %> <%= long_text %> <% end %> <% end %> <% component.with_item(max_width: 200) do %> <%= render(Primer::Beta::Link.new(href: "#", id: "truncate-link-200")) do |link| %> <% link.with_tooltip(text: long_text) %> <%= long_text %> <% end %> <% end %> <% component.with_item(max_width: 100) do %> <%= render(Primer::Beta::Link.new(href: "#", id: "truncate-link-100")) do |link| %> <% link.with_tooltip(text: long_text) %> <%= long_text %> <% end %> <% end %><% end %>No notes provided.
No params configured.
app/components/primer/beta/truncate.css
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
/* Truncate */.Truncate { display: inline-flex; min-width: 0; max-width: 100%;}.Truncate > .Truncate-text { min-width: 1ch; max-width: fit-content; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }:is(.Truncate > .Truncate-text) + .Truncate-text { /* stylelint-disable-next-line primer/spacing */ margin-left: var(--control-small-gap); }.Truncate-text--primary:is(.Truncate > .Truncate-text) { flex-basis: 200%; }.Truncate-text--expandable:is(.Truncate > .Truncate-text):hover,.Truncate-text--expandable:is(.Truncate > .Truncate-text):focus,.Truncate-text--expandable:is(.Truncate > .Truncate-text):active { max-width: 100% !important; flex-shrink: 0; cursor: pointer; }