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.
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.
| Name | Type | Default | Description |
|---|---|---|---|
action | ReactNode | – | One action, full width: a Button. |
avatar | ReactNode | – | An Avatar (xl); decorative, since the name is printed under it. |
cover | ReactNode | – | Replaces the CSS cover. Decorative: hidden from assistive technology. |
description | ReactNode | – | What they do and where: "Product designer · Lisbon". |
headingLevel | 2 | 3 | 4 | 5 | 6 | 3 | The name's level. |
namerequired | ReactNode | – | The person's name: the card's heading. |
render | RenderProp<Record<string, never>> | – | Must render an |
stats | readonly ProfileStat[] | – | Up to three counts. |
- Also takes every attribute of
<article>exceptchildren. (Omit<ComponentPropsWithRef<"article">, "children">)
render takes an element, or, in client code, a function of the props and no state.
Other exports
ProfileCardPropstypeimport type { ProfileCardProps } from '@nizivo/react/unstable/profile-card'The props of
ProfileCard, listed above.ProfileStattypeimport type { ProfileStat } from '@nizivo/react/unstable/profile-card'One count: "142 Posts".
Name Type Default Description labelrequiredReactNode– valuerequiredReactNode–
Data attributes and slots
Style parts by class (.nz-<slot>) and state by data attribute. Attribute meanings come from contracts/vocabulary.json.
| Slot | Rendered by | Data attributes |
|---|---|---|
profile-card.nz-profile-card | ProfileCardroot (takes render) | none |
profile-card-description.nz-profile-card-description | ProfileCardinner element (CSS only) | none |
profile-card-name.nz-profile-card-name | ProfileCardinner element (CSS only) | none |
profile-card-stats.nz-profile-card-stats | ProfileCardinner 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.
Popover
A small dialog anchored to its trigger, for status, quick settings and filters. It has a title, a description, any controls, and a close button; Escape or a press outside closes it, and focus returns to the trigger.
ProgressBar
A native progress bar for a task or goal, determinate or indeterminate, with a visible label and value.