SDropZone <s-drop-zone>
ts
import { SDropZone } from 'polaris-vue-elements'Example
Value: (empty)
vue
<script setup>
import { ref } from 'vue'
import { SDropZone } from 'polaris-vue-elements'
const value = ref('')
</script>
<template>
<SDropZone label="Upload a file" accept="image/*" v-model="value" />
<p>Value: {{ value }}</p>
</template>v-model
v-model on <SDropZone> binds to the value property and listens for the input DOM event.
template
<SDropZone v-model="value" />is equivalent to:
template
<SDropZone :value="value" @input="value = $event.target.value" />Props
| Prop | Type | Description |
|---|---|---|
accept | string | A string representing the types of files that are accepted by the drop zone. This string is a comma-separated list of unique file type specifiers which can be one of the following: - A file extension starting with a period (".") character (e.g. .jpg, .pdf, .doc) - A valid MIME type string with no extensions If omitted, all file types are accepted. |
accessibilityLabel | string | A label that describes the purpose or contents of the item. When set, it will be announced to buyers using assistive technologies and will provide them with more context. |
disabled | boolean | Disables the field, disallowing any interaction. |
error | any | Indicate an error to the user. The field will be given a specific stylistic treatment to communicate problems that have to be resolved immediately. |
files | readonly File[] | An array of File objects representing the files currently selected by the user. This property is read-only and cannot be directly modified. To clear the selected files, set the value prop to an empty string or null. |
label | any | Content to use as the field label. |
labelAccessibilityVisibility | "visible" | "exclusive" | Changes the visibility of the component's label. - visible: the label is visible to all users. - exclusive: the label is visually hidden but remains in the accessibility tree. |
multiple | boolean | Whether multiple files can be selected or dropped at once. |
name | string | An identifier for the field that is unique within the nearest containing form. |
required | boolean | Whether the field needs a value. This requirement adds semantic value to the field, but it will not cause an error to appear automatically. If you want to present an error when this field is empty, you can do so with the error property. |
value | string | A string that represents the path to the selected file(s). If no file is selected yet, the value is an empty string (""). When the user selected multiple files, the value represents the first file in the list of files they selected. The value is always the file's name prefixed with "C:\fakepath", which isn't the real path of the file. |
Events
| Event | Type |
|---|---|
change | CustomEvent |
droprejected | CustomEvent |
input | CustomEvent |
Listen for these with @change-style listeners on <SDropZone>.
Slots
| Slot | Description |
|---|---|
default | Content to display inside the drop zone, such as upload instructions, file type icons, or previews of selected files. When provided, replaces the default upload prompt. |