2022-11-23 17:42:43 +01:00
import { Story, Canvas, ArgsTable } from '@storybook/addon-docs';
import { AvatarBase } from './avatar-base';
### This is a base component. It should not be used in your feature code directly but as a "base" for other UI components
# AvatarBase
The `AvatarBase` is a wrapper component responsible for enforcing dimensions and border radius for Avatar components
<Canvas>
2023-01-20 20:27:46 +01:00
<Story id="components-componentlibrary-avatarbase--default-story" />
2022-11-23 17:42:43 +01:00
</Canvas>
## Props
2023-01-20 20:27:46 +01:00
The `AvatarBase` accepts all props below as well as all [Box](/docs/components-ui-box--default-story#props) component props.
2022-11-23 17:42:43 +01:00
<ArgsTable of={AvatarBase} />
### Size
Use the `size` prop to set the size of the `AvatarBase`.
Possible sizes include:
- `xs` 16px
- `sm` 24px
- `md` 32px
- `lg` 40px
- `xl` 48px
Defaults to `md`
2023-03-17 18:06:59 +01:00
The text styles of the `AvatarBase` is based on the `size` prop. To override this use the `Text` component's `variant` prop. `AvatarBase` also accepts all `Text` component props.
2022-11-23 17:42:43 +01:00
<Canvas>
2023-01-20 20:27:46 +01:00
<Story id="components-componentlibrary-avatarbase--size" />
2022-11-23 17:42:43 +01:00
</Canvas>
```jsx
2023-05-04 02:30:07 +02:00
import { AvatarBaseSize } from '../ui/component-library/avatar-base/avatar-base.types';
import { AvatarBase } from '../../component-library/avatar-base';
<AvatarBase size={AvatarBaseSize.XS} />
<AvatarBase size={AvatarBaseSize.SM} />
<AvatarBase size={AvatarBaseSize.MD} />
<AvatarBase size={AvatarBaseSize.LG} />
<AvatarBase size={AvatarBaseSize.XL} />
2022-11-23 17:42:43 +01:00
```
### Children
The `AvatarBase` component can contain images, icons or text
<Canvas>
2023-01-20 20:27:46 +01:00
<Story id="components-componentlibrary-avatarbase--children" />
2022-11-23 17:42:43 +01:00
</Canvas>
```jsx
import { AvatarBase } from '../../component-library';
<AvatarBase>
2023-04-19 17:25:19 +02:00
<img src="./images/eth_logo.png" />
2022-11-23 17:42:43 +01:00
</AvatarBase>
<AvatarBase>
<img width="100%" src="./images/arbitrum.svg" />
</AvatarBase>
<AvatarBase>
<img width="100%" src="./images/avax-token.png" />
</AvatarBase>
<AvatarBase>A</AvatarBase>
```
### Color, Background Color And Border Color
Use the `color`, `backgroundColor` and `borderColor` props to set the text color, background-color and border-color of the `AvatarBase`.
<Canvas>
2023-01-20 20:27:46 +01:00
<Story id="components-componentlibrary-avatarbase--color-background-color-and-border-color" />
2022-11-23 17:42:43 +01:00
</Canvas>
```jsx
2023-02-02 21:15:26 +01:00
import { TextColor,
BackgroundColor,
BorderColor } from '../../../helpers/constants/design-system';
2022-11-23 17:42:43 +01:00
import { AvatarBase } from '../../component-library';
<AvatarBase>B</AvatarBase>
<AvatarBase
2023-02-02 21:15:26 +01:00
backgroundColor={BackgroundColor.goerli}
borderColor={BorderColor.goerli}
color={TextColor.primaryInverse}
2022-11-23 17:42:43 +01:00
>
G
</AvatarBase>
<AvatarBase
2023-02-02 21:15:26 +01:00
backgroundColor={BackgroundColor.sepolia}
borderColor={BorderColor.sepolia}
color={TextColor.primaryInverse}
2022-11-23 17:42:43 +01:00
>
S
</AvatarBase>
```