Axon 911 Frontend DocsAxon 911 Frontend Docs
Axon 911 Frontend Docs
    Loading navigation…
U
User
Switch to light mode
  1. Components
  2. Attachment
  3. API and Development

Attachment

API and Development

View SourceOpens in a new tabSubmit IssueOpens in a new tab
Import Attachment, AttachmentMediaKind, Attachments, getAttachmentMediaMeta, normalizeMediaType from @prepared911/ui/attachment.
Attachments
PropTypeDefaultNotes
childrenReactNodeAttachments
aria-labelLocalizedMessageName of the list
classNamestring
refRef<HTMLUListElement>
Attachment
Props are a union: read-only, or removable.
PropTypeDefaultNotes
filenamestringrequiredData; truncates
mediaTypestringPicks the glyph, kind and subtype label
urlstringAn image type with a URL shows a thumbnail
descriptionLocalizedMessage | DisplayValuethe subtype of mediaTypeSupporting line
onRemoveMouseEventHandler<HTMLButtonElement>Makes the chip removable
removeLabelLocalizedMessagerequired with onRemoveName and tooltip of the remove control
classNamestring
refRef<HTMLLIElement>
data-* attributes pass to the list or the item. Reserved design-system state names are dropped with a warning.
Helpers
ExportNotes
getAttachmentMediaMeta(mediaType?){ glyph, kind, subtype? }
normalizeMediaType(mediaType)Lowercased, parameters removed
AttachmentMediaKindFile, Image, Video, Audio, Pdf, Code
Exports
Attachments, Attachment, AttachmentMediaKind, getAttachmentMediaMeta, normalizeMediaType, and the types AttachmentsProps, AttachmentProps and AttachmentMediaMeta.
Props
NameTypeDefaultDescription
filenamestring—File name, shown as the title. It is data, and it truncates with an ellipsis.
classNamestring—Classes appended after the generated classes.
descriptionLocalizedMessage | DisplayValue—Supporting text under the title, such as "PDF · 12 KB". With none, the short label of mediaType shows (PDF), and with neither nothing shows.
mediaTypestring—MIME type. It picks the glyph and the paint of the media tile, and, with no description, the short type label.
onRemoveMouseEventHandler<HTMLButtonElement>—Not set: the attachment has no remove control. Called when the remove control is pressed.
refRef<HTMLLIElement>—Ref to the list item.
removeLabelLocalizedMessage—Not allowed without onRemove. Accessible name and tooltip of the remove control, such as "Remove requirements.pdf".
urlstring—Source URL. With an image/* mediaType it draws as a thumbnail in the media tile. Image accepts same-origin paths, data:image/* URLs, and, here, remote http(s) URLs; it rejects blob: URLs in development.
Storybook
Interactive examples and edge cases for this component are in Storybook.
DefaultOpens in a new tab
Previous
Attachment / Usage
Next
Attachment / Accessibility
On this page
Attachments
Attachment
Helpers
Exports
Props
Storybook