Protein Structure
A 3D protein viewer you can turn, zoom and point at: cartoon, tube, trace, ball and stick, spacefill or a molecular surface. It renders on the GPU with Mol*, loaded only when a structure is on screen, so pages without one stay light.
Install
npx shadcn@latest add @nelumbo/protein-structureUbiquitin
The cartoon view: helices as ribbons, strands as arrows, loops as tubes, with a black outline. K48 and K63, the lysines that chain ubiquitins together for degradation and for signalling, show their side chains. Drag to turn it.
- Helix
- Strand
- Coil
AlphaFold confidence
colorBy plddt uses AlphaFold's four confidence bands in their standard colors, so the view matches the AlphaFold database. SUMO1's ubiquitin-like core is confident; its first twenty residues and the C-terminal tail are not, and that is where the model is least reliable.
- Very high > 90
- Confident 70–90
- Low 50–70
- Very low < 50
Representations and outline
Cartoon, tube and trace follow the backbone. Ball and stick, spacefill and surface draw every atom when the data has them, with nitrogen, oxygen and sulfur in their usual colors. Shading is flat by default, plain colors with a bolder black outline and no shadows; lit adds lighting and ambient occlusion. The outline can also be a gap in the background color, none, or any CSS color.
- Helix
- Strand
- Coil
Linked to the sequence
hovered and selected pair a sequence view with the structure. Select residues in either place; the other follows.
Ubiquitin sequence, 76 residues
Press letters to select residues, or shift-press to select a run; click residues in the structure to add or remove them there. Selected residues show their side chains. Hovering either side lights up the other.
Large structures from a file
Pass url and format to load a PDB, mmCIF or BinaryCIF file straight into Mol*: every chain, thousands of atoms, still smooth to turn. This is human hemoglobin, PDB 4HHB, four chains around their heme groups.
- N terminus
- C terminus
<ProteinStructure url="https://files.rcsb.org/download/4HHB.cif" format="mmcif" />From a PDB file
parsePdb reads the first chain's heavy atoms, HELIX and SHEET records and, for AlphaFold models, the pLDDT stored in the B-factor column.
import { ProteinStructure, parsePdb } from "@/components/ui/protein-structure"const text = await fetch("https://files.rcsb.org/download/1UBQ.pdb").then((r) => r.text())<ProteinStructure residues={parsePdb(text)} highlight={[{ residue: 48, label: "K48" }]} />// AlphaFold models keep pLDDT in the B-factor column<ProteinStructure residues={parsePdb(afText, { plddt: true })} colorBy="plddt" />Props
| Prop | Type | Default | Notes |
|---|---|---|---|
residues | ProteinResidue[] | — | C-alpha { x, y, z } in Å, with optional aa, ss (H, E, C), plddt and atoms. |
url | string | — | A structure file to load instead of residues. |
format | "pdb" | "mmcif" | "bcif" | "pdb" | The file format at url. |
representation | "cartoon" | "tube" | "trace" | "ball-and-stick" | "spacefill" | "surface" | "cartoon" | How the protein is drawn. |
outline | "black" | "background" | "none" | string | "black" | Outline color; background draws a gap. |
shading | "flat" | "lit" | "flat" | Flat colors with a bolder outline, or lighting and shadows. |
colorBy | "structure" | "plddt" | "rainbow" | "plain" | "structure" | What the color shows. |
highlight | { residue, label? }[] | [] | Residues marked with a label; with atoms, their side chains show as ball and stick. |
hovered | number | null | — | The residue under the pointer, when controlled. |
onHoveredChange | (residue) => void | — | Called as the pointer moves over residues. |
selected | number[] | — | Selected residues, when controlled. Outlined, with side chains shown. |
defaultSelected | number[] | [] | Selected residues to start with, when uncontrolled. |
onSelectedChange | (residues) => void | — | Called when a click in 3D adds or removes a residue. |
firstResidue | number | 1 | Number of the first residue, for labels. |
spin | boolean | false | Turns slowly until someone drags it. Off with reduced motion. |
controls | boolean | true | Turn, zoom and reset buttons. |
legend | boolean | true | What the colors mean. |
label | string | "Protein structure" | Accessible name. |