[Feature] Add Attachment component
Related issue
No issue. Adds shadcn's new Attachment component.
Description
Adds Attachment, a file or image chip for chat composers and messages, matching shadcn's Base UI build with the vega style.
Parts: Attachment, AttachmentGroup, AttachmentMedia, AttachmentContent, AttachmentTitle, AttachmentDescription, AttachmentActions, AttachmentAction and AttachmentTrigger.
Attachmenttakesstate:(:idle,:uploading,:processing,:error,:done),size:(:default,:sm,:xs) andorientation:(:horizontal,:vertical). Unknown values fall back to the defaults.AttachmentMediatakesvariant: :iconor:image. Images stay dimmed until the attachment is idle or done.AttachmentActionis a RubyUIButtonthat defaults to ghost andicon_xs, so it accepts every Button option (href:,disabled:…).AttachmentTriggeris an invisible button or link (as: :a) stretched over the card. Actions sit above it and stay clickable. shadcn'srenderprop maps toas:, as inBubbleContent. To open a Dialog, wrap it inDialogTrigger(class: "contents").- No Stimulus controller. Everything is native elements and CSS.
The title shimmers while uploading or processing. That needs shadcn's shimmer utility (MIT), which is now in the install template, the docs CSS and both installation pages, next to scroll-fade-x. It stops under prefers-reduced-motion. scrollbar-none, used by the group, is a Tailwind 4.3 core utility.
Also in this PR: the docs page at /docs/attachment (with its route, menu entry and regenerated sitemap and llms files), dependencies.yml (depends on Button), the audit map with its drift baseline, fixtures and the rebuilt MCP registry.
shadcn audit
Every line passes. Computed styles match on all nine parts in light and dark; the only difference is the docs app's font stack, and both sides render Inter. The accessibility tree, tags and data attributes match too. In the browser, the trigger covers the card while actions stay on top, the tab order and focus ring match, and so do the hover background and the shimmer animation.
Checklist
shadcn audit ruby-ui/ruby_ui
base 23cf925f head f4644979 shadcn e62c9435
⚠️ Environment font: "Inter Variable", "system-ui", -apple-system, "system-ui", "Segoe UI", Roboto, "Helvetica Neue", Arial, "sans-serif" vs "Inter Variable", sans-serif (light)
⚠️ Environment font: "Inter Variable", "system-ui", -apple-system, "system-ui", "Segoe UI", Roboto, "Helvetica Neue", Arial, "sans-serif" vs "Inter Variable", sans-serif (dark)
✅ Theme neutral tokens match shadcn
Attachment (ref: bases/base/ui/attachment.tsx + style-vega.css @ e62c9435)
✅ Look properties: font-family
Override: every computed property of all nine parts matches in light and dark except font-family, and that is the docs app font stack (environment diff). Both sides load and render Inter Variable; the pixel diff shows text identical. The only pixel differences are the file-text icon paths in the RubyUI fixture (older lucide drawing), not the component.
↳ getComputedStyle (shadcn-audit collect), screens/attachment-closed-diff-*.png
✅ Look AttachmentAction: Button(variant: :ghost, size: :icon_xs) classes
Reference warning settled from the DOM: collect matched the action computed styles (24x24, ghost hover) on both sides, including the secondary variant on the vertical tile.
↳ bases/base/ui/attachment.tsx:150
✅ HTML div/span/button/a with data-slot, data-state, data-size, data-orientation, data-variant
Compared every [data-slot^=attachment] element in the fixture. tabindex="0" on a native <button> is redundant: element.tabIndex is 0 on both sides.
↳ bases/base/ui/attachment.tsx:27-200
✅ Props Attachment(state:, size:, orientation:), AttachmentMedia(variant:), AttachmentAction(variant:, size:), AttachmentTrigger(as:, type:)
render maps to as: (:button or :a), same as BubbleContent; to open a Dialog, the docs wrap AttachmentTrigger in DialogTrigger(class: "contents"). AttachmentAction takes every RubyUI Button option (href:, disabled:).
↳ bases/base/ui/attachment.tsx:26-180
✅ ARIA AttachmentGroup, Attachment, AttachmentMedia, AttachmentContent, AttachmentTitle, AttachmentDescription, AttachmentActions, AttachmentAction, AttachmentTrigger: accessibility tree matches
↳ accessibility tree (shadcn-audit collect)
✅ Behavior trigger covers the card (elementFromPoint → attachment-trigger), actions stay on top (→ attachment-action), tab order action → trigger, focus-within ring 0 0 0 1px ring/50 with :focus-visible, hover bg muted/50 on attachments with a trigger
Driven in Chrome on both fixtures (light). screens/attachment-hover-focus-*.png.
↳ style-vega.css:1520-1574
✅ Animation AttachmentTitle: animation tw-shimmer 2s, background-clip text, transparent fill only when state is uploading/processing
shimmer utility ported from shadcn tailwind.css (MIT) into the install template, the docs CSS and the install pages; its prefers-reduced-motion rule (no animation, solid text) is copied as is but was not emulated in this run.
↳ bases/base/ui/attachment.tsx:97
✅ Native no Stimulus controller: native <button> and <a href> for trigger and actions, CSS for hover/focus/scroll-snap — native
↳ https://developer.mozilla.org/pt-BR/docs/Web/HTML/Element/button
✅ Spec AttachmentTrigger has no content and is named by aria-label; actions are icon buttons named by aria-label
button requires an accessible name (Name From: contents, author); both fixtures pass it via aria-label, and the accessibility tree shows the names. Trigger and actions are siblings, not nested interactive content.
↳ https://www.w3.org/TR/wai-aria-1.2/#button
Testing instructions
cd gem && bundle exec rake(includestest/ruby_ui/attachment_test.rb).cd docs && bin/dev, then open http://localhost:3000/docs/attachment.- In States, the uploading and processing titles shimmer, and the idle one has a dashed border.
- In Triggers, hover and Tab through the cards: the whole card shows hover and a focus ring, the action buttons still work, and the second example opens a dialog.
- Scroll the group sideways: it snaps to each card and fades the edge that has more content.
🤖 Generated with Claude Code
Summary by cubic
Adds the Attachment component family to RubyUI, matching shadcn's Base UI + vega build, for displaying files or images in chat composers and messages.
New Features
- Provides
Attachment,AttachmentGroup,AttachmentMedia,AttachmentContent,AttachmentTitle,AttachmentDescription,AttachmentActions,AttachmentAction, andAttachmentTrigger, built with native elements and CSS only (no Stimulus controller). AttachmentActionis aButtonsubclass defaulting to ghost/icon_xs, so it inherits all Button options; shadcn'srenderprop maps toAttachmentTrigger(as:)for buttons or links.- Adds the
shimmerutility (MIT, from shadcn) to the install template and docs CSS, animating the title while uploading or processing, stopping underprefers-reduced-motion, and guarded by@supportsso the text stays visible in browsers without relative color support. - Includes the
/docs/attachmentpage, tests, audit fixtures and component map, MCP registry entry, and aButtondependency forattachment.