Grasco
Profile Picture UI

Styling & Customization

CSS custom properties, animations, and theming

The Profile Picture component uses CSS custom properties for theming, ships with a set of keyframe animations, and renders in the Light DOM for full compatibility with utility-class frameworks like Tailwind CSS.

CSS Custom Properties

Override these properties on the profile-picture element (or any ancestor) to customize the look and feel.

PropertyDefaultDescription
--pp-transition-duration200msTransition duration
--pp-transition-timingcubic-bezier(0.4, 0, 0.2, 1)Transition timing function
--pp-spring-timingcubic-bezier(0.34, 1.56, 0.64, 1)Spring animation timing
--pp-hover-scale1.05Scale on hover
--pp-press-scale0.95Scale on press
--pp-focus-ring-colorrgba(99, 102, 241, 0.5)Focus ring color
--pp-focus-ring-width3pxFocus ring width
--pp-skeleton-base#e5e7ebSkeleton base color
--pp-skeleton-shine#f3f4f6Skeleton shine color

Example

profile-picture {
  --pp-hover-scale: 1.1;
  --pp-transition-duration: 300ms;
  --pp-focus-ring-color: rgba(59, 130, 246, 0.5);
}

You can scope overrides to specific contexts:

/* Larger hover effect in hero sections */
.hero profile-picture {
  --pp-hover-scale: 1.15;
  --pp-spring-timing: cubic-bezier(0.22, 1.8, 0.64, 1);
}

/* Subtler transitions in dense lists */
.user-list profile-picture {
  --pp-hover-scale: 1.02;
  --pp-transition-duration: 150ms;
}

Animations

The component registers the following @keyframes animations. They are used internally but can be referenced or overridden in your own styles.

AnimationDescription
pp-shimmerShimmer loading effect
pp-pulseGentle breathe effect
pp-skeletonSkeleton pulse
pp-badge-bounceBadge entrance bounce
pp-ring-rotateRing rotation (gradient rings)
pp-presence-pulsePresence indicator pulse
pp-glowGlow animation
pp-fade-inFade in
pp-scale-inScale in (spring-like)

Tailwind Integration

Because the component renders in the Light DOM, Tailwind utility classes work directly on internal elements. To ensure that dynamically generated class names are included in your production build, import the provided safelist:

import safelist from '@grasco/profile-picture/tailwind.safelist';

Then add the safelist to your Tailwind config:

// tailwind.config.ts
import safelist from '@grasco/profile-picture/tailwind.safelist';

export default {
  // ...
  safelist,
};

This guarantees that all component-generated utility classes survive tree-shaking during the CSS purge step.

Reduced Motion

The component respects the prefers-reduced-motion media query. When the user has requested reduced motion at the OS level:

  • Hover scale and press scale transitions are disabled.
  • Shimmer, pulse, glow, and bounce animations are replaced with simple opacity fades or removed entirely.
  • Presence pulse and ring rotation animations are paused.

No additional configuration is needed — this behavior is built in and automatic.

On this page