Class: UI::Skeleton

Inherits:
Phlex::HTML
  • Object
show all
Defined in:
app/components/ui/skeleton.rb

Overview

Skeleton - Phlex implementation

A simple loading placeholder component with pulsing animation. This is a CSS-only component with no JavaScript behavior.

Examples:

Basic usage

render UI::Skeleton.new(class: "h-[20px] w-[100px] rounded-full")

Card skeleton

div(class: "flex flex-col space-y-3") do
  render UI::Skeleton.new(class: "h-[125px] w-[250px] rounded-xl")
  div(class: "space-y-2") do
    render UI::Skeleton.new(class: "h-4 w-[250px]")
    render UI::Skeleton.new(class: "h-4 w-[200px]")
  end
end

Instance Method Summary collapse

Constructor Details

#initialize(classes: "", **attributes) ⇒ Skeleton

Returns a new instance of Skeleton.

Parameters:

  • classes (String) (defaults to: "")

    Additional CSS classes (width, height, shape)

  • attributes (Hash)

    Additional HTML attributes



22
23
24
25
# File 'app/components/ui/skeleton.rb', line 22

def initialize(classes: "", **attributes)
  @classes = classes
  @attributes = attributes
end

Instance Method Details

#view_templateObject



27
28
29
# File 'app/components/ui/skeleton.rb', line 27

def view_template
  div(**merged_attributes)
end