import { Story, Canvas, ArgsTable } from '@storybook/addon-docs'; import { BadgeWrapper } from './badge-wrapper'; # BadgeWrapper The `BadgeWrapper` positions a badge on top of another component ## Props The `BadgeWrapper` accepts all props below as well as all [Box](/docs/components-ui-box--default-story#props) component props. ### Children Use the `children` prop to define the element to be wrapped by the `BadgeWrapper`. This element will be what the badge is positioned on top of. ```jsx import { Color, Size } from '../../../helpers/constants/design-system'; import { AvatarAccount, AvatarNetwork, AvatarToken, BadgeWrapper, BadgeWrapperAnchorElementShape, BadgeWrapperPosition, } from '../../component-library'; } > } > } anchorElementShape={BadgeWrapperAnchorElementShape.rectangular} > ``` ### Badge Use the `badge` prop to define the badge component to be rendered on top of the `children` component. To access the component containing the badge, use the `badgeContainerProps` prop. The wrapping component is a `Box` and accepts all box props. ```jsx import { BorderColor, BorderRadius, Color, IconColor, Size, } from '../../../helpers/constants/design-system'; import { AvatarAccount, AvatarNetwork, BadgeWrapper, BadgeWrapperAnchorElementShape, Icon, ICON_NAMES, Tag, } from '../../component-library'; } > } > } anchorElementShape={BadgeWrapperAnchorElementShape.rectangular} > NFTs ``` ### Position Use the `position` prop and the `BadgeWrapperPosition` enum to set the position of the badge. Possible positions are: - top left `BadgeWrapperPosition.topLeft` - top right `BadgeWrapperPosition.topRight` - bottom left `BadgeWrapperPosition.bottomLeft` - bottom right `BadgeWrapperPosition.bottomRight` If you require a custom position, you can use the `positionObj` prop see [Position Obj](/docs/components-componentlibrary-badgewrapper--position-obj#position-obj) for more details. ```jsx import { BorderColor Size } from '../../../helpers/constants/design-system'; import { AvatarAccount, AvatarNetwork, BadgeWrapper, BadgeWrapperPosition } from '../../component-library'; } > } > } > } > ``` ### Position Obj Use the `positionObj` prop to set a custom position for the badge. The `positionObj` prop takes an object with the following properties: - `top` - the top position of the badge - `right` - the right position of the badge - `bottom` - the bottom position of the badge - `left` - the left position of the badge ```jsx import { BorderColor Size } from '../../../helpers/constants/design-system'; import { AvatarAccount, AvatarNetwork, BadgeWrapper, } from '../../component-library'; } positionObj={{ top: 4, right: -8 }} > ``` ### Anchor Element Shape Use the `anchorElementShape` prop and the `BadgeWrapperAnchorElementShape` enum to set the badge position relative to the shape of the anchor element. Possible shapes are: - circular `BadgeWrapperAnchorElementShape.circular` - rectangular `BadgeWrapperAnchorElementShape.rectangular` ```jsx import Box from '../../ui/box/box'; import { BorderRadius, Color } from '../../../helpers/constants/design-system'; import { BadgeWrapper, BadgeWrapperAnchorElementShape } from '../../component-library'; } > } > } > } > ```