Class: Shadcn::TableComponent

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

Overview

Table component for displaying tabular data Matches shadcn/ui Table component

Examples:

Basic table

<%= render Shadcn::TableComponent.new do |table| %>
  <% table.with_header do |header| %>
    <% header.with_row do |row| %>
      <% row.with_head { "Name" } %>
      <% row.with_head { "Email" } %>
      <% row.with_head { "Role" } %>
    <% end %>
  <% end %>
  <% table.with_body do |body| %>
    <% @users.each do |user| %>
      <% body.with_row do |row| %>
        <% row.with_cell { user.name } %>
        <% row.with_cell { user.email } %>
        <% row.with_cell { user.role } %>
      <% end %>
    <% end %>
  <% end %>
<% end %>

Constant Summary collapse

BASE_CLASSES =
"w-full caption-bottom text-sm"

Instance Attribute Summary

Attributes inherited from BaseComponent

#class_name, #data, #html_options

Method Summary

Methods inherited from BaseComponent

#content, #initialize

Methods included from Rails::Helpers::ClassNameHelper

#cn

Constructor Details

This class inherits a constructor from Shadcn::BaseComponent