Skip to main content

Starwind UI v3.0 is now available! Migration guide

JD

Installation

Usage

size

JD JD JD

variant

JD JD JD JD JD JD JD

image

Rather than passing an image URL, you can also pass an imported image to the AvatarImage component. This will optimize the image using the astro:assets <Image/> component.

GC

Fallback

When an image fails to load or isn’t provided, the fallback content will be displayed.

WR

API Reference

Styled Component API

These props are added or materially changed by the installed styled component. Standard HTML attributes remain available through the inherited interfaces noted below. Expand a prop to see named type definitions and framework-specific imports. Follow the Primitive and Runtime links for lower-level behavior props.

Avatar

Inherits span attributes.

Contains the following additional props:

Prop Type Default Toggle details
size "sm" | "md" | "lg" "md"
Description
Selects the component's visual size.
Classification
Styled variant
variant "default" | "primary" | "secondary" | "info" | "success" | "warning" | "error" "default"
Description
Selects the component's visual variant.
Classification
Styled variant

Avatar Image

Inherits img attributes. Omits `children`.

Contains the following additional props:

Prop Type Default Toggle details
alt Required string
Description
Provides alternative text for the rendered image.
Classification
Wrapper prop
image ImageMetadata
Description
Provides Astro image metadata for optimized image rendering.
Classification
Wrapper prop
src string
Description
Provides the media source URL.
Classification
Wrapper prop

Primitive And Runtime API

Use these references when you need the lower-level behavior APIs behind Avatar.

Primitive API

Runtime API

Avatar primitive
createAvatar from @starwind-ui/runtime/avatar

Changelog

v2.0.2

  • Named the generated aggregate default export so React and Astro tooling can identify the installed component cleanly.

v2.0.1

  • Rendered Avatar roots as inline flex containers so the small, medium, and large size variants produce exact circles while preserving image-loading and fallback visibility.

v2.0.0

  • Rebuilt Avatar on Starwind Runtime for image loading and fallback state.
  • See the Avatar Primitive for the underlying unstyled anatomy and behavior API.

v1.2.3

  • Refactor tailwind variants functions into separate variants.ts file

v1.2.1

  • Add the ability to pass additional attributes to components

v1.2.0

  • Add a data-slot attribute to all components to enable global styling updates

v1.1.1

  • Adjust component to use type VariantProps from tailwind-variants. This provides greater type safety and cleans up component frontmatter.
  • Add eslint disable comment for using the “onerror” function which allows us to handle an image that doesn’t load. This allows us to display the fallback content.

v1.1.0

  • tailwind-variants now implemented. This uses tailwind-merge under the hood to merge Tailwind classes without style conflicts, allowing you to override any existing classes using the “class” prop.