Account Profile B
Content of account popover menu.
Preview
John Wilson
Administrator
Jane Peterson
Content Manager
This is an additional content
Code
import styles from "./account-profile-b.module.css"; type ActionType = { icon?: React.ReactElement; title?: string; showTitle?: boolean; onClick?: () => void; }; type Props = { className?: string; children?: React.ReactNode; imageSrc?: string; title: string; description?: React.ReactNode; actionTopIcon?: React.ReactNode; rounded?: "none" | "small" | "medium" | "large"; imageRounded?: "default" | "none" | "small" | "medium" | "large" | "full"; footerLeftActions?: ActionType[]; footerRightActions?: ActionType[]; // Put additional variants here, then define them in the CSS variant?: "default" | "simple"; onClickActionTop?: () => void; }; export default function AccountProfileB({ className, children, imageSrc, title, description, actionTopIcon, rounded = "small", imageRounded = "default", variant, footerLeftActions, footerRightActions, onClickActionTop, }: Props) { return ( <div className={[ styles["wrapper"], styles[`r-${rounded}`], styles[`img-r-${imageRounded}`], styles[`variant-${variant}`], className, ].join(" ")} > <div className={styles["top-action"]}> {actionTopIcon && ( <button type="button" className={styles["action-top-btn"]} onClick={() => { // add on click behavior here eg: onClickActionTop && onClickActionTop(); }} > <div className={styles["action-top-btn-icon"]}>{actionTopIcon}</div> </button> )} </div> <div className={styles["body"]}> {/* You may replace the a tag with a Link if you use NextJS, or simply remove it if you do not want link */} <div className={styles["body-wrapper"]}> <div className={styles["image-wrapper"]}> {/* You may need to replace the a tag with a Link if you use Next.js */} {/* If you use Next.js, replace 'img' with 'Image' element */} <img className={[styles["image"], styles["square"]].join(" ")} src={imageSrc} alt={title?.valueOf()?.toString()} width={360} height={360} loading="lazy" /> </div> <div className={styles["body-header"]}> <div className={styles["bh-text"]}> <div className={styles["text-content"]}> <h3 className={styles["title"]}>{title}</h3> {description && ( <div className={styles["desc"]}> {typeof description === "string" ? ( <p>{description}</p> ) : ( <>{description}</> )} </div> )} </div> </div> </div> {children && <div className={styles["body-content"]}>{children}</div>} </div> </div> <div className={styles["footer"]}> <div className={styles["f-left"]}> {/* You may replace this button with button-a, button-b, ... */} <div className={styles["f-action"]}> {footerLeftActions?.map((action, index) => ( <ActionButton key={action.title || `action-${index}`} action={action} /> ))} </div> </div> <div className={styles["f-right"]}> <div className={styles["f-action"]}> {footerRightActions?.map((action, index) => ( <ActionButton key={action.title || `action-${index}`} action={action} iconPosition={"right"} /> ))} </div> </div> </div> </div> ); } function ActionButton({ action, iconPosition = "left", }: { action: ActionType; iconPosition?: "left" | "right"; }) { return ( <button type="button" className={styles["action-button"]} title={action.title} onClick={() => { // add on click behavior here eg: action.onClick && action.onClick(); }} > {iconPosition === "left" && action.icon && ( <span className={styles["icon"]}>{action.icon}</span> )} {action.showTitle && ( <span className={styles["text"]}>{action.title}</span> )} {iconPosition === "right" && action.icon && ( <span className={styles["icon"]}>{action.icon}</span> )} </button> ); }
Design
Figma design file:
Documentation
Properties
Props of the component:
className
(string): Specifies the CSS class of the component.children
(ReactNode): React children of the component. Specifies the ReactNode placed inside the component.imageSrc
(string): Specifies the URL of the image.title
(string or ReactNode): Specifies the text or component that will be used as the title.description
(string or ReactNode): Specifies the text or component that will be used as the description.actionTopIcon
(ReactNode): Specifies the action icon component placed on top.rounded
("none" | "small" | "medium" | "large"): Specifies the border radius of the frame.imageRounded
("default" | "none" | "small" | "medium" | "large"): Specifies the border radius of the image.footerLeftActions
(Array of ActionType): Specifies the action buttons placed on the left side of the component's footer.footerRightActions
(Array of ActionType): Specifies the action buttons placed on the right side of the component's footer.variant
("default" | "simple" or a customized value): Specifies the color or theme variant of the component. Check out the "Sample CSS customization" below for an example of how to use it.onClickActionTop
(function): Fires when the action button is clicked.
ActionType item arguments
icon
(ReactElement): Specifies the action icon element.title
(string): Specifies the action title text.showTitle
(boolean): Show or hide title.onClick
(function): Fires when the action button is clicked.
Sample CSS customization
.variant-simple { --bg-color: transparent; --padding: 0px; --action-button-size: 1.25rem; --footer-padding-y: 0.5rem; --footer-padding-x: 0rem; box-shadow: none; } .variant-simple .body-content { margin-top: 0.5rem; } .variant-simple .footer { margin-top: 0.5rem; padding-top: 0.5rem; }