useFormatByte

useFormatByte is a custom hook for formatting bytes.

1.02 kB

1.05 MB

1.07 GB

1.1 TB

Usage

import { useFormatByte } from "@yamada-ui/react"
const kilobyte = useFormatByte(1024)

Changing the Locale

To change the locale, set a value for locale.

en-US

1.02 kB

ja-JP

1.02 KB

de-DE

1,02 kB

Set the Locale for the Entire Application

If you want to set the locale for the entire application, set the locale for the UIProvider.

import { UIProvider } from "@yamada-ui/react"

const App = () => {
  return (
    <UIProvider locale="en-US">
      <FormatByte value={1024} />
    </UIProvider>
  )
}

Unit Format

To convert units, set unit to either "byte" or "bit". The default is "byte".

Bytes

1.02 kB

Bits

1.02 kb

Unit Display

To change the unit display, set a value for unitDisplay.

Short

1.02 kB

Narrow

1.02kB

Long

1.02 kilobytes