glaze/oat/upload

Oat documentation: https://oat.ink/components/upload/

A drop zone around a native file input. Selected files are shown as removable badges in the files element. This requires Oat’s JavaScript.

Recipe

import glaze/oat/upload
import lustre/attribute
import lustre/element/html

fn uploader() {
  upload.upload([], [
    html.input([
      attribute.type_("file"),
      attribute.name("files"),
      attribute.multiple(True),
      attribute.hidden(True),
    ]),
    html.button([attribute.type_("button")], [html.text("Choose files")]),
    upload.files([], [html.small([], [html.text("Drop files here")])]),
  ])
}

Values

pub fn files(
  attrs: List(attribute.Attribute(msg)),
  children: List(element.Element(msg)),
) -> element.Element(msg)

Where the selected files are listed. Its children are shown while no files are selected.

pub fn upload(
  attrs: List(attribute.Attribute(msg)),
  children: List(element.Element(msg)),
) -> element.Element(msg)
✨ Search Document