Use Subhead
as the start of a section. The :heading
slot will render an <h2>
font-sized text.
:description
slot to render a short description and the :actions
slot for a related action.:description
slot. For longer descriptions, omit the description slot and render a paragraph below the Subhead
.The :heading
slot defaults to rendering a <div>
. Update the tag to a heading element with the appropriate level to improve page navigation for assistive technologies.
Learn more about best heading practices (WAI Headings)
Name | Type | Default | Description |
---|---|---|---|
spacious | Boolean | false | Whether to add spacing to the Subhead. |
hide_border | Boolean | false | Whether to hide the border under the heading. |
system_arguments | Hash | N/A | System arguments |
heading
The heading
Name | Type | Default | Description |
---|---|---|---|
tag | Symbol | N/A | One of :div , :h1 , :h2 , :h3 , :h4 , :h5 , or :h6 . |
danger | Boolean | N/A | Whether to style the heading as dangerous. |
system_arguments | Hash | N/A | System arguments |
actions
Actions
Name | Type | Default | Description |
---|---|---|---|
system_arguments | Hash | N/A | System arguments |
description
The description
Name | Type | Default | Description |
---|---|---|---|
system_arguments | Hash | N/A | System arguments |
<%= render(Primer::Beta::Subhead.new) do |component| %><% component.with_heading(tag: :h3) do %>My Heading<% end %><% component.with_description do %>My Description<% end %><% end %>
<%= render(Primer::Beta::Subhead.new) do |component| %><% component.with_heading(tag: :h3, danger: true) do %>My Heading<% end %><% component.with_description do %>My Description<% end %><% end %>
This is a longer description that is sitting below the Subhead. It's much longer than a description that could sit comfortably in the Subhead.
<%= render(Primer::Beta::Subhead.new) do |component| %><% component.with_heading(tag: :h3) do %>My Heading<% end %><% end %><p> This is a longer description that is sitting below the Subhead. It's much longer than a description that could sit comfortably in the Subhead. </p>
<%= render(Primer::Beta::Subhead.new(hide_border: true)) do |component| %><% component.with_heading do %>My Heading<% end %><% component.with_description do %>My Description<% end %><% end %>
<%= render(Primer::Beta::Subhead.new) do |component| %><% component.with_heading do %>My Heading<% end %><% component.with_description do %>My Description<% end %><% component.with_actions do %><%= render(Primer::ButtonComponent.new(tag: :a, href: "http://www.google.com", scheme: :danger)) { "Action" } %><% end %><% end %>