Socket
Socket
Sign inDemoInstall

@workday/canvas-kit-react-avatar

Package Overview
Dependencies
81
Maintainers
6
Versions
300
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @workday/canvas-kit-react-avatar

A circular user photo (or a default)


Version published
Weekly downloads
2.8K
increased by31.97%
Maintainers
6
Install size
13.5 MB
Created
Weekly downloads
 

Readme

Source

Canvas Kit Avatar

A component showing a user's photo with a circular crop.

Installation

yarn add @workday/canvas-kit-react

or

yarn add @workday/canvas-kit-react-avatar

Usage

import * as React from 'react';
import {Avatar, AvatarVariant} from '@workday/canvas-kit-react-avatar';

// Basic button with click handler
<Avatar onClick={someFunction} />

// Rendering as a div instead of a button
<Avatar as="div" />

// Using static properties on Avatar
<Avatar
  size={Avatar.Size.xs}
  variant={Avatar.Variant.Dark}
/>

// Using AvatarVariant import directly
<Avatar size={Avatar.Size.xs} variant={AvatarVariant.Dark} />

Static Properties

variant: AvatarVariant
<Avatar variant={Avatar.Variant.Dark} />

Size: SystemIconCircleSize | number
<Avatar size={Avatar.Size.xs} />

// Custom Size.
// Note: Please use the predefined sizes as it works nicely with the Canvas Design System
<Avatar size={48} />

Component Props

Required

None

Optional

variant: AvatarVariant

The variant of the avatar if using a default image.

Default: AvatarVariant.Light

VariantDescription
LightLight grey background, dark icon
DarkDark blue background, white icon

size: SystemIconCircleSize | number

The diameter of the avatar in pixels

Default: Avatar.Size.m

NameSize (px)
xs16
s24
m32
l40
xl64
xxl120

altText: string

Text describing what the avatar is showing.


url: string

The URL of the user's photo. Expects a square (1:1) photo.


ref: React.Ref<HTMLButtonElement>

A ref to the underlying <button> or <div> element.


as: 'div'

Option to display the avatar as a div instead of a button.

Keywords

FAQs

Last updated on 09 Jul 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc