Class: Shadcn::CommandComponent

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

Overview

Command component - a command palette for searching and selecting items Matches shadcn/ui Command component (cmdk pattern)

Examples:

Basic command

<%= render Shadcn::CommandComponent.new do |command| %>
  <% command.with_input(placeholder: "Type a command...") %>
  <% command.with_list do |list| %>
    <% list.with_empty { "No results found." } %>
    <% list.with_group(heading: "Suggestions") do |group| %>
      <% group.with_item(value: "calendar") { "Calendar" } %>
      <% group.with_item(value: "search") { "Search" } %>
    <% end %>
  <% end %>
<% end %>

Constant Summary collapse

BASE_CLASSES =
"flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground"

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



32
33
34
# File 'app/components/shadcn/command_component.rb', line 32

def call
  (:div, command_content, **command_attributes)
end