# Format Byte

URL: https://ark-ui.com/docs/utilities/format-byte
LLM: https://ark-ui.com/llms.txt/utilities/format-byte

Used to format byte values with various options and units

---



## Usage

The byte formatting component extends the number formatting capabilities to handle byte-specific formatting, including
automatic unit conversion and display options.

```jsx
import { Format } from '@ark-ui/react'
```

## Examples

### Basic

Use the `Format.Byte` component to format a byte value with default options.

```tsx
import { Format } from '@ark-ui/react/format'
import styles from 'styles/format.module.css'

export const ByteBasic = () => {
  return (
    <div className={styles.Root}>
      <span className={styles.Label}>File size</span>
      <span className={styles.Value}>
        <Format.Byte value={120000} />
      </span>
    </div>
  )
}
```

### Sizes

Use the `sizes` prop to specify custom byte sizes for formatting.

```tsx
import { Format } from '@ark-ui/react/format'
import styles from 'styles/format.module.css'

export const ByteSizes = () => {
  const byteSizes = [50, 5000, 5000000, 5000000000]

  return (
    <div className={styles.List}>
      {byteSizes.map((size) => (
        <div key={size} className={styles.ListItem}>
          <span className={styles.Value}>
            <Format.Byte value={size} />
          </span>
        </div>
      ))}
    </div>
  )
}
```

### Locale

Use the `locale` prop to format the byte value according to a specific locale.

```tsx
import { Format } from '@ark-ui/react/format'
import { LocaleProvider } from '@ark-ui/react/locale'
import styles from 'styles/format.module.css'

export const ByteWithLocale = () => {
  const locales = ['de-DE', 'zh-CN']

  return (
    <div className={styles.List}>
      {locales.map((locale) => (
        <LocaleProvider key={locale} locale={locale}>
          <div className={styles.ListItem}>
            <span className={styles.InlineLabel}>{locale}:</span>
            <span className={styles.Value}>
              <Format.Byte value={1450.45} />
            </span>
          </div>
        </LocaleProvider>
      ))}
    </div>
  )
}
```

### Unit

Use the `unit` prop to specify the unit of the byte value.

```tsx
import { Format } from '@ark-ui/react/format'
import styles from 'styles/format.module.css'

export const ByteWithUnit = () => {
  return (
    <div className={styles.Inline}>
      <span className={styles.InlineLabel}>File size:</span>
      <span className={styles.InlineValue}>
        <Format.Byte value={1450.45} unit="bit" />
      </span>
    </div>
  )
}
```

### Unit Display

Use the `unitDisplay` prop to specify the display of the unit.

```tsx
import { Format } from '@ark-ui/react/format'
import styles from 'styles/format.module.css'

export const ByteWithUnitDisplay = () => {
  const unitDisplays = ['narrow', 'short', 'long'] as const

  return (
    <div className={styles.List}>
      {unitDisplays.map((unitDisplay) => (
        <div key={unitDisplay} className={styles.ListItem}>
          <span className={styles.InlineLabel}>{unitDisplay}:</span>
          <span className={styles.Value}>
            <Format.Byte value={50345.53} unitDisplay={unitDisplay} />
          </span>
        </div>
      ))}
    </div>
  )
}
```

### Unit System

Use the `unitSystem` prop to specify whether to use decimal (1000 bytes) or binary (1024 bytes) unit system.

```tsx
import { Format } from '@ark-ui/react/format'
import styles from 'styles/format.module.css'

export const ByteWithUnitSystem = () => {
  return (
    <div className={styles.List}>
      <div className={styles.ListItem}>
        <span className={styles.InlineLabel}>Decimal (1000 bytes):</span>
        <span className={styles.InlineValue}>
          <Format.Byte value={1024} unitSystem="decimal" />
        </span>
      </div>
      <div className={styles.ListItem}>
        <span className={styles.InlineLabel}>Binary (1024 bytes):</span>
        <span className={styles.InlineValue}>
          <Format.Byte value={1024} unitSystem="binary" />
        </span>
      </div>
    </div>
  )
}
```