🎨
Valence
🎨
Valence
  • Overview
    • 👋Welcome to Valence
    • 🏄‍♂️Getting started
  • Core Concepts
    • Responsiveness
    • Color
      • List of colors
      • Color types
    • Polymorphism
  • Valence Core
    • 🏃‍♂️Fundamentals
      • 🎬The ValenceProvider
      • ✍️Using custom fonts
    • 🧱Components
      • 🔘Buttons
        • Button with icon
        • Grid Button
        • Text button
        • Icon button
        • Multi-part button
        • Unstyled button
        • Primitive button
      • ⌨️Inputs
        • Color Picker
        • Text input
        • Text area
        • Number input
        • Select input
        • Switch
        • Slider
        • Range slider
        • Pill selector
        • Input container
        • Dropdown container
      • 🖥️Display
        • Accordion
        • Alert
        • Color Swatch
        • Icon
        • Image
        • Avatar
        • Avatar Group
        • Loader
        • Pill
        • Spoiler
        • Stepper
        • Text
        • Title
      • 🧩Layout
        • App Container
        • Card
        • Flex
          • Flex Center
          • Styled Flex
        • Floating Toolbar
        • Grid
        • Header
        • Overflow Container
        • Space
      • 🗺️Navigation
        • App Nav
      • 🔼Overlays
        • Modal
        • Tooltip
        • Modal background
        • 📰Sheets
          • Bottom Sheet
          • Dynamic Sheet
          • Side Sheet
    • 🪝Hooks
      • UseColorScheme
      • UseColors
      • UseControlledList
      • UseDetectKeyDown
      • UseDisclosure
      • UseFloating
      • UseTooltip
      • UseBreakpoint
      • UseResponsiveProps
    • 🤚Generics
      • Generic button props
      • Generic input props
      • Generic Sheet Props
  • Valence Plugins
    • 🎠Valence Carousel
      • Carousel Child Props
  • Valence Utils
    • ✋Generics
      • Clickable
      • Events
      • Global
      • Grid
      • Layout
      • Overlay
      • Polymorphic
    • 🧜‍♀️Polymorphism
      • Polymorphic Button
      • Polymorphic Layout
      • Polymorphic Text
  • Update Notes
    • 3.0.0
    • 2.7.0
    • 2.6.0
    • 2.5.0
    • 2.4.0
    • 2.3.0
    • 2.2.0
    • 2.1.0
    • 2.0.0
Powered by GitBook
On this page
  • Usage
  • Overriding default props
  • Setting a fill variant
  • Customizing the placeholder
  • Props
  • Changelog

Was this helpful?

Edit on GitHub
  1. Valence Core
  2. Components
  3. Display

Avatar

Last update: 2.1.0 (30/01/2024)

PreviousImageNextAvatar Group

Last updated 1 year ago

Was this helpful?

The Avatar component builds upon the component, appearing as a round image with a custom icon placeholder.

Usage

import { Avatar } from "@valence-ui/core";

function MyComponent() { 
    return ( 
        <Avatar
            src="https://images.unsplash.com/photo-1419242902214-272b3f66ee7a?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=720&q=80"
            alt="A nice avatar!"
        />
    )
}

Overriding default props

import { Avatar } from "@valence-ui/core";
import { IconUserCircle } from "@tabler/icons-react";

function MyComponent() { 
    return ( 
        <Avatar
            src="https://images.unsplash.com/photo-1419242902214-272b3f66ee7a?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=720&q=80"
            alt="A nice avatar!"
            
            square={false}
            radius="sm"
            placeholder={<IconUserCircle />}
        />
    )
}

Setting a fill variant

import { Avatar } from "@valence-ui/core";

function MyComponent() { 
    return ( 
        <Avatar
            src="https://images.unsplash.com/photo-1419242902214-272b3f66ee7a?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=720&q=80"
            alt="A nice avatar!"
            
            variant="filled"     // Defaults to theme default
        />
    )
}

Customizing the placeholder

import { Avatar } from "@valence-ui/core";

function MyComponent() { 
    return ( 
        <Avatar
            src="https://images.unsplash.com/photo-1419242902214-272b3f66ee7a?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=720&q=80"
            alt="A nice avatar!"
            
            placeholderColor="blue"
        />
    )
}

Props

Property
Type
Description

variant

FillVariant

Defines the fill variant for this avatar. Defaults to theme default.

size

ComponentSize

Defines the size of this avatar. Defaults to theme default.

outline

boolean

Whether to render an outline in the placeholder.

secondaryIcon

ReactNode

An optional secondary icon to display near the avatar.

secondaryIconProps

Props to apply to the secondary icon, if it exists.

spanStyle

CSSProperties

Optional styles to pass to the containing span component.


Changelog

  • 2.1.0:

    • Removed placeholderColor prop; use color instead.

    • Added size, outline, spanStyle, secondaryIcon and secondaryIconProps props.

Extends .

🧱
🖥️
Image
ImageProps
IconProps