Lynx

Attachment Display Field

A component that displays media provided from external sources and manages them through host actions.

Available since@seed-design/lynx-react@0.8.0, @seed-design/lynx-css@0.12.0
Loading Lynx example…

Installation

If you only need basic item display, install the following package and default snippet.

npm install @seed-design/lynx-react @seed-design/lynx-css

Reorderable

If you need to reorder items, install a separate snippet that includes native horizontal long-press gesture.

npx @seed-design/cli@latest add ui:attachment-display-field-reorderable

Lynx AttachmentDisplayField does not directly call media picker or upload APIs. When the trigger is tapped, onTriggerTap is executed, and pass the AttachmentDisplayEntry[] returned by the host app's media picker to the callback's addEntries. The picsum.photos URL in the documentation examples is a fixed demo fixture and does not assume actual app native module names or bridge APIs.

Props

AttachmentDisplayField

Prop

Type

children?React.ReactNode
label?React.ReactNode
labelWeight?"medium" | "bold" | undefined
indicator?React.ReactNode
description?React.ReactNode
errorMessage?React.ReactNode
showRequiredIndicator?boolean | undefined
entries?AttachmentDisplayEntry[] | undefined
defaultEntries?AttachmentDisplayEntry[] | undefined
onEntriesChange?((entries: AttachmentDisplayEntry[]) => void) | undefined
disabled?boolean | undefined
invalid?boolean | undefined
readOnly?boolean | undefined
required?boolean | undefined
maxEntries?number | undefined
onTriggerTap?((helpers: { addEntries: (entries: AttachmentDisplayEntry[]) => void; updateEntryStatus: (id: string, details: AttachmentDisplayStatusDetails) => void; }) => void) | undefined
style?CSSProperties | undefined
className?string | undefined

AttachmentDisplay

Prop

Type

onTriggerTap(helpers: DisplayTriggerHelpers) => void
children?((context: AttachmentDisplayContextValue) => React.ReactNode) | undefined
onRetry?((entry: DisplayEntry, helpers: DisplayRetryHelpers) => void) | undefined

AttachmentDisplayItem

Prop

Type

entryAttachmentDisplayEntry
onRetry?(() => void) | undefined
children?React.ReactNode
style?CSSProperties | undefined
className?string | undefined

Usage

Compose AttachmentDisplay within AttachmentDisplayField. onTriggerTap is a callback that calls the host media picker and passes the returned entries to addEntries.

<AttachmentDisplayField defaultEntries={[]} maxEntries={10}>
  <AttachmentDisplay
    onTriggerTap={async ({ addEntries }) => {
      const entries = await hostMediaPicker();
      addEntries(entries);
    }}
  />
</AttachmentDisplayField>

hostMediaPicker is an adapter owned by your app. Do not define specific native module names in snippets or documentation; implement it to return [] when cancelled. Display entries use a URL-based model. They use id, thumbnailUrl, and status, and optionally pass progress in the uploading state. AttachmentDisplay does not handle File or Blob and does not perform file validation.

Composing Items Directly

The children of AttachmentDisplay are context render callbacks. You can directly render AttachmentDisplayItem in the order of entries, and pass native item root props and dragging variant prop to AttachmentDisplayItem. If children are omitted, the default image, uploading progress, retry, and remove action composition is automatically rendered.

<AttachmentDisplay onTriggerTap={async ({ addEntries }) => addEntries(await hostMediaPicker())}>
  {({ entries }) => entries.map((entry) => <AttachmentDisplayItem key={entry.id} entry={entry} />)}
</AttachmentDisplay>

Adding Entries

Trigger

The default AttachmentDisplay provides both a trigger and an item list. Tapping the trigger calls onTriggerTap({ addEntries, updateEntryStatus }). When passing picker results to addEntries, the maxEntries limit and single-mode (maxEntries={1}) substitution are applied.

Loading Lynx example…

Listening to Entry Changes

You can manage the list in a controlled manner using entries and onEntriesChange. Both adding via trigger and tapping delete action results are passed to onEntriesChange. The value-changes example accumulates and displays added/removed values.

Loading Lynx example…

Managing Item Status

Item status is one of pending, uploading, success, or error. Update progress and final status via updateEntryStatus in your host app's upload operations.

  • uploading: ProgressCircle is displayed, and if progress is present, that value (0–100) is shown.
  • error: If onRetry is provided, a retry action is displayed. In the retry callback, revert the same id to uploading and restart the upload.
  • success: Displays the completed thumbnail.

The example demonstrates both uploading(0 → 25 → 60) → success transitions and retry transitions for error items. These transitions are synchronous callbacks for demo fixtures; update with actual host upload results in your app.

Loading Lynx example…

Reordering Entries

Lynx does not use React's dnd-kit dependency. AttachmentDisplayReorderable uses native horizontal long-press gesture from a separate snippet, and when the gesture ends, calls reorderEntry(fromIndex, toIndex) to change the list order. Reordering gestures are blocked in disabled and readOnly states.

The SortableAttachmentDisplayItem from the separate snippet requires index. The default item map also uses explicit SortableAttachmentDisplayItem, and when using custom children callbacks, compose each item directly with that component. Callback results are not re-interpreted with Children.toArray or cloned by index.

Loading Lynx example…

Examples

Disabled

disabled prevents trigger addition and reordering gestures but allows remove action on existing items.

Loading Lynx example…

Read Only

readOnly prevents all trigger, remove, and reordering gestures. External updates to entries or hydrating the initial list are still allowed.

Loading Lynx example…

Controlled

You can control the item list externally using entries and onEntriesChange. External reset is performed by updating app state like setEntries([]).

Loading Lynx example…

Custom Inset

In a layout wrapping an actual horizontal scroll-view, you can extend the list beyond the global gutter using the --seed-attachment-input-extend-x CSS variable. The example includes a 400px gray outer container with TextField/AttachmentDisplay inside.

Loading Lynx example…

Field Integration

You can use label, indicator, description, errorMessage, and showRequiredIndicator together with Field slots. The example displays invalid and error footer when the list is empty.

Loading Lynx example…

Customizing Items

For non-default item compositions, use SeedAttachmentDisplay.Item compound slots to compose badge, progress, retry, and remove actions directly. The first fixture in the example has a representative photo badge.

Loading Lynx example…

State and Accessibility

label, description, errorMessage, indicator, and showRequiredIndicator are rendered as Field slots. The default trigger and remove action have accessibility labels provided. When composing custom actions, specify an accessibility-label that explains the meaning.

Unsupported Lynx Features

  • Browser drag-and-drop and React dnd-kit: Replace with native long-press reorder snippet.
  • HTML <input type="file">, File, Blob, object URL: Configure the host media picker to return URL-based AttachmentDisplayEntry.
  • HTML form submission and react-hook-form: Replace with app state and submit/controller adapter.

Table of contents