Demos#
Placeholder#
No value given
<Value.Upload placeholder="No value given" />
Value#
og
<Value.Upload inline value={[ { file: createMockFile('fileName-1.png', 1000000, 'image/png'), exists: false, id: '1', }, { file: createMockFile('fileName-2.png', 2000000, 'image/png'), exists: false, id: '2', }, ]} />
With displaySize property#
With download property#
Custom format#
Label#
Label text
<Value.Upload label="Label text" showEmpty />
Label and value#
Inline#
List variants#
List types#
Field.Upload path#
Using onFileClick#
Label text og
<Value.Upload label="Label text" value={[ { file: createMockFile('35217511.jpg', 1000000, 'image/png'), exists: false, id: '1', }, { file: createMockFile('1501870.jpg', 2000000, 'image/png'), exists: false, id: '2', }, ]} onFileClick={async ({ fileItem }) => { const request = createRequest() console.log( `making API request to fetch the url of the file: ${fileItem.file.name}` ) await request(2000) // Simulate a request window.open( `https://eufemia.dnb.no/images/avatars/${fileItem.file.name}`, '_blank' ) }} />
Display files as non-clickable#
When file size is 0 or not given (new File([], name, { type })), the file is displayed as a span instead of an anchor. However, when onFileClick is given, the file will be clickable as a button.