SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

FileTrigger

A pressable surface that opens the platform's file picker, backed by a native <input type="file"> wrapped in a <label> so the platform itself handles the trigger-to-picker wiring.

Import contacts

The first row is read as the header. Columns named email and name are matched automatically; everything else is offered for mapping on the next step.

Nothing chosen yet.

View code
tsx
let chosen: File | null = null;

function readChoice(event: Event) {
	if (!(event.target instanceof HTMLInputElement)) return;
	chosen = event.target.files?.[0] ?? null;
	void handle.update();
}

<Header>Import contacts</Header>

<FileTrigger
	name="contacts"
	accept=".csv,text/csv"
	mix={[on<HTMLLabelElement, "change">("change", readChoice)]}
>
	<UploadIcon aria-hidden="true" />
	Choose a CSV
</FileTrigger>

<FileTrigger
	name="vcards"
	acceptDirectory
	variant="outline"
	color="neutral"
	mix={[on<HTMLLabelElement, "change">("change", readChoice)]}
>
	<FolderIcon aria-hidden="true" />
	Choose a vCard folder
</FileTrigger>

<Description>
	The first row is read as the header. Columns named email and name are matched
	automatically; everything else is offered for mapping on the next step.
</Description>

<Separator />

{chosen === null ? (
	<Description>Nothing chosen yet.</Description>
) : (
	<Item>
		<Item.Content>
			<Item.Title>{chosen.name}</Item.Title>
			<Item.Description>{formatFileSize(chosen.size)}</Item.Description>
		</Item.Content>
	</Item>
)}

<Button type="submit" disabled={chosen === null}>
	Import
</Button>

Demo apps

Whole pages built only from @sdxc/ui, each for an invented product with its own palette and type. They open in a new tab.

Every demo, landings and docs sites alike, is listed in the showcase.

Installation

An ordinary dependency: install it, import the theme once, and import the component where it is used.

Terminal
npm add @sdxc/ui remix
typescript
import "@sdxc/ui/theme.css";

Usage

typescript
import { FileTrigger } from "@sdxc/ui/app";

Renders a native <input type="file"> wrapped in a <label> styled through this library's shared data-color/data-variant/data-size contract; in dev mode, content lacking an accessible name logs a warning.

Examples

Several files

View code
tsx
<FileTrigger name="attachments" multiple color="brand" variant="outline">
	<PaperclipIcon aria-hidden="true" />
	Attach files
</FileTrigger>

Folder picker

View code
tsx
<FileTrigger name="folder" acceptDirectory variant="outline" aria-label="Choose a folder to import">
	<FolderIcon aria-hidden="true" />
</FileTrigger>

Props

Read from the component's own types, so every prop, every default and every allowed value is listed.

PropTypeDefaultRequiredDescription
color"brand" | "neutral" | "success" | "warning" | "danger"—NoSemantic color role. Defaults to DEFAULT_COLOR.
variant"solid" | "outline" | "ghost"—NoVisual weight. Defaults to DEFAULT_VARIANT.
size"sm" | "md" | "lg"—NoSize variant. Defaults to DEFAULT_SIZE.
acceptDirectoryboolean—NoSwitches the picker from choosing individual files to choosing whole directories, carrying every file nested inside the chosen directory.
childrenRemixNode—NoThe trigger's visible content, rendered inside the same <label> that wraps the host <input> — an icon, text, or both, kept decorative so the platform's label-to-control association reaches the input on click.
mixTagProps<"label">["mix"]—NoStyling and behavior for the visible <label>.

Also accepts everything in Omit<TagProps<"input">, "type" | "role" | "size" | "mix">.

Types

NameValuesWhat it decides
Color"brand" | "neutral" | "success" | "warning" | "danger"Semantic color role, each mapped to its matching --ui-* variables.
Variant"solid" | "outline" | "ghost"Visual weight the trigger renders with: a solid fill with an on-solid foreground, a transparent fill with a strong colored border, or a fully transparent fill with just a colored label.
Size"sm" | "md" | "lg"Size variant controlling the trigger's padding and font size.
@sdxc/ui

Can’t find it? Contact us