1.1.0 • Published 2 years ago

react-codepen-embed v1.1.0

Weekly downloads
123
License
MIT
Repository
github
Last release
2 years ago

react-codepen-embed

React component for embedding pens from Codepen.io

Installation

#using npm cli
npm install --save react-codepen-embed

#using yarn
yarn add react-codepen-embed

Usage

import React from "react";
import Codepen from "react-codepen-embed";

const CodepenEmbedded = () => {
  return <Codepen hash="JyxeVP" user="shettypuneeth" />;
};

Component Props

PropertyTypeRequiredDefaultDescription
hashstringtrueId of the pen to embed
userstringtrueCodepen username
heightnumberfalse300Height of the pen
loaderelementfalseLoader to render while the pen is being embedded or errors out
defaultTabstringfalsecss,resultDefault tab to display
themeIdstringfalsedarkTheme for the pen
previewbooleanfalsetrueMake the preview "Click-to-Load"
editablebooleanfalsefalseCan edit code
titlestringfalseTitle of the pen

API

Props.loader

Compenent to render when the pen is being embedded or when it errors.

<Codepen
  hash="JyxeVP"
  user="shettypuneeth"
  loader={() => <div>Loading...</div>}
/>

If the embed fails then the loader component will receive an error prop

const Loading = props => {
  if (props.error) {
    return <div>Error</div>;
  }
  return <div>Loading...</div>;
};
1.1.0

2 years ago

1.0.2

3 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.1.0

6 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago