import { Story, Canvas, ArgsTable } from '@storybook/addon-docs';

import { PickerNetwork } from './picker-network';

# PickerNetwork

The `PickerNetwork` is used for the action of changing a network.

[MetaMask Design System Guides](https://www.notion.so/MetaMask-Design-System-Guides-Design-f86ecc914d6b4eb6873a122b83c12940)

<Canvas>
  <Story id="components-componentlibrary-pickernetwork--default-story" />
</Canvas>

## Props

<ArgsTable of={PickerNetwork} />

### Label

Use the `label` prop for the text content of the `PickerNetwork` component. For long labels set a `max-width` using a `className` and the text will truncate showing an ellipsis. If the `src` prop is not set, the `label` prop will be used to generate fallback initial for `AvatarNetwork`.

<Canvas>
  <Story id="components-componentlibrary-pickernetwork--label" />
</Canvas>

```jsx
import { PickerNetwork } from '../../ui/component-library';
<PickerNetwork src="./images/avax-token.svg" label="Avalanche C-Chain" />
<PickerNetwork label="Arbitrum One" />
<PickerNetwork label="Polygon Mainnet" />
<PickerNetwork label="Optimism" />
<PickerNetwork label="BNB Smart Chain (previously Binance Smart Chain Mainnet)" style={{ maxWidth: '200px' }} />
```

### Src

Use the `src` prop with an image url to render the `AvatarNetwork`. Use the `avatarNetworkProps` to pass additional props to the `AvatarNetwork` component. If the `src` prop is not set, the `label` prop will be used to generate fallback initial for `AvatarNetwork`.

<Canvas>
  <Story id="components-componentlibrary-pickernetwork--src" />
</Canvas>

```jsx
import { PickerNetwork } from '../../ui/component-library';
<PickerNetwork src="./images/arbitrum.svg" label="Arbitrum One" />
<PickerNetwork src="./images/pol-token.svg" label="Polygon Mainnet" />
<PickerNetwork src="./images/optimism.svg" label="Optimism" />
```

### Width

The width of the `PickerNetwork` is set to auto by default. Use the style utility `width` prop with the `BlockSize` enum to set the width of the `PickerNetwork` component.

<Canvas>
  <Story id="components-componentlibrary-pickernetwork--width" />
</Canvas>

```jsx
import { PickerNetwork } from '../../ui/component-library';
import { BlockSize } from '../../../helpers/constants/design-system';

<PickerNetwork src="./images/avax-token.svg" label="Avalanche C-Chain" />;
<PickerNetwork
  src="./images/avax-token.svg"
  label="Avalanche C-Chain"
  width={BlockSize.Full}
/>;
```
