class Primer::LinkComponent
Use ‘Link` for navigating from one page to another. `Link` styles anchor tags with default blue styling and hover text-decoration.
def before_render
def before_render raise ArgumentError, "href is required when using <a> tag" if @system_arguments[:tag] == :a && @system_arguments[:href].nil? && !Rails.env.production? end
def initialize(href: nil, tag: DEFAULT_TAG, scheme: DEFAULT_SCHEME, muted: false, underline: true, **system_arguments)
-
system_arguments(Hash) -- <%= link_to_system_arguments_docs %> -
underline(Boolean) -- Whether or not to underline the link. -
muted(Boolean) -- Uses light gray for Link color, and blue on hover. -
scheme(Symbol) -- <%= one_of(Primer::LinkComponent::SCHEME_MAPPINGS.keys) %> -
href(String) -- URL to be used for the Link. Required if tag is `:a`. If the requirements are not met an error will be raised in non production environments. In production, an empty link element will be rendered. -
tag(String) -- <%= one_of(Primer::LinkComponent::TAG_OPTIONS) %>
Other tags:
- Example: With tooltip -
Example: Span as link -
Example: Without underline -
Example: Schemes -
Example: Muted -
Example: Default -
def initialize(href: nil, tag: DEFAULT_TAG, scheme: DEFAULT_SCHEME, muted: false, underline: true, **system_arguments) @system_arguments = system_arguments @id = @system_arguments[:id] @system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG) @system_arguments[:href] = href @system_arguments[:classes] = class_names( @system_arguments[:classes], SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_MAPPINGS.keys, scheme, DEFAULT_SCHEME)], "Link" => tag == :span, "Link--muted" => muted, "no-underline" => !underline ) end