Skip to content
Get started

Components

ProfileCard

Unstable: a person at a glance, a cover, the avatar, the name as the heading, what they do, a few counts and one action. Import it from @nizivo/react/unstable/profile-card.

Server component, no client JSUnstable

Examples

Basic

A card: who, what they do, three counts and Follow.

Alex Rivera

Product designer · Lisbon

Posts
142
Followers
8.2k
Following
312
import type { JSX } from 'react';
import { Avatar } from '@nizivo/react/avatar';
import { Button } from '@nizivo/react/button';
import { ProfileCard } from '@nizivo/react/unstable/profile-card';

export function ProfileCardExample(): JSX.Element {
  return (
    <div style={{ maxInlineSize: 320 }}>
      <ProfileCard
        name="Alex Rivera"
        avatar={<Avatar name="Alex Rivera" size="xl" decorative />}
        description="Product designer · Lisbon"
        stats={[
          { label: 'Posts', value: '142' },
          { label: 'Followers', value: '8.2k' },
          { label: 'Following', value: '312' },
        ]}
        action={
          <Button variant="primary" aria-pressed={false} fullWidth>
            Follow
          </Button>
        }
      />
    </div>
  );
}

Import

import { ProfileCard } from '@nizivo/react/unstable/profile-card';

// Once per app (Getting started), after
// @nizivo/tokens/tokens.css and @nizivo/react/css/base.css
import '@nizivo/react/css/profile-card.css';

Static or interactive

Server. No client JavaScript of its own; the action you pass may have some. How to choose.

Content

name is the card's heading (headingLevel, 3 by default), avatar an xl Avatar, decorative since the name follows, and description what they do. stats (up to three) is a description list, each read as "Posts, 142". action is one full-width action: for Follow, a Button with aria-pressed that becomes "Following".

The cover

The design's cover is the Aurora shader: pass cover={<ShaderSurface />} (ShaderSurface). Without it the cover is drawn with CSS gradients; cover takes any picture in its place, hidden from assistive technology.

Props

Server component Renders data-slot="profile-card" with the class nz-profile-card. Props: ProfileCardProps. Source: src/unstable/profile-card/profile-card.tsx.

NameTypeDefaultDescription
actionReactNode–

One action, full width: a Button.

avatarReactNode–

An Avatar (xl); decorative, since the name is printed under it.

coverReactNode–

Replaces the CSS cover. Decorative: hidden from assistive technology.

descriptionReactNode–

What they do and where: "Product designer · Lisbon".

headingLevel2 | 3 | 4 | 5 | 63

The name's level.

namerequiredReactNode–

The person's name: the card's heading.

renderRenderProp<Record<string, never>>–

Must render an <article>.

statsreadonly ProfileStat[]–

Up to three counts.

  • Also takes every attribute of <article> except children. (Omit<ComponentPropsWithRef<"article">, "children">)

render takes an element, or, in client code, a function of the props and no state.

Other exports

ProfileCardProps type

import type { ProfileCardProps } from '@nizivo/react/unstable/profile-card'

The props of ProfileCard, listed above.

ProfileStat type

import type { ProfileStat } from '@nizivo/react/unstable/profile-card'

One count: "142 Posts".

NameTypeDefaultDescription
labelrequiredReactNode–
valuerequiredReactNode–

Data attributes and slots

Style parts by class (.nz-<slot>) and state by data attribute. Attribute meanings come from contracts/vocabulary.json.

SlotRendered byData attributes
profile-card
.nz-profile-card
ProfileCard
root (takes render)
none
profile-card-description
.nz-profile-card-description
ProfileCard
inner element (CSS only)
none
profile-card-name
.nz-profile-card-name
ProfileCard
inner element (CSS only)
none
profile-card-stats
.nz-profile-card-stats
ProfileCard
inner element (CSS only)
none

CSS hooks

Set a hook on the component's class or any ancestor to restyle it without specificity games; leave it unset for the default shown.

This stylesheet reads no public hook.

Layers: nz.components. Classes: .nz-profile-card, .nz-profile-card-action, .nz-profile-card-avatar, .nz-profile-card-cover, .nz-profile-card-description, .nz-profile-card-name, .nz-profile-card-stat, .nz-profile-card-stat-label, .nz-profile-card-stat-value, .nz-profile-card-stats, .nz-shader-surface.

Tokens this stylesheet reads (22)

--nz-bg-accent, --nz-bg-brand-muted, --nz-bg-canvas, --nz-bg-subtle, --nz-bg-surface, --nz-border-subtle, --nz-border-width-default, --nz-font-body-s, --nz-font-heading-h3, --nz-font-label-m-strong, --nz-radius-2xl, --nz-radius-full, --nz-radius-xs, --nz-space-0-5, --nz-space-1, --nz-space-10, --nz-space-2, --nz-space-4, --nz-space-5, --nz-text-primary, --nz-text-secondary, --nz-tracking-heading-h3

Accessibility

Nothing in this component takes focus or keyboard input.

Keyboard

None.

On this page