module Kiso::IconHelper

def icon_class_merger

Returns:
  • (TailwindMerge::Merger) -
def icon_class_merger
  @icon_class_merger ||= TailwindMerge::Merger.new
end

def kiso_component_icon(semantic_name, **)

Other tags:
    Example: Host app overrides the icon globally -
    Example: In a component partial (dropdown indicator) -
    Example: In a component partial (separator chevron) -

Raises:
  • (KeyError) - if +semantic_name+ is not registered in

Returns:
  • (ActiveSupport::SafeBuffer) - rendered inline SVG

Parameters:
  • options (Hash) -- forwarded to {#kiso_icon} (e.g. +size:+,
  • semantic_name (Symbol) -- a key from the icon registry
def kiso_component_icon(semantic_name, **)
  icon_name = Kiso.config.icons.fetch(semantic_name) {
    raise KeyError, "Unknown Kiso icon: #{semantic_name.inspect}. " \
      "Known icons: #{Kiso.config.icons.keys.join(", ")}"
  }
  kiso_icon(icon_name, **)
end

def kiso_icon(name, size: nil, **options)

Other tags:
    Example: From a specific icon set -
    Example: With accessibility label -
    Example: With extra Tailwind classes -
    Example: With a size preset -
    Example: Basic usage in a template -

Returns:
  • (ActiveSupport::SafeBuffer) - rendered inline SVG element

Parameters:
  • options (Hash) -- forwarded to +kiso_icon_tag+ from the
  • size (Symbol, nil) -- size preset from {SIZE_PRESETS}
  • name (String) -- icon identifier, optionally prefixed with the
def kiso_icon(name, size: nil, **options)
  css_classes = options.delete(:class) || ""
  size_class = size ? SIZE_PRESETS.fetch(size) : nil
  merged = merge_icon_classes(BASE_CLASSES, size_class, css_classes)
  kiso_icon_tag(name, class: merged, **options)
end

def merge_icon_classes(*parts)

Returns:
  • (String) - deduplicated, conflict-resolved class string

Parameters:
  • parts (Array) -- class strings to merge. +nil+ and
def merge_icon_classes(*parts)
  combined = parts.reject { |p| p.nil? || p.to_s.empty? }.join(" ")
  icon_class_merger.merge(combined)
end