# Profile

> The Profile section of an AI product’s settings. Handles photo cropping, a username checked as you type and email changes confirmed by code.

Canonical: https://hextaui.com/blocks/profile
Last updated: 2026-10-29

## Overview

ProfileSettings is the Profile page from a product like Claude or Cursor, built to drop into any SettingsShell section. Give it the saved profile and an onSave, and it handles the rest: a draft that only saves when you say so, field errors from your checks or your server, and the floating save bar from Settings with ⌘S.

At the top, a card shows how others see your profile and changes as you type: photo, name, handle, bio and links. Turn off Show my profile and the card dims and says only you can see it. Copy link puts the profile URL on the clipboard.

Pick a photo, or drop one on the row, and it opens in a crop dialog. Drag to move it, zoom with the slider, the wheel or a trackpad pinch, and the photo is cropped to a square in the browser before it reaches onSave as a data URL. Files of the wrong type, too large or under 128 pixels are refused in the row with the reason.

The username is checked as you type, without slowing typing. Checks wait 350ms after the last key, stale checks are cancelled through an AbortSignal, and names you already checked answer instantly. A taken name shows your suggestions as one-tap fixes. If you save before a check finishes, the save waits for it.

Email isn't part of the draft. Change opens a two-step dialog: enter the new address, then the 6-digit code sent to it, which checks itself when the last digit goes in. A wrong code shakes and clears, Resend unlocks after 30 seconds, and the row updates once the code is confirmed. An unverified address shows Resend link.

Links take whatever people paste: github.com/you, a full URL or a www address. Known sites get their icon, anything else its first letter. On save they're normalized to https URLs and empty ones are dropped. Addresses that aren't links or repeat another are marked one by one.

## Installation

### Step 1: Get HextaUI Pro

