Skip to content

FileInput

A file input component for selecting files with pixel-art styling.

NameCategoryDescriptionTypeDefault
color? StyleFile input color, accepts preset theme colors or custom hex values'primary' | 'success' | 'warning' | 'danger' | 'info' | string
ghost? StyleWhether to use ghost style (no border/shadow at rest, visible on hover)booleanfalse
size? SizeSize'large' | 'default' | 'small''default'
disabled? StateWhether disabledbooleanfalse
clearable? BehaviorWhether clearablebooleanfalse
accept? BehaviorNative accept attribute, restricts file typesstring
multiple? BehaviorWhether to allow multiple filesbooleanfalse
form? BehaviorNative form attribute, associates with a formstring
model-value / v-model? ContentBinding valueFileList | null
placeholder? ContentPlaceholder text when no file is selectedstring'No file chosen'
change? EventTriggered when file selection changes(value: FileList | null) => void
clear? EventTriggered on clear() => void
trigger? SlotCustom trigger button content
ref? ExposeNative file input HTML elementRef<HTMLInputElement>
open? ExposeOpen the file selection dialog() => void
clear? ExposeClear selected files() => void

Basic Usage

Basic usage of the file input component.

<template>
  <div class="demo-file-input">
    <px-file-input placeholder="Select a file..." />
  </div>
</template>

<style scoped>
.demo-file-input {
  max-width: 400px;
}
</style>

File Input Colors

Use the color prop to apply preset theme colors to the file input border and shadow.

<template>
  <div class="demo-file-input">
    <px-file-input color="primary" placeholder="Primary" />
    <px-file-input color="success" placeholder="Success" />
    <px-file-input color="warning" placeholder="Warning" />
    <px-file-input color="danger" placeholder="Danger" />
    <px-file-input color="info" placeholder="Info" />
  </div>
</template>

<style scoped>
.demo-file-input {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 400px;
}
</style>

Custom Colors

Pass any hex color string to the color prop for fully custom colored file inputs.

<template>
  <div class="demo-file-input">
    <px-file-input color="#626aef" placeholder="Indigo" />
    <px-file-input color="#f59e0b" placeholder="Amber" />
    <px-file-input color="#ec4899" placeholder="Pink" />
  </div>
</template>

<style scoped>
.demo-file-input {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 400px;
}
</style>

Ghost Style

Use the ghost prop to create borderless file inputs that reveal their border and shadow on hover. Works with both preset and custom colors.

<template>
  <div class="demo-file-input">
    <px-file-input ghost placeholder="Ghost" />
    <px-file-input ghost color="primary" placeholder="Ghost Primary" />
    <px-file-input ghost color="danger" placeholder="Ghost Danger" />
    <px-file-input ghost color="#626aef" placeholder="Ghost Custom" />
  </div>
</template>

<style scoped>
.demo-file-input {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 400px;
}
</style>

Different Sizes

Use size property to set the file input size.

<template>
  <div class="demo-file-input">
    <px-file-input size="large" placeholder="Large" />
    <px-file-input placeholder="Default" />
    <px-file-input size="small" placeholder="Small" />
  </div>
</template>

<style scoped>
.demo-file-input {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 400px;
}
</style>

Disabled

Use disabled property to disable the file input.

<template>
  <div class="demo-file-input">
    <px-file-input disabled placeholder="Disabled file input" />
  </div>
</template>

<style scoped>
.demo-file-input {
  max-width: 400px;
}
</style>

Clearable

Use clearable property to enable the clear button after a file is selected.

<template>
  <div class="demo-file-input">
    <px-file-input clearable placeholder="Select and clear" />
  </div>
</template>

<style scoped>
.demo-file-input {
  max-width: 400px;
}
</style>

Multiple Files

Use multiple property to allow selecting multiple files.

<template>
  <div class="demo-file-input">
    <px-file-input multiple clearable placeholder="Select multiple files" />
  </div>
</template>

<style scoped>
.demo-file-input {
  max-width: 400px;
}
</style>

Accept Filter

Use accept property to restrict file types.

<template>
  <div class="demo-file-input">
    <px-file-input accept="image/*" placeholder="Images only" />
    <px-file-input accept=".pdf" placeholder="PDF files only" />
    <px-file-input accept=".jpg,.png,.gif" placeholder=".jpg, .png, .gif" />
  </div>
</template>

<style scoped>
.demo-file-input {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 400px;
}
</style>