Heading with Anchor

Description

Heading with anchor for easy linking to sections.

PRO
This component is part of our professional component suite. See the installation instructions below for more on how to use it.

Arguments

Name Default Type Description
tag h1 String Define the html heading tag
Options: h1, h2, h3, h4, h5, h6, div, span
text String The headline itself. If not set the content block of the component will be rendered.
size String Define a size class, defaults to nil
Options: h1, h2, h3, h4, h5, h6
display String Define a heading display class for a different styling
Options: 1, 2, 3, 4, 5, 6
html_attributes {} Hash Any attributes for the used html wrapper tag

Examples

Default

<%= render Railsboot::HeadingWithAnchorComponent.new.with_content("h1 Heading") %>
<%= render Railsboot::HeadingWithAnchorComponent.new(tag: "h2").with_content("h2 Heading") %>
<%= render Railsboot::HeadingWithAnchorComponent.new(tag: "h3").with_content("h3 Heading") %>
<%= render Railsboot::HeadingWithAnchorComponent.new(tag: "h4").with_content("h4 Heading") %>
<%= render Railsboot::HeadingWithAnchorComponent.new(tag: "h5").with_content("h5 Heading") %>
<%= render Railsboot::HeadingWithAnchorComponent.new(tag: "h6").with_content("h6 Heading") %>
<h1 id="h1_heading">
  h1 Heading<a class="heading-anchor" aria-label="Anchor" data-anchor-icon="#" href="#h1_heading"></a>
</h1>
<h2 id="h2_heading">
  h2 Heading<a class="heading-anchor" aria-label="Anchor" data-anchor-icon="#" href="#h2_heading"></a>
</h2>
<h3 id="h3_heading">
  h3 Heading<a class="heading-anchor" aria-label="Anchor" data-anchor-icon="#" href="#h3_heading"></a>
</h3>
<h4 id="h4_heading">
  h4 Heading<a class="heading-anchor" aria-label="Anchor" data-anchor-icon="#" href="#h4_heading"></a>
</h4>
<h5 id="h5_heading">
  h5 Heading<a class="heading-anchor" aria-label="Anchor" data-anchor-icon="#" href="#h5_heading"></a>
</h5>
<h6 id="h6_heading">
  h6 Heading<a class="heading-anchor" aria-label="Anchor" data-anchor-icon="#" href="#h6_heading"></a>
</h6>

Installation

Simply download this component with all its related files and assets. Unpackage the downloaded ZIP-file, copy all relevant files into your app and adapt the things you need. The ZIP-folder contains:

  • A parent component class (app/components/railsboot/component.rb) of which all components inherit from.
  • A base component class (app/components/railsboot/base_component.rb) which is used for rendering internally.
  • The desired component itself (app/components/railsboot/heading_with_anchor_component.rb).
  • A view template (app/components/railsboot/heading_with_anchor_component.html.erb) for the component unless it's rendered inline.
  • Any other dependent components such as Slots (just if the component needs those)
  • Any dependent assets (JS-Files, CSS-Files) (just if the component needs those)
  • A test file for the components (test/components/railsboot/heading_with_anchor_component_test.rb) including potential slot or dependency tests.

For more information please refer to the installation section.

Download

Download the component and its related files (e.g. templates, assets, slots etc.), unpackage the zip file and adapt the things you need.

Get access You need to purchase a professional license to download this component.