FileUpload
Genel görünümimport { FileFormatIcon, FileUploadArea, FileUploadCard, ImageUpload, ImageUploadShape } from '@nili/ui';Bu, kütüphanenin kendi genel görünüm sayfası — canlı olarak render ediliyor. Üstten dili veya temayı değiştirin, o da değişir.
Yükleme alanı
Bırakma hedefi. onFiles, dosyalar bırakılmış da olsa iletişim kutusundan seçilmiş de olsa bir File dizisi alır; böylece tek bir kod yolu kalır. Altında gerçek bir input vardır, bu yüzden klavye ve ekran okuyucu kullanıcıları da seçiciyi alır.
import { FileUploadArea } from "@nili/ui"
export function Example() {
return (
<FileUploadArea
multiple
accept="image/*,application/pdf"
label="Upload files"
title="Choose a file or drag it here"
description="PNG, JPG or PDF, up to 10 MB."
onFiles={(files) => upload(files)}
/>
)
}Yükleme alanı durumları
Reddedilen bir dosya için invalid — yanlış tür, çok büyük — ve kota tükendiğinde ya da form gönderilirken disabled.
import { FileUploadArea } from "@nili/ui"
export function Example() {
return (
<>
<FileUploadArea label="Upload" onFiles={onFiles} />
<FileUploadArea label="Upload" invalid onFiles={onFiles} />
<FileUploadArea label="Upload" disabled onFiles={onFiles} />
</>
)
}Dosya kartı
Yüklenmiş tek bir dosya: biçim simgesi, adı, boyutu ve durumu. progress çubuğu sürer; onRetry bir hatayla, onRemove her durumda görünür. İkisi de etiket ister, çünkü düğmeler simgedir.
import { FileUploadCard } from "@nili/ui"
export function Example() {
return (
<>
<FileUploadCard
fileName="annual-report.pdf"
fileSize="2.4 MB"
status="progress"
progress={62}
onRemove={cancel}
removeLabel="Cancel upload"
/>
<FileUploadCard
fileName="photo.png"
fileSize="840 KB"
status="success"
onRemove={remove}
removeLabel="Remove file"
/>
<FileUploadCard
fileName="archive.zip"
fileSize="18 MB"
status="error"
errorMessage="File is larger than 10 MB."
onRetry={retry}
retryLabel="Try again"
onRemove={remove}
removeLabel="Remove file"
/>
</>
)
}Dosya biçimi simgesi
Simge dosya adından türetilir; böylece karışık yüklemelerden oluşan bir liste kendini renklendirir. Sinyal vermek istediğiniz şey uzantı değilse color ile geçersiz kılın.
import { FileFormatIcon } from "@nili/ui"
export function Example() {
return (
<>
<FileFormatIcon fileName="report.pdf" />
<FileFormatIcon fileName="sheet.xlsx" />
<FileFormatIcon fileName="photo.png" size="xs" />
<FileFormatIcon fileName="anything.bin" color="purple" />
</>
)
}Görsel yükleme
Önizleme öncelikli varyant; bir avatar, şirket işareti ya da kapak için. shape çerçeveyi ve önizlemenin ima ettiği kırpmayı belirler; alignment denetimleri görselin altına ya da yanına koyar.
import { ImageUpload, Button } from "@nili/ui"
export function Example() {
return (
<>
<ImageUpload
shape="avatar"
label="Profile photo"
hint="JPG or PNG, at least 256×256."
onFiles={(files) => upload(files[0])}
actions={<Button size="xs" appearance="stroke">Choose file</Button>}
/>
<ImageUpload shape="16:9" alignment="horizontal" label="Cover" onFiles={onFiles} />
</>
)
}FileCard
dahiliVaryant eksenleri — bileşenin cva tanımından
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| status | progress | success | error | progress |
FileFormatIcon
extends Omit< ComponentPropsWithoutRef<'span'>, 'color' >
Varyant eksenleri — bileşenin cva tanımından
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| color | red | orange | yellow | green | teal | sky | blue | purple | pink | gray | gray | |
| size | md | xs | md |
Diğer proplar
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| fileName* | string | — |
FileProgress
dahiliFileProgressBar
dahiliVaryant eksenleri — bileşenin cva tanımından
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| status | progress | success | error | progress |
FileUploadArea
extends Omit< ComponentPropsWithoutRef<'label'>, 'onDrop' | 'onChange' | 'title' >
Varyant eksenleri — bileşenin cva tanımından
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| disabled | boolean | false | |
| invalid | boolean | false | |
| dragging | 'true' | 'false' | false |
Diğer proplar
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| onFiles* | (files: File[]) => void | — | |
| accept | string | — | |
| multiple | boolean | false | |
| title | ReactNode | Choose a file or drag it here | |
| description | ReactNode | — | |
| icon | ReactNode | — | |
| label | string | Upload file | Accessible name for the hidden file input. |
FileUploadCard
extends Omit< ComponentPropsWithoutRef<'div'>, 'children' >
Diğer proplar
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| fileName* | string | — | |
| fileSize | string | — | Pre-formatted — size formatting is a locale decision. |
| status | error | success | progress | progress | |
| progress | number | 0 | 0–100. Ignored unless `status` is `'progress'`. |
| errorMessage | ReactNode | — | |
| onRemove | () => void | — | |
| onRetry | () => void | — | |
| removeLabel | string | Remove | |
| retryLabel | string | Retry |
ImageUpload
extends Omit< ComponentPropsWithoutRef<'div'>, 'onChange' >
Varyant eksenleri — bileşenin cva tanımından
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| shape | avatar | company | square | 4:3 | 16:9 | square |
Diğer proplar
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| alignment | vertical | horizontal | vertical | |
| src | string | — | Preview URL. Absent means the Figma "Empty" state. |
| onFiles* | (files: File[]) => void | — | |
| accept | string | image/* | |
| label | string | Upload image | |
| hint | ReactNode | — | |
| actions | ReactNode | — | |
| alt | string |
ImageUploadRoot
dahiliVaryant eksenleri — bileşenin cva tanımından
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| alignment | vertical | horizontal | vertical |