UNPKG

@stratakit/bricks

Version:

Small, modular components for StrataKit

26 lines (25 loc) 882 B
import { jsx } from "react/jsx-runtime"; import { Role } from "@ariakit/react/role"; import { forwardRef } from "@stratakit/foundations/secret-internals"; import cx from "classnames"; const Avatar = forwardRef((props, forwardedRef) => { const { size = "medium", initials, alt, image, ...rest } = props; const isDecorative = !alt; return /* @__PURE__ */ jsx( Role.span, { role: isDecorative ? void 0 : "img", "aria-label": isDecorative ? void 0 : alt, ...rest, "data-kiwi-size": size, className: cx("\u{1F95D}-avatar", props.className), ref: forwardedRef, children: image ?? /* @__PURE__ */ jsx("abbr", { className: "\u{1F95D}-avatar-initials", "aria-hidden": "true", children: initials?.substring(0, 1) }) } ); }); DEV: Avatar.displayName = "Avatar"; var Avatar_default = Avatar; export { Avatar_default as default };