File Size Format
retab-ui/file-size-formatFreeComponent
A small byte-size display formatter for file UI components.
Install it
npx shadcn@latest add https://ui.retab.com/r/file-size-format.jsonSource
1export function formatFileSize(bytes: number): string {2 if (bytes === 0) return "0 B";34 const units = ["B", "KB", "MB", "GB"];5 const unitIndex = Math.min(6 Math.floor(Math.log(bytes) / Math.log(1024)),7 units.length - 1,8 );910 return `${(bytes / 1024 ** unitIndex).toFixed(unitIndex === 0 ? 0 : 1)} ${11 units[unitIndex]12 }`;13}
Files it writes
More from retab-ui
All 130 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Alertalert | retab-ui | Components | Free | 1 dep | |
| Alert Dialogalert-dialog | retab-ui | Components | Free | 1 dep | |
| Aspect Ratioaspect-ratio | retab-ui | Components | Free | no deps | |
| Attachment Sidebarattachment-sidebar | retab-ui | Components | Free | 1 dep | |
| Autocompleteautocomplete | retab-ui | Components | Free | 2 deps | |
| Calendarcalendar | retab-ui | Components | Free | 2 deps | |
| Code Viewercode-viewer | retab-ui | Components | Free | 2 deps · 32 files | |
| Commandcommand | retab-ui | Components | Free | 2 deps |
