import React from 'react'; import { type IconOrContent, type UserData } from '../../util/utility-types'; import type { Size } from '../../util/variant-types'; type AvatarProps = { /** * Label for the given avatar. Defaults to a string using user data. */ ariaLabel?: string; /** * CSS class names that can be appended to the component. */ className?: string; /** * The URL to an image resource (loaded lazily) */ src?: string; /** * CSS properties defined for the HTML element. Includes the component's CSS Custom Properties: * * - `--avatar__bg` * - `--avatar__border` * - `--avatar__fg` */ style?: AvatarCSSProperties; /** * The user associated with this avatar * * `UserData` takes the format (`[]` key-values are optional): * * ``` * - fullName (string) * - [id] (string | number) * - [displayName] (string) * - [key:string] (string | number | boolean) * ``` */ user?: UserData; /** * Set the behavior of the avatar, based on the specified user data. * * - `default` selects a color from a set, using the user data as a "key" * - `fixed` selects a static color that does not change based on the user data * * **Default is `"default"`**. */ color?: 'default' | 'fixed'; /** * Content for the `"icon"` variant of the avatar. Takes an EDS icon name, or any content * to render in its place, sized to match `size`. Default is "person" */ icon?: IconOrContent; /** * Marking whether the Avatar is intended to be interactive (have focus/hover states) */ isInteractive?: boolean; /** * The size of the avatar */ size?: Extract; /** * Variants of how the avatar will be portrayed */ variant?: 'icon' | 'text' | 'image'; }; export interface AvatarCSSProperties extends React.CSSProperties { /** * Custom property to customize the background color of this component (e.g., background color) */ '--avatar__bg'?: string; /** * Custom property to customize the border color of this component */ '--avatar__border'?: string; /** * Custom property to customize the foreground color of this component (e.g., text, icon, etc.) */ '--avatar__fg'?: string; } export declare function getInitials(fromName: string): string; /** * ## Usage * * Avatars represent a single user in the system. The representation can be generated (using a color derived from the * user data), or include an image for each user. `Avatar` supports text, images, and multi-byte characters (e.g., emoji), * and can reference flexible metadata for the associated user. * * | Type/Use | Description | Example | * |----------|-------------|---------| * | Text | Initials generated from `user.fullName`, or a `displayName` you supply directly. | Comment authors. Member lists. Emoji stand-ins. | * | Image | A profile photo loaded from `src`, falling back to text when no source is set. | Account menus. Profile pages. | * | Icon | A named EDS icon instead of user-specific content. | Unidentified users. "Add a person" affordances. | * * ### Best Practices * * * Use avatars in places where we want to show a user as identified and logged in. * * Avatars can be used in place of regular `Button`s for triggers in certain components (e.g., `Menu`, `Tooltip`). * * ## Interaction * * Avatars support focus rings and can exist in the tab order when used as a trigger. Set `isInteractive` to get focus * and hover states. * * `Avatar` instances in a collection can overlap by 50% for efficient use of space. A hover state on the container * holding multiple instances can then remove the overlap and show every `Avatar` in full. * * ## Content & Accessibility * * ### Do's * * * Use `Avatar` to represent users in `AppHeader` when logged in. * * Use the large size `Avatar` when the component is shown in the main page area. For menus and navigation, use a smaller `Avatar`. * * ### Don'ts * * * Avoid relying on the icon or text as the only indication of which user is being represented. Use adjacent text, or `aria-*` tags for screen-reader support. * * Avoid using very large image files for user profiles in `Avatar`. Save a specific, low-resolution file for user avatar images. * * ## Resources * * * https://github.com/flmnt/graphemer */ export declare const Avatar: React.ForwardRefExoticComponent>; export {};