One payment unlocks every block, including future ones. [See pricing](https://hextaui.com/pricing).

### Step 2: Add the Pro registry to components.json

```json title="components.json"
{
  "registries": {
    "@hextaui-pro": {
      "url": "https://hextaui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${HEXTAUI_PRO_TOKEN}"
      }
    }
  }
}
```

### Step 3: Add your token

Create a token on your [account page](https://hextaui.com/account) and put it in `.env.local` as `HEXTAUI_PRO_TOKEN`.

### Step 4: Add the block

```bash
npx shadcn@latest add @hextaui-pro/profile
```

## Usage

### Wire it to your API

Pass the saved profile and an onSave that returns field errors or throws. checkUsername gets an AbortSignal, so stale checks are cancelled as people type.

```tsx
"use client"

import { SettingsSection, SettingsShell } from "../settings/settings"

import { ProfileSettings, type ProfileValues } from "@/components/blocks/profile/profile"

export function ProfilePage({ profile, email }: { profile: ProfileValues; email: string }) {
  return (
    <SettingsShell sections={[{ id: "profile", label: "Profile" }]} className="h-svh">
      <SettingsSection id="profile">
        <ProfileSettings
          profile={profile}
          email={email}
          checkUsername={async (username, signal) => {
            const response = await fetch(`/api/usernames/${username}`, { signal })
            return response.json()
          }}
          onSave={async (values) => {
            const response = await fetch("/api/profile", {
              method: "PATCH",
              body: JSON.stringify(values),
            })
            if (response.status === 409) return { username: "That username is taken." }
            if (!response.ok) throw new Error("Check your connection and try again.")
          }}
        />
      </SettingsSection>
    </SettingsShell>
  )
}
```

### Change and verify email

Add onRequestEmailCode and onVerifyEmailCode to turn on the Change button. Return a message from onRequestEmailCode to refuse an address, and false from onVerifyEmailCode for a wrong code.

```tsx
"use client"

import * as React from "react"

import { SettingsSection, SettingsShell } from "../settings/settings"

import { ProfileSettings, type ProfileValues } from "@/components/blocks/profile/profile"

export function ProfileWithEmail({ profile, account }: {
  profile: ProfileValues
  account: { email: string; verified: boolean }
}) {
  const [email, setEmail] = React.useState(account.email)

  return (
    <SettingsShell sections={[{ id: "profile", label: "Profile" }]} className="h-svh">
      <SettingsSection id="profile">
        <ProfileSettings
          profile={profile}
          email={email}
          emailVerified={account.verified}
          onSave={(values) => fetch("/api/profile", { method: "PATCH", body: JSON.stringify(values) }).then(() => {})}
          onResendVerification={() => fetch("/api/email/verify", { method: "POST" })}
          onRequestEmailCode={async (next) => {
            const response = await fetch("/api/email/change", {
              method: "POST",
              body: JSON.stringify({ email: next }),
            })
            if (response.status === 409) return "That address belongs to another account."
            if (!response.ok) throw new Error("Couldn’t send the code. Try again.")
          }}
          onVerifyEmailCode={async (next, code) => {
            const response = await fetch("/api/email/change/verify", {
              method: "POST",
              body: JSON.stringify({ email: next, code }),
            })
            return response.ok
          }}
          onEmailChange={setEmail}
        />
      </SettingsSection>
    </SettingsShell>
  )
}
```

## Anatomy

The parts you compose, from the outside in.

| Part | Description |
| --- | --- |
| `ProfileSettings` | The section: preview card, photo, name, what the assistant calls you, username, bio, public profile, links and email. |
| `ProfileCard` | The live preview of the public profile, with Copy link. Usable on its own. |
| `AvatarCropDialog` | Crops an image to a square with drag, zoom and keyboard, and returns a data URL. |
| `ChangeEmailDialog` | The two-step email change: new address, then a 6-digit code. |
| `useUsernameCheck` | Debounced, cancellable, cached availability checks for a username. |

## API reference

### ProfileSettings

Use inside a SettingsSection.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `profile` | `ProfileValues` | – | What's saved now: { avatar, name, nickname, username, bio, links, public }. When it changes and there are no edits, the draft follows it. |
| `onSave` | `(values) => void \| errors \| Promise<void \| errors>` | – | Called with trimmed values and normalized links. Return { field: message } for field errors, or throw to show the message in the save bar. |
| `email` | `string` | – | The sign-in address. |
| `emailVerified` | `boolean` | `true` | Shows Verified, or Not verified with Resend link. |
| `checkUsername` | `(username, signal) => Promise<{ available, message?, suggestions? }>` | – | Checks if a username is free. Gets the lowercased name and an AbortSignal. Without it, only the format is checked. |
| `onRequestEmailCode` | `(email) => Promise<void \| string>` | – | Sends a code to a new address. Return a message to refuse the address. With onVerifyEmailCode, turns on Change. |
| `onVerifyEmailCode` | `(email, code) => Promise<boolean>` | – | Checks the code. Return false for a wrong code, or throw to show your message. |
| `onEmailChange` | `(email) => void` | – | Called once the new address is confirmed. |
| `onResendVerification` | `() => Promise<unknown>` | – | Adds Resend link while the address is unverified. |
| `profileUrl` | `(username) => string` | `https://hexta.app/@username` | The public profile URL, shown under the username and copied by Copy link. |
| `assistantName` | `string` | `"Hexta"` | Used in “What should Hexta call you?”. |
| `maxAvatarBytes` | `number` | `5 MB` | Largest photo accepted. |
| `maxLinks` | `number` | `5` | How many links a profile can have. |
| `maxBio` | `number` | `160` | Bio length, with a counter. |

### ProfileCard

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `profile` | `{ avatar, name, username, bio, links, public }` | – | What to show. |
| `url` | `string` | – | The profile URL to show and copy. |
| `onCopied` | `() => void` | – | Called after the link is copied. |

### AvatarCropDialog

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `source` | `{ url, width, height } \| null` | – | The image to crop. Open while set. |
| `onOpenChange` | `(open) => void` | – | Clear source when it closes. |
| `onApply` | `(dataUrl) => void` | – | Gets the cropped square as WebP, or PNG where WebP isn't supported. |
| `outputSize` | `number` | `512` | Largest side of the output in pixels. Never upscales past the crop. |
| `maxZoom` | `number` | `4` | How far you can zoom in. |

### ChangeEmailDialog

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `open` | `boolean` | – | Whether it's open. |
| `currentEmail` | `string` | – | Shown in the intro and refused as the new address. |
| `onRequestCode` | `(email) => Promise<void \| string>` | – | Sends the code. Return a message to refuse. |
| `onVerifyCode` | `(email, code) => Promise<boolean>` | – | Checks the code. |
| `onChanged` | `(email) => void` | – | Called after the code is confirmed, before the dialog closes. |
| `resendAfter` | `number` | `30` | Seconds before Resend code unlocks. |

### useUsernameCheck(username, options)

Returns { status, result, problem, retry, resolve }. status is idle, invalid, checking, available, taken or error.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `current` | `string` | – | The saved username, which is never checked. |
| `check` | `(username, signal) => Promise<UsernameCheck>` | – | Your availability check. |
| `delay` | `number` | `350` | Milliseconds to wait after typing stops. |

## Keyboard

| Key | Action |
| --- | --- |
| `Enter` | In the last link, adds another link and moves to it. |
| `←` `→` `↑` `↓` | In the crop dialog, move the photo. Shift moves farther. |
| `+` `−` | In the crop dialog, zoom in and out. 0 resets. |
| `⌘` `S` | Saves while something is unsaved. Ctrl+S on Windows and Linux. |
| `Esc` | Closes a dialog and returns focus to the button that opened it. |

## Accessibility

- Every field is named by its row, and buttons that repeat a word say what they act on: Upload photo, Change email, Remove link 2, github.com/you.
- Username results, copied links, photo changes, removed links and a changed email are announced politely. Checking itself isn't announced, so typing stays quiet.
- Field errors mark only the field at fault, and focus moves to the first one when a save is refused. The email code announces checking, confirmed and wrong.
- Removing a link moves focus to the next link, or to Add link when none are left. Removing the photo moves focus to Upload.
- The crop area is focusable and works with arrow keys and plus and minus, and the zoom slider says its value as a percentage.
- On touch screens, inputs use 16px text so iOS doesn't zoom, and icon buttons have 44px targets.

## Built with

The free HextaUI components Profile is made from. Each one installs on its own.

- [Avatar](https://hextaui.com/docs/avatar) - User photos with an initials fallback, status badges and stacked groups that collapse into a count.
- [Badge](https://hextaui.com/docs/badge) - Status labels with colored dots, removable tags that slide closed and counts that roll to their new value.
- [Button](https://hextaui.com/docs/button) - Buttons in every variant and size, with a built-in loading, success and error flow that skips the spinner for fast requests.
- [Dialog](https://hextaui.com/docs/dialog) - A window over the page for forms and focused tasks, with a pinned header and footer, nesting, and a swipeable bottom sheet on phones.
- [Field](https://hextaui.com/docs/field) - Labels, descriptions and errors wired to their control, with validation states and layouts for forms.
- [Input](https://hextaui.com/docs/input) - A text input with three sizes, invalid and read-only states, native validation styling and a 16px touch font so phones never zoom in.
- [Input group](https://hextaui.com/docs/input-group) - An input with icons, text, buttons or a keyboard hint attached, sharing one border and focus ring.
- [Input OTP](https://hextaui.com/docs/input-otp) - One-time code slots that take typing, paste and SMS autofill, with an opt-in animation that cascades codes in and a status for verifying.
- [Slider](https://hextaui.com/docs/slider) - Pick a value or a range by dragging, tapping the track or using the keys, with jumps that glide and an optional value bubble.
- [Spinner](https://hextaui.com/docs/spinner) - A loading indicator with Apple-style ticks or a breathing ring that can wait before showing and stay long enough not to flicker.
- [Switch](https://hextaui.com/docs/switch) - An on/off toggle you can tap, press or drag, with a thumb that stretches under your finger and an optional pending state for saves.

## Code

6 files, added to components/blocks/profile.
