Class: BetterUi::HeadingComponent
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- BetterUi::HeadingComponent
- Defined in:
- app/components/better_ui/heading_component.rb
Overview
A flexible heading component for rendering semantic HTML headings with optional subtitle, actions, divider, and color variant support.
This component renders headings (h1-h6) with consistent typography, alignment, and optional subtitle text. It supports an actions slot for placing buttons or other controls alongside the heading.
Constant Summary collapse
- LEVELS =
Available heading levels
%i[h1 h2 h3 h4 h5 h6].freeze
- ALIGNMENTS =
Available alignment options
%i[left center right].freeze
Constants inherited from ApplicationComponent
ApplicationComponent::SHADOWS, ApplicationComponent::VARIANTS, ApplicationComponent::VARIANT_BODY_DIVIDE, ApplicationComponent::VARIANT_DIVIDE, ApplicationComponent::VARIANT_HEADER_BG, ApplicationComponent::VARIANT_HEADER_TEXT, ApplicationComponent::VARIANT_HIGHLIGHTED, ApplicationComponent::VARIANT_HOVERABLE, ApplicationComponent::VARIANT_RING, ApplicationComponent::VARIANT_SORT_ICON, ApplicationComponent::VARIANT_STRIPED
Instance Method Summary collapse
-
#initialize(level: :h2, subtitle: nil, divider: false, variant: nil, align: :left, container_classes: nil, **options) ⇒ HeadingComponent
constructor
Initializes a new heading component.
-
#with_actions ⇒ Object
Slot for rendering action buttons or controls aligned to the right of the heading.
-
#with_subtitle ⇒ Object
Slot for rendering rich subtitle content below the heading.
Constructor Details
#initialize(level: :h2, subtitle: nil, divider: false, variant: nil, align: :left, container_classes: nil, **options) ⇒ HeadingComponent
Initializes a new heading component.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'app/components/better_ui/heading_component.rb', line 67 def initialize( level: :h2, subtitle: nil, divider: false, variant: nil, align: :left, container_classes: nil, ** ) @level = validate_level(level) @subtitle_text = subtitle @divider = divider @variant = variant ? validate_variant(variant) : nil @align = validate_align(align) @container_classes = container_classes @options = end |
Instance Method Details
#with_actions ⇒ Object
Slot for rendering action buttons or controls aligned to the right of the heading.
51 |
# File 'app/components/better_ui/heading_component.rb', line 51 renders_one :actions |
#with_subtitle ⇒ Object
Slot for rendering rich subtitle content below the heading. Takes precedence over the subtitle string parameter when both are provided.
46 |
# File 'app/components/better_ui/heading_component.rb', line 46 renders_one :subtitle |