Attachment
Displays a file or image attached to a message or form, with upload states, actions, and an optional trigger.
Usage
File
Attachment do
AttachmentMedia { file_text_icon }
AttachmentContent do
AttachmentTitle { "quarterly-report.pdf" }
AttachmentDescription { "PDF · 2.4 MB" }
end
AttachmentActions do
AttachmentAction(aria_label: "Remove quarterly-report.pdf") { x_icon }
end
end
Content only
Leave out AttachmentMedia for a compact chip.
div(class: "flex flex-wrap gap-2") do
Attachment do
AttachmentContent do
AttachmentTitle { "notes.md" }
AttachmentDescription { "Markdown · 4 KB" }
end
end
Attachment do
AttachmentContent { AttachmentTitle { "brand-guidelines.pdf" } }
AttachmentActions do
AttachmentAction(aria_label: "Remove brand-guidelines.pdf") { x_icon }
end
end
end
States
Upload states
state: :idle shows a dashed border, :uploading and :processing make the title shimmer, :error tints the attachment.
div(class: "flex w-full flex-col gap-2") do
Attachment(state: :idle, class: "w-full") do
AttachmentMedia { clock_icon }
AttachmentContent do
AttachmentTitle { "selected-file.pdf" }
AttachmentDescription { "Ready to upload" }
end
AttachmentActions do
AttachmentAction(aria_label: "Remove selected-file.pdf") { x_icon }
end
end
Attachment(state: :uploading, class: "w-full") do
AttachmentMedia { spinner_icon }
AttachmentContent do
AttachmentTitle { "design-system.zip" }
AttachmentDescription { "Uploading · 64%" }
end
AttachmentActions do
AttachmentAction(aria_label: "Remove design-system.zip") { x_icon }
end
end
Attachment(state: :processing, class: "w-full") do
AttachmentMedia { file_text_icon }
AttachmentContent do
AttachmentTitle { "market-research.pdf" }
AttachmentDescription { "Processing document" }
end
AttachmentActions do
AttachmentAction(aria_label: "Remove market-research.pdf") { x_icon }
end
end
Attachment(state: :error, class: "w-full") do
AttachmentMedia { circle_alert_icon }
AttachmentContent do
AttachmentTitle { "financials.xlsx" }
AttachmentDescription { "Upload failed. File is too large." }
end
AttachmentActions do
AttachmentAction(aria_label: "Remove financials.xlsx") { x_icon }
end
end
Attachment(state: :done, class: "w-full") do
AttachmentMedia { file_text_icon }
AttachmentContent do
AttachmentTitle { "meeting-notes.pdf" }
AttachmentDescription { "PDF · 1.1 MB" }
end
AttachmentActions do
AttachmentAction(aria_label: "Remove meeting-notes.pdf") { x_icon }
end
end
end
Images
Image tiles
orientation: :vertical with AttachmentMedia(variant: :image). The image is dimmed until the upload is done.
div(class: "flex flex-wrap gap-3") do
Attachment(orientation: :vertical) do
AttachmentMedia(variant: :image) { img(src: "https://images.unsplash.com/photo-1497366754035-f200968a6e72?w=900&auto=format&fit=crop&q=80", alt: "Office") }
AttachmentActions do
AttachmentAction(variant: :secondary, aria_label: "Remove office.jpg") { x_icon }
end
end
Attachment(orientation: :vertical, state: :uploading) do
AttachmentMedia(variant: :image) { img(src: "https://images.unsplash.com/photo-1497366754035-f200968a6e72?w=900&auto=format&fit=crop&q=80", alt: "Office") }
AttachmentContent do
AttachmentTitle { "office.jpg" }
AttachmentDescription { "Uploading" }
end
end
Attachment(orientation: :vertical) do
AttachmentMedia(variant: :image) { img(src: "https://images.unsplash.com/photo-1497366754035-f200968a6e72?w=900&auto=format&fit=crop&q=80", alt: "Office") }
AttachmentContent do
AttachmentTitle { "office.jpg" }
AttachmentDescription { "JPG · 1.8 MB" }
end
end
end
Sizes
Sizes
div(class: "flex flex-col items-start gap-3") do
[:default, :sm, :xs].each do |size|
Attachment(size: size) do
AttachmentMedia { file_text_icon }
AttachmentContent do
AttachmentTitle { "proposal.pdf" }
AttachmentDescription { "PDF · 640 KB" }
end
AttachmentActions do
AttachmentAction(aria_label: "Remove proposal.pdf") { x_icon }
end
end
end
end
Group
Scrollable group
AttachmentGroup scrolls sideways and snaps to each attachment, fading the edge that has more to show.
AttachmentGroup(class: "w-full max-w-md") do
%w[roadmap.pdf budget.xlsx contract.docx kickoff.pptx notes.md].each do |name|
Attachment do
AttachmentMedia { file_text_icon }
AttachmentContent do
AttachmentTitle { name }
AttachmentDescription { "Shared file" }
end
AttachmentActions do
AttachmentAction(aria_label: "Remove #{name}") { x_icon }
end
end
end
end
Triggers
Open in a new tab
AttachmentTrigger stretches a link or button over the attachment; its actions stay clickable on top.
Attachment(class: "w-full") do
AttachmentMedia { file_text_icon }
AttachmentContent do
AttachmentTitle { "contract-review.pdf" }
AttachmentDescription { "PDF · 820 KB" }
end
AttachmentActions do
AttachmentAction(aria_label: "Download contract-review.pdf") { download_icon }
end
AttachmentTrigger(as: :a, href: "#", target: "_blank", rel: "noreferrer", aria_label: "Open contract-review.pdf")
end
Open a dialog
Wrap the trigger in DialogTrigger(class: "contents") so it still covers the attachment.
Dialog do
Attachment(class: "w-full hover:bg-muted/50") do
AttachmentMedia { file_text_icon }
AttachmentContent do
AttachmentTitle { "research-summary.pdf" }
AttachmentDescription { "Open preview dialog" }
end
AttachmentActions do
AttachmentAction(aria_label: "Copy link to research-summary.pdf") { copy_icon }
end
DialogTrigger(class: "contents") do
AttachmentTrigger(aria_label: "Preview research-summary.pdf")
end
end
DialogContent(class: "sm:max-w-md") do
DialogHeader do
DialogTitle { "research-summary.pdf" }
DialogDescription { "Attachment triggers can open dialogs while actions remain independently reachable." }
end
end
end
Installation
Using RubyUI CLI
Run the install command
rails g ruby_ui:component Attachment
Manual installation
1
Add RubyUI::Attachment to app/components/ruby_ui/attachment/attachment.rb
# frozen_string_literal: true
module RubyUI
# A file or image attached to a message or form, styled after shadcn's
# Attachment (Base UI + vega).
#
# state: :idle (selected, not sent yet: dashed border), :uploading and
# :processing (the title shimmers), :error (destructive tint) or :done.
# size: :default, :sm or :xs. orientation: :horizontal (a row) or :vertical
# (a tile, e.g. an image preview).
class Attachment < Base
STATES = %i[idle uploading processing error done].freeze
SIZES = {
default: "gap-2 text-sm has-data-[slot=attachment-media]:p-2 " \
"has-data-[slot=attachment-content]:px-2.5 has-data-[slot=attachment-content]:py-2",
sm: "gap-2.5 text-xs has-data-[slot=attachment-media]:p-1.5 " \
"has-data-[slot=attachment-content]:px-2 has-data-[slot=attachment-content]:py-1.5",
xs: "gap-1.5 rounded-lg text-xs has-data-[slot=attachment-media]:p-1 " \
"has-data-[slot=attachment-content]:px-1.5 has-data-[slot=attachment-content]:py-1"
}.freeze
ORIENTATIONS = {
horizontal: "min-w-40 items-center",
vertical: "w-24 flex-col has-data-[slot=attachment-content]:w-30"
}.freeze
def initialize(state: :done, size: :default, orientation: :horizontal, **attrs)
@state = pick(state, STATES, :done)
@size = pick(size, SIZES.keys, :default)
@orientation = pick(orientation, ORIENTATIONS.keys, :horizontal)
super(**attrs)
end
def view_template(&)
div(**attrs, &)
end
private
def pick(value, allowed, fallback)
value = value.to_s.to_sym
allowed.include?(value) ? value : fallback
end
def default_attrs
{
data: {slot: "attachment", state: @state, size: @size, orientation: @orientation},
class: [
"group/attachment relative flex w-fit max-w-full min-w-0 shrink-0 flex-wrap rounded-xl border",
"bg-card text-card-foreground transition-colors focus-within:ring-1 focus-within:ring-ring/50",
"has-[>a,>button]:hover:bg-muted/50 data-[state=error]:border-destructive/30 data-[state=idle]:border-dashed",
SIZES[@size],
ORIENTATIONS[@orientation]
]
}
end
end
end
2
Add RubyUI::AttachmentAction to app/components/ruby_ui/attachment/attachment_action.rb
# frozen_string_literal: true
module RubyUI
# An icon button for an Attachment (remove, download, copy link…). A RubyUI
# Button that defaults to variant: :ghost and size: :icon_xs, as shadcn's
# AttachmentAction does; it takes every Button option, href: included.
# Give it an aria_label naming the file.
class AttachmentAction < Button
def initialize(variant: :ghost, size: :icon_xs, **attrs)
super
end
private
def default_attrs
super.tap { |attrs| attrs[:data][:slot] = "attachment-action" }
end
end
end
3
Add RubyUI::AttachmentActions to app/components/ruby_ui/attachment/attachment_actions.rb
# frozen_string_literal: true
module RubyUI
# Holds the AttachmentAction buttons. Sits above an AttachmentTrigger, so
# its buttons stay clickable; on a vertical attachment it floats over the
# top-right corner of the media.
class AttachmentActions < Base
def view_template(&)
div(**attrs, &)
end
private
def default_attrs
{
data: {slot: "attachment-actions"},
class: "relative z-20 flex shrink-0 items-center " \
"group-data-[orientation=vertical]/attachment:absolute group-data-[orientation=vertical]/attachment:top-3 " \
"group-data-[orientation=vertical]/attachment:right-3 group-data-[orientation=vertical]/attachment:gap-1"
}
end
end
end
4
Add RubyUI::AttachmentContent to app/components/ruby_ui/attachment/attachment_content.rb
# frozen_string_literal: true
module RubyUI
# Holds an Attachment's title and description.
class AttachmentContent < Base
def view_template(&)
div(**attrs, &)
end
private
def default_attrs
{
data: {slot: "attachment-content"},
class: "max-w-full min-w-0 flex-1 leading-tight group-data-[orientation=vertical]/attachment:px-1"
}
end
end
end
5
Add RubyUI::AttachmentDescription to app/components/ruby_ui/attachment/attachment_description.rb
# frozen_string_literal: true
module RubyUI
# A muted line under the title: file type and size, progress or an error.
class AttachmentDescription < Base
def view_template(&)
span(**attrs, &)
end
private
def default_attrs
{
data: {slot: "attachment-description"},
class: "mt-0.5 block max-w-full min-w-0 truncate text-xs text-muted-foreground " \
"group-data-[state=error]/attachment:text-destructive/80"
}
end
end
end
6
Add RubyUI::AttachmentDocs to app/components/ruby_ui/attachment/attachment_docs.rb
# frozen_string_literal: true
class Views::Docs::Attachment < Views::Base
IMAGE = "https://images.unsplash.com/photo-1497366754035-f200968a6e72?w=900&auto=format&fit=crop&q=80"
def view_template
component = "Attachment"
div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do
render Docs::Header.new(title: "Attachment", description: "Displays a file or image attached to a message or form, with upload states, actions, and an optional trigger.")
Heading(level: 2) { "Usage" }
render Docs::VisualCodeExample.new(title: "File", context: self) do
<<~RUBY
Attachment do
AttachmentMedia { file_text_icon }
AttachmentContent do
AttachmentTitle { "quarterly-report.pdf" }
AttachmentDescription { "PDF · 2.4 MB" }
end
AttachmentActions do
AttachmentAction(aria_label: "Remove quarterly-report.pdf") { x_icon }
end
end
RUBY
end
render Docs::VisualCodeExample.new(title: "Content only", description: "Leave out AttachmentMedia for a compact chip.", context: self) do
<<~RUBY
div(class: "flex flex-wrap gap-2") do
Attachment do
AttachmentContent do
AttachmentTitle { "notes.md" }
AttachmentDescription { "Markdown · 4 KB" }
end
end
Attachment do
AttachmentContent { AttachmentTitle { "brand-guidelines.pdf" } }
AttachmentActions do
AttachmentAction(aria_label: "Remove brand-guidelines.pdf") { x_icon }
end
end
end
RUBY
end
Heading(level: 2) { "States" }
render Docs::VisualCodeExample.new(title: "Upload states", description: "state: :idle shows a dashed border, :uploading and :processing make the title shimmer, :error tints the attachment.", context: self) do
<<~RUBY
div(class: "flex w-full flex-col gap-2") do
Attachment(state: :idle, class: "w-full") do
AttachmentMedia { clock_icon }
AttachmentContent do
AttachmentTitle { "selected-file.pdf" }
AttachmentDescription { "Ready to upload" }
end
AttachmentActions do
AttachmentAction(aria_label: "Remove selected-file.pdf") { x_icon }
end
end
Attachment(state: :uploading, class: "w-full") do
AttachmentMedia { spinner_icon }
AttachmentContent do
AttachmentTitle { "design-system.zip" }
AttachmentDescription { "Uploading · 64%" }
end
AttachmentActions do
AttachmentAction(aria_label: "Remove design-system.zip") { x_icon }
end
end
Attachment(state: :processing, class: "w-full") do
AttachmentMedia { file_text_icon }
AttachmentContent do
AttachmentTitle { "market-research.pdf" }
AttachmentDescription { "Processing document" }
end
AttachmentActions do
AttachmentAction(aria_label: "Remove market-research.pdf") { x_icon }
end
end
Attachment(state: :error, class: "w-full") do
AttachmentMedia { circle_alert_icon }
AttachmentContent do
AttachmentTitle { "financials.xlsx" }
AttachmentDescription { "Upload failed. File is too large." }
end
AttachmentActions do
AttachmentAction(aria_label: "Remove financials.xlsx") { x_icon }
end
end
Attachment(state: :done, class: "w-full") do
AttachmentMedia { file_text_icon }
AttachmentContent do
AttachmentTitle { "meeting-notes.pdf" }
AttachmentDescription { "PDF · 1.1 MB" }
end
AttachmentActions do
AttachmentAction(aria_label: "Remove meeting-notes.pdf") { x_icon }
end
end
end
RUBY
end
Heading(level: 2) { "Images" }
render Docs::VisualCodeExample.new(title: "Image tiles", description: "orientation: :vertical with AttachmentMedia(variant: :image). The image is dimmed until the upload is done.", context: self) do
<<~RUBY
div(class: "flex flex-wrap gap-3") do
Attachment(orientation: :vertical) do
AttachmentMedia(variant: :image) { img(src: "#{IMAGE}", alt: "Office") }
AttachmentActions do
AttachmentAction(variant: :secondary, aria_label: "Remove office.jpg") { x_icon }
end
end
Attachment(orientation: :vertical, state: :uploading) do
AttachmentMedia(variant: :image) { img(src: "#{IMAGE}", alt: "Office") }
AttachmentContent do
AttachmentTitle { "office.jpg" }
AttachmentDescription { "Uploading" }
end
end
Attachment(orientation: :vertical) do
AttachmentMedia(variant: :image) { img(src: "#{IMAGE}", alt: "Office") }
AttachmentContent do
AttachmentTitle { "office.jpg" }
AttachmentDescription { "JPG · 1.8 MB" }
end
end
end
RUBY
end
Heading(level: 2) { "Sizes" }
render Docs::VisualCodeExample.new(title: "Sizes", context: self) do
<<~RUBY
div(class: "flex flex-col items-start gap-3") do
[:default, :sm, :xs].each do |size|
Attachment(size: size) do
AttachmentMedia { file_text_icon }
AttachmentContent do
AttachmentTitle { "proposal.pdf" }
AttachmentDescription { "PDF · 640 KB" }
end
AttachmentActions do
AttachmentAction(aria_label: "Remove proposal.pdf") { x_icon }
end
end
end
end
RUBY
end
Heading(level: 2) { "Group" }
render Docs::VisualCodeExample.new(title: "Scrollable group", description: "AttachmentGroup scrolls sideways and snaps to each attachment, fading the edge that has more to show.", context: self) do
<<~RUBY
AttachmentGroup(class: "w-full max-w-md") do
%w[roadmap.pdf budget.xlsx contract.docx kickoff.pptx notes.md].each do |name|
Attachment do
AttachmentMedia { file_text_icon }
AttachmentContent do
AttachmentTitle { name }
AttachmentDescription { "Shared file" }
end
AttachmentActions do
AttachmentAction(aria_label: "Remove \#{name}") { x_icon }
end
end
end
end
RUBY
end
Heading(level: 2) { "Triggers" }
render Docs::VisualCodeExample.new(title: "Open in a new tab", description: "AttachmentTrigger stretches a link or button over the attachment; its actions stay clickable on top.", context: self) do
<<~RUBY
Attachment(class: "w-full") do
AttachmentMedia { file_text_icon }
AttachmentContent do
AttachmentTitle { "contract-review.pdf" }
AttachmentDescription { "PDF · 820 KB" }
end
AttachmentActions do
AttachmentAction(aria_label: "Download contract-review.pdf") { download_icon }
end
AttachmentTrigger(as: :a, href: "#", target: "_blank", rel: "noreferrer", aria_label: "Open contract-review.pdf")
end
RUBY
end
render Docs::VisualCodeExample.new(title: "Open a dialog", description: "Wrap the trigger in DialogTrigger(class: \"contents\") so it still covers the attachment.", context: self) do
<<~RUBY
Dialog do
Attachment(class: "w-full hover:bg-muted/50") do
AttachmentMedia { file_text_icon }
AttachmentContent do
AttachmentTitle { "research-summary.pdf" }
AttachmentDescription { "Open preview dialog" }
end
AttachmentActions do
AttachmentAction(aria_label: "Copy link to research-summary.pdf") { copy_icon }
end
DialogTrigger(class: "contents") do
AttachmentTrigger(aria_label: "Preview research-summary.pdf")
end
end
DialogContent(class: "sm:max-w-md") do
DialogHeader do
DialogTitle { "research-summary.pdf" }
DialogDescription { "Attachment triggers can open dialogs while actions remain independently reachable." }
end
end
end
RUBY
end
render Components::ComponentSetup::Tabs.new(component_name: component)
# components
render Docs::ComponentsTable.new(component_files(component))
end
end
private
# lucide icons, as lucide-react renders them (24x24, aria-hidden, no size
# class): AttachmentMedia and AttachmentAction size them.
def lucide_icon(**attrs, &)
defaults = {
xmlns: "http://www.w3.org/2000/svg",
width: "24",
height: "24",
viewbox: "0 0 24 24",
fill: "none",
stroke: "currentColor",
stroke_width: "2",
stroke_linecap: "round",
stroke_linejoin: "round",
aria_hidden: "true"
}
svg(**defaults.merge(attrs).compact, &)
end
def file_text_icon
lucide_icon do |s|
s.path(d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z")
s.path(d: "M14 2v5a1 1 0 0 0 1 1h5")
s.path(d: "M10 9H8")
s.path(d: "M16 13H8")
s.path(d: "M16 17H8")
end
end
def x_icon
lucide_icon do |s|
s.path(d: "M18 6 6 18")
s.path(d: "m6 6 12 12")
end
end
def clock_icon
lucide_icon do |s|
s.circle(cx: "12", cy: "12", r: "10")
s.path(d: "M12 6v6l4 2")
end
end
def circle_alert_icon
lucide_icon do |s|
s.circle(cx: "12", cy: "12", r: "10")
s.line(x1: "12", x2: "12", y1: "8", y2: "12")
s.line(x1: "12", x2: "12.01", y1: "16", y2: "16")
end
end
def download_icon
lucide_icon do |s|
s.path(d: "M12 15V3")
s.path(d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4")
s.path(d: "m7 10 5 5 5-5")
end
end
def copy_icon
lucide_icon do |s|
s.rect(width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2")
s.path(d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2")
end
end
# shadcn's Spinner: a spinning loader-circle announced as "Loading".
def spinner_icon
lucide_icon(role: "status", aria_hidden: nil, aria_label: "Loading", class: "size-4 animate-spin", data: {slot: "spinner"}) do |s|
s.path(d: "M21 12a9 9 0 1 1-6.219-8.56")
end
end
end
7
Add RubyUI::AttachmentGroup to app/components/ruby_ui/attachment/attachment_group.rb
# frozen_string_literal: true
module RubyUI
# A row of Attachments that scrolls sideways, snapping to each one, with the
# edges faded while there is more to scroll (scroll-fade-x from the install
# CSS).
class AttachmentGroup < Base
def view_template(&)
div(**attrs, &)
end
private
def default_attrs
{
data: {slot: "attachment-group"},
class: "flex min-w-0 scroll-fade-x snap-x snap-mandatory scrollbar-none gap-3 overflow-x-auto overscroll-x-contain scroll-px-1 py-1 " \
"*:data-[slot=attachment]:flex-none *:data-[slot=attachment]:snap-start"
}
end
end
end
8
Add RubyUI::AttachmentMedia to app/components/ruby_ui/attachment/attachment_media.rb
# frozen_string_literal: true
module RubyUI
# The square thumbnail of an Attachment: an icon (variant: :icon) or an
# <img> that fills it (variant: :image). The image is dimmed until the
# attachment is :idle or :done.
class AttachmentMedia < Base
VARIANTS = {
icon: "",
image: "opacity-60 group-data-[state=idle]/attachment:opacity-100 group-data-[state=done]/attachment:opacity-100 " \
"*:[img]:aspect-square *:[img]:w-full *:[img]:object-cover"
}.freeze
def initialize(variant: :icon, **attrs)
@variant = variant.to_s.to_sym
@variant = :icon unless VARIANTS.key?(@variant)
super(**attrs)
end
def view_template(&)
div(**attrs, &)
end
private
def default_attrs
{
data: {slot: "attachment-media", variant: @variant},
class: [
"relative flex aspect-square w-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted text-foreground",
"group-data-[state=error]/attachment:bg-destructive/10 group-data-[state=error]/attachment:text-destructive",
"group-data-[size=sm]/attachment:w-8 group-data-[size=xs]/attachment:w-7 group-data-[size=xs]/attachment:rounded-md",
"group-data-[orientation=vertical]/attachment:w-full",
"[&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",
"group-data-[size=xs]/attachment:[&_svg:not([class*='size-'])]:size-3.5",
"group-data-[orientation=vertical]/attachment:[&_svg:not([class*='size-'])]:size-6",
"group-data-[orientation=vertical]/attachment:*:data-[slot=spinner]:size-6!",
VARIANTS[@variant]
]
}
end
end
end
9
Add RubyUI::AttachmentTitle to app/components/ruby_ui/attachment/attachment_title.rb
# frozen_string_literal: true
module RubyUI
# The file name. Truncates, and shimmers while the attachment is
# :uploading or :processing (the shimmer utility from the install CSS).
class AttachmentTitle < Base
def view_template(&)
span(**attrs, &)
end
private
def default_attrs
{
data: {slot: "attachment-title"},
class: "block max-w-full min-w-0 truncate font-medium " \
"group-data-[state=processing]/attachment:shimmer group-data-[state=uploading]/attachment:shimmer"
}
end
end
end
10
Add RubyUI::AttachmentTrigger to app/components/ruby_ui/attachment/attachment_trigger.rb
# frozen_string_literal: true
module RubyUI
# Makes the whole Attachment clickable: an invisible <button> (or, with
# as: :a, a link) stretched over it. The attachment shows its focus ring
# and hover background; AttachmentActions stay on top and keep working.
# Give it an aria_label ("Open report.pdf"), since it has no text.
#
# shadcn's render prop maps to as: (:button or :a). To open a Dialog, put
# it inside DialogTrigger.
class AttachmentTrigger < Base
def initialize(as: :button, **attrs)
@as = (as.to_s == "a") ? :a : :button
super(**attrs)
end
def view_template(&)
send(@as, **attrs, &)
end
private
def default_attrs
attrs = {
data: {slot: "attachment-trigger"},
class: "absolute inset-0 z-10 outline-none"
}
attrs[:type] = "button" if @as == :button
attrs
end
end
end
11
Install required components
Component Attachment relies on the following RubyUI components. Refer to their individual installation guides for setup instructions:
Components
| Component | Built using | Source |
|---|---|---|
Attachment | Phlex | |
AttachmentAction | Phlex | |
AttachmentActions | Phlex | |
AttachmentContent | Phlex | |
AttachmentDescription | Phlex | |
AttachmentDocs | Phlex | |
AttachmentGroup | Phlex | |
AttachmentMedia | Phlex | |
AttachmentTitle | Phlex | |
AttachmentTrigger | Phlex |