---
meta:
title: Format Bytes
description: Formats a number as a human readable bytes value.
layout: component
---
```html:preview
The file is in size.
```
{% raw %}
```jsx:react
import { useState } from 'react';
import { SlButton, SlFormatBytes, SlInput } from '@shoelace-style/shoelace/dist/react';
const App = () => {
const [value, setValue] = useState(1000);
return (
<>
The file is in size.
setValue(event.target.value)}
/>
>
);
};
```
{% endraw %}
## Examples
### Formatting Bytes
Set the `value` attribute to a number to get the value in bytes.
```html:preview
```
```jsx:react
import { SlFormatBytes } from '@shoelace-style/shoelace/dist/react';
const App = () => (
<>
>
);
```
### Formatting Bits
To get the value in bits, set the `unit` attribute to `bit`.
```html:preview
```
```jsx:react
import { SlFormatBytes } from '@shoelace-style/shoelace/dist/react';
const App = () => (
<>
>
);
```
### Localization
Use the `lang` attribute to set the number formatting locale.
```html:preview
```
```jsx:react
import { SlFormatBytes } from '@shoelace-style/shoelace/dist/react';
const App = () => (
<>
>
);
```