Skip to content

File Size

Free

Shows a number of bytes the way people read it, such as 1.8 MB or 1.2 of 4.8 GB. The exact bytes can show in a tooltip.

  • React 19
  • Tailwind CSS 4

Added Nov 9, 2026 · MIT + Commons Clause

Playground

Loading the preview

Props

Pass the size in bytes. Put a FileSizeEmpty inside for a file whose size is not known yet.

attachments.tsx

FileSize

<data>
PropTypeDefaultDescription
bytesRequirednumber | null—The size in bytes. null, undefined, NaN, and a negative size show the empty text.
totalnumber | null—The whole, for "used of total": storage, a quota, an upload. "1.2 of 4.8 GB" when both round to one unit, else "12 MB of 2 GB". null (an unknown or unlimited total) shows the used size alone.
base10001024—The step: 1000 (default, SI: kB, MB, GB) or 1024 (IEC: KiB, MiB, GiB), for RAM and Windows.
length"long""short""short"The unit words: short (default, "1.8 MB") or long ("1.8 megabytes").
tooltipbooleanfalseA Tooltip with the exact bytes ("2,401,872 bytes") on hover, focus, and tap, a dotted underline, and one tab stop. Default false: the short text.
localestring—The BCP 47 locale. Default: the DisplayLocaleProvider locale, else "en-US".
labelsPartial<{ of: string; }>—The words (FILE_SIZE_LABELS). Keep the object stable.
childrenReactNode—A FileSizeEmpty part: the words of no value. With a value, they are not drawn.
...props<data> attributes—Every other attribute goes to the <data>, with a ref.

FileSizeEmpty

<div>
PropTypeDefaultDescription
data-slotstring—The data-slot of the root: the item's own slot ("time-ago"). Default "empty-value".
From Base UIUseRenderBase UI docs
render—Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render.
...props<div> attributes—Every other attribute goes to the <div>, with a ref.
  • Pass bytes, and total for used of total.
  • Use base={1024} for RAM or a Windows size ("1.8 MiB").
  • Use tooltip when people need the exact bytes.
  • For a bar that shows how full a quota is, use a Meter.
  • For other numbers, use Number Text.
TabWith tooltip, moves to the size and shows the exact bytes in a Tooltip.

It renders a data element, and its value attribute keeps the bytes (used/total for used of total).

A narrow no-break space sits before the unit, so the size never wraps.

Built with

Installs with File Size

Components
Full Value
  1. AddedFile Size, with Full Value.
Open the release