Components

Attachment

File and image attachments

Import
import { Attachment, AttachmentContent, AttachmentTitle } from "@nyte-ai/ui/attachment";

Parts for attached files and images. Your app handles uploads, previews and removal.

Usage

  • Style with className and style, not xstyle.
  • AttachmentAction uses Nyte button styles unless render replaces it.

Anatomy

PartElementParent
AttachmentGroupdivYour container
AttachmentdivAttachmentGroup
AttachmentMediadivAttachment
AttachmentContentdivAttachment
AttachmentTitlespanAttachmentContent
AttachmentDescriptionspanAttachmentContent
AttachmentTriggerbutton, or renderAttachment
AttachmentActionsdivAttachment
AttachmentActionBase UI button, or renderAttachmentActions

Examples

<Attachment state="done">
  <AttachmentContent>
    <AttachmentTitle>report.pdf</AttachmentTitle>
  </AttachmentContent>
</Attachment>

Props

Parts take native props and refs and set a matching data-slot.

PartPropTypeDefault
Attachmentstate"idle" | "uploading" | "processing" | "error" | "done""done"
Attachmentsize"default" | "sm" | "xs" | null"default"
Attachmentorientation"horizontal" | "vertical" | null"horizontal"
AttachmentMediavariant"icon" | "image" | null"icon"
AttachmentTriggerrenderReactElement | render callbackbutton
AttachmentTriggertypeNative button type"button", only without render
AttachmentActionvariant"default" | "outline" | "secondary" | "ghost" | "destructive" | "link" | null"ghost"
AttachmentActionsize"default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | null"icon-xs"

Attachment sets data-state, data-size and data-orientation. Media sets data-variant. null omits the matching class and attribute. A null action variant means "ghost".

Only AttachmentAction accepts state callbacks for className and style.

A button component that can be used to trigger actions. Renders a <button> element.

Button Props:

PropTypeDefaultDescription
focusableWhenDisabledbooleanfalseWhether the button should be focusable when disabled.
nativeButtonbooleantrueWhether the component renders a native <button> element when replacing it via the render prop. Set to false if the rendered element is not a button (for example, <div>).
classNamestring | ((state: Button.State) => string | undefined)-CSS class applied to the element, or a function that returns a class based on the component's state.
styleReact.CSSProperties | ((state: Button.State) => React.CSSProperties | undefined)-Style applied to the element, or a function that returns a style object based on the component's state.
renderReactElement | ((props: HTMLProps, state: Button.State) => ReactElement)-Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render.

Button Data Attributes:

AttributeTypeDescription
data-disabled-Present when the button is disabled.

Accessibility

Name the preview and icon-only action buttons, and give images alt text. Upload and error states are not announced.