Skip to content
HomeCobalt

Image field

Lets a person choose the picture that stands for them or their organisation, such as a face, a logo or a cover, place it in its frame, and see it upload and save.

Examples

A profile picture on an account page. Choose a picture, or drop one on the circle, place it in the crop window, and watch it upload: grey at first, its colour rising as it goes. Replace and Remove sit beside it.
Profile picturePNG, JPEG or WebP, up to 20 MB
FailedAn upload that does not go through. The new picture stays grey under the retry arrow, the line under the label says so, and the buttons become Retry and Cancel; Cancel puts the saved picture back. Here every first try fails.
Profile picturePNG, JPEG or WebP, up to 20 MB
Shape coverA research group's cover, 3:1. A picture chosen or dropped opens in the window to be placed, and what is sent is the framed part at 1500 by 500.
CoverAt least 1500 by 500 pixels
Shape squareA firm's logo, square with the card's corner, before one is chosen. The first upload needs nothing removed, so only Upload logo shows.
LogoA square PNG keeps its transparent parts
In a cardA profile card on an account page: the picture saves on its own as soon as it is placed, and the name saves with Save, which reports its request in place and says when it fails.
Profile
Profile picturePNG, JPEG or WebP, up to 20 MB

Usage

Use it when

  • A person sets the picture that stands for them, such as a profile picture on an account page.
  • An organisation sets its logo, or a group its cover, where the picture must fit a fixed frame and is sent already cropped.

Use something else when

  • Files of any kind, or several at once, such as a booking's documents. Use FileDrop instead.
  • Photos attached to a message. Use Composer instead.
  • Someone's picture shown with no way to change it. Use Avatar instead.

Rules

General

Content

Avoid

Limits

Install

npx shadcn@latest add https://kaanarici.com/r/cobalt/image-field.json https://kaanarici.com/r/cobalt/image-crop.json
import { ImageField, imageFieldLabels, type ImageUpload } from "@/components/cobalt/ui/image-field"
import { centred, clampPlacement, coverScale, frameRatio, reach, sourceRect } from "@/lib/cobalt/image-crop"