Start here
  • InstallationAdd Nelumbo to a shadcn project
  • ThemingBrand accent, neutrals, dynamic color
  • Biology componentsSequences, maps, plates and trees
  • katalyx.bio

    Chemical Structure

    A molecule's skeletal formula, drawn from a SMILES string as crisp SVG. It follows the theme, scales to its box, and colors heteroatoms the conventional way, or not at all.

    Install

    npx shadcn@latest add @nelumbo/chemical-structure

    Usage

    import { ChemicalStructure } from "@/components/ui/chemical-structure"​<ChemicalStructure smiles="CN1C=NC2=C1C(=O)N(C(=O)N2C)C" name="Caffeine" showFormula />

    Basic

    Give it a SMILES string; name adds a caption and names the image for screen readers, and showFormula adds the molecular formula.

    Caffeine

    A small library

    Neurotransmitters, sugars, antibiotics, energy carriers and a kinase inhibitor. Drawings lay themselves out; rings, charges and stereo come from the SMILES.

    Caffeine

    Adenosine receptor antagonist

    Aspirin

    Acetylates COX-1 and COX-2

    Dopamine

    Catecholamine neurotransmitter

    Serotonin

    5-HT, an indoleamine

    β-D-Glucose

    Pyranose ring, all equatorial

    Penicillin G

    β-lactam fused to a thiazolidine

    ATP

    Adenosine triphosphate

    Imatinib

    BCR-ABL kinase inhibitor

    Element or mono

    color "element" colors heteroatom labels the conventional way: nitrogen blue, oxygen red, sulfur amber. "mono" keeps the whole drawing in the text color, for print or when color means something else on the page.

    element
    mono

    Highlighted atoms

    highlight takes atom-map numbers from the SMILES, the :1 in [NH:1], and draws a soft halo behind those atoms. Here, the amide nitrogen and carbonyl carbon of paracetamol, the bond that amidases cleave.

    Paracetamol
    <ChemicalStructure smiles="C[C:2](=O)[NH:1]C1=CC=C(O)C=C1" highlight={[1, 2]} />

    Try it

    The drawing updates as you type, and an invalid SMILES shows a short message instead of breaking the page.

    Try your own SMILES. This one is (S)-ibuprofen, the active enantiomer; its stereocenter is drawn as a wedge.

    Props

    PropTypeDefaultNotes
    smilesstring—The molecule, as SMILES.
    namestring—Caption, and the accessible name.
    labelstring"Chemical structure"Accessible name when there is no name.
    color"element" | "mono""element"Conventional heteroatom colors, or all text color.
    highlightnumber[][]Atom-map numbers to draw a halo behind.
    showFormulabooleanfalseShows the molecular formula.
    explicitHydrogensbooleanfalseDraws every hydrogen.
    terminalCarbonsbooleanfalseLabels terminal carbons (CH3) instead of leaving bare line ends.
    bondLengthnumber30Bond length in px at 1×; the drawing still scales to its box.