Skip to main content
More in Learn

React JS Components

This brings Image, Grid and Content Transformer component to ease your rendering when using React JS.


With NPM:

npm install @crystallize/reactjs-components

With Yarn:

yarn add @crystallize/reactjs-components


This output an img tag with different source variations from Crystallize using srcset. Use this to easily build responsive images powered by Crystallize.

import { Image } from '@crystallize/reactjs-components/dist/image';
const imageFromCrystallize = {
    url: '...',
    variants: [...]

    sizes="(max-width: 400px) 300w, 700px"

There is a live demo:


This output videos from Crystallize using the native video element.

import { Video } from '@crystallize/reactjs-components/dist/video';
import '@crystallize/reactjs-components/assets/video/styles.css';
const videoFromCrystallize = {
    playlists: [...],
    thumbnails: [...]

    thumbnmailProps={{ sizes: "(max-width: 700px) 90vw, 700px" }}

There is a live demo:


That makes it easy to render Crystallize grids with React JS. In order to use the grid renderer you'll need to have fetched your grid model. This can be fetched fairly easily from Crystallize's API via GraphQL.

At the minimum you will need to fetch layout of each column and some properties on the item. Your query might look something like this:

query grid($id: Int!, $language: String!) {
    grid(id: $id, language: $language) {
        rows {
            columns {
                layout {
                item {

Then, inside your component, render the Grid, passing through the grid model as a prop. By default, the grid is rendered using CSS grid but it could also be a Table.

<GridRenderer grid={grid} type={GridRenderingType.Div} cellComponent={Cell} />
<GridRenderer grid={grid} type={GridRenderingType.Table} cellComponent={Cell} />
<GridRenderer grid={grid} type={GridRenderingType.RowCol} cellComponent={Cell} />

There is a live demo:

To go further

If you want full control over each of the cells, you can instead supply a function as the children of the grid component. This will allow you to iterate over each of the cells and mutate them as you please.

const children = ({ cells }) => {
    return => (
                gridColumn: `span ${cell.layout.colspan}`,
                gridRow: `span ${cell.layout.rowspan}`,

return (
    <GridRenderer grid={grid} type={GridRenderingType.Div} cellComponent={Cell}>

Content Transformer

This helps you to transform Crystallize rich text json to React html components.

const overrides: Overrides = {
    link: (props: NodeProps) => (
        <a href={props.metadata?.href}>
            <NodeContent {...props} />

<ContentTransformer json={richTextJson} overrides={overrides} />;

There is a live demo:

People showing thumbs up

Need further assistance?

Ask the Crystallize team or other enthusiasts in our slack community.

Join our slack community