# Format Byte (SVELTE)



## 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.

```svelte
<script lang="ts">
  import { Format } from '@ark-ui/svelte/format'
  import styles from 'styles/format.module.css'
</script>

<div class={styles.Root}>
  <span class={styles.Label}>File size</span>
  <span class={styles.Value}>
    <Format.Byte value={120000} />
  </span>
</div>
```

### Sizes

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

```svelte
<script lang="ts">
  import { Format } from '@ark-ui/svelte/format'
  import styles from 'styles/format.module.css'

  const byteSizes = [50, 5000, 5000000, 5000000000]
</script>

<div class={styles.List}>
  {#each byteSizes as size (size)}
    <div class={styles.ListItem}>
      <span class={styles.Value}>
        <Format.Byte value={size} />
      </span>
    </div>
  {/each}
</div>
```

### Locale

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

```svelte
<script lang="ts">
  import { Format } from '@ark-ui/svelte/format'
  import { LocaleProvider } from '@ark-ui/svelte/locale'
  import styles from 'styles/format.module.css'

  const locales = ['de-DE', 'zh-CN']
</script>

<div class={styles.List}>
  {#each locales as locale (locale)}
    <LocaleProvider {locale}>
      <div class={styles.ListItem}>
        <span class={styles.InlineLabel}>{locale}:</span>
        <span class={styles.Value}>
          <Format.Byte value={1450.45} />
        </span>
      </div>
    </LocaleProvider>
  {/each}
</div>
```

### Unit

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

```svelte
<script lang="ts">
  import { Format } from '@ark-ui/svelte/format'
  import styles from 'styles/format.module.css'
</script>

<div class={styles.Inline}>
  <span class={styles.InlineLabel}>File size:</span>
  <span class={styles.InlineValue}>
    <Format.Byte value={1450.45} unit="bit" />
  </span>
</div>
```

### Unit Display

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

```svelte
<script lang="ts">
  import { Format } from '@ark-ui/svelte/format'
  import styles from 'styles/format.module.css'

  const unitDisplays = ['narrow', 'short', 'long'] as const
</script>

<div class={styles.List}>
  {#each unitDisplays as unitDisplay (unitDisplay)}
    <div class={styles.ListItem}>
      <span class={styles.InlineLabel}>{unitDisplay}:</span>
      <span class={styles.Value}>
        <Format.Byte value={50345.53} {unitDisplay} />
      </span>
    </div>
  {/each}
</div>
```

### Unit System

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

```svelte
<script lang="ts">
  import { Format } from '@ark-ui/svelte/format'
  import styles from 'styles/format.module.css'
</script>

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