Skip to content
Components / Metrics

File size

A byte count as people read it: 25 MB, 1,5 kB.

@fabrials/ui
Loading state
  • 812 B812 B
  • 1.5 kB1,5 kB
  • 25 MB25 MB
  • Unknown size

Installation

  1. Import the control from @fabrials/ui, after setting the app up.

    TypeScript
    import { FileSize, formatBytes } from "@fabrials/ui";

API reference

Prop / exportTypeDescription
bytesnumber | null | undefinedThe count. An unknown or invalid value renders the fallback, never throws.
localestringLanguage of the number and unit.
formatBytes(locale, bytes)stringThe plain function: 1024 steps, short units, throws a RangeError for a negative or non-finite count.

Behavior

Tabular and unbroken, with the exact count in the title.

Accessibility

Keyboard and contrast
Keep visible labels, keyboard focus and status announcements when customizing. These components inherit your theme; maintain sufficient contrast in both color modes. The preview is keyboard operable.