Class: Shadcn::EmptyComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/shadcn/empty_component.rb

Overview

Empty state component for displaying placeholder content when no data is available Matches shadcn/ui Empty component

Examples:

Basic empty state

<%= render Shadcn::EmptyComponent.new do |empty| %>
  <% empty.with_header do |header| %>
    <% header.with_media(variant: :icon) do %>
      <svg>...</svg>
    <% end %>
    <% header.with_title { "No Projects Yet" } %>
    <% header.with_description { "Get started by creating your first project." } %>
  <% end %>
  <% empty.with_content do %>
    <%= render Shadcn::ButtonComponent.new { "Create Project" } %>
  <% end %>
<% end %>

With outline style

<%= render Shadcn::EmptyComponent.new(class_name: "border border-dashed") do |empty| %>
  ...
<% end %>

Constant Summary collapse

BASE_CLASSES =
"flex flex-col items-center justify-center gap-6 py-16 text-center"

Instance Attribute Summary

Attributes inherited from BaseComponent

#class_name, #data, #html_options

Instance Method Summary collapse

Methods inherited from BaseComponent

#content, #initialize

Methods included from Rails::Helpers::ClassNameHelper

#cn

Constructor Details

This class inherits a constructor from Shadcn::BaseComponent

Instance Method Details

#callObject



42
43
44
45
46
# File 'app/components/shadcn/empty_component.rb', line 42

def call
  (:div, class: merge_classes(BASE_CLASSES), **html_options.merge(build_data)) do
    safe_join([header, content_slot, content].compact)
  end
end