Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <h1>Custom crop and hotspots in <a href=""></a></h1>
<div id="app">
  <p id="loading">Loading...</p>
  <p>This is a demo of how to use structured content in <a href=""></a></p>
  <p>Photos from <a href=""></a></p>


                :root {
  --primary-color: #aef;
  --background-color: #1d1e22;
  --border-radius: 3px;
body {
  padding: 1em;
  background: var(--background-color);
  color: #fff;
pre {
  font-size: 11px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: break-word;
a {
  color: var(--primary-color);
.container {
  display: flex;
  flex-wrap: wrap;
.card {
  background-color: #fff;
  color: #000;
  flex-basis: 30%;
  margin: 3px;
  padding: 5px;
  border-radius: var(--border-radius);
@media only screen and (max-width: 600px) {
  .card {
      flex-basis: 100%;
img {
  width: 100%;
button {
  position: relative;
  font-size: 1em;
  display: inline-block;
  padding: 0.5em;
  border: 2px solid currentColor;
  background-color: #fff;
  margin: 1em 0 0.5em 0;
  border-radius: var(--border-radius);

.metadata {
  background: #fff;
  color: black;
  width: auto;
  margin: 1em;
  padding: 1em;
  top: 1em;
.ReactModal__Overlay--after-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
  max-height: 100vh;
  overflow-y: auto


                const client = SanityClient({
  projectId: "anokeucs",
  dataset: "production",
  useCdn: true

const query = `*[_type == 'post' && defined(mainImage)]{
         "palette": mainImage.asset->metadata.palette

const builder = SanityImageUrlBuilder(client)

function urlFor(source) {
  return builder.image(source)

class ImageExample extends React.Component {
  constructor(props) {
    this.state = {
      result: []
    this.openDialog = this.openDialog.bind(this)
    this.closeDialog = this.closeDialog.bind(this)

  componentDidMount() {
    client.fetch(query).then((result = []) => this.setState({ result }))
   openDialog(_id) {
    this.setState({ showModal: _id })
  closeDialog(_id) {
    this.setState({ showModal: '' })
  render() {
    const { result = [] } = this.state
    if (!result.length) return <div>Loading...</div>
    return (
      <div className="container">
        {{ _id, mainImage, palette }) => (
              backgroundColor: palette.dominant.background,
              color: palette.dominant.foreground
            <button onClick={() => this.openDialog(_id)}>
              Inspect metadata
              isOpen={this.state.showModal === _id}
              contentLabel="Minimal Modal Example"
              OnAfterClose={() => = 'hidden' }
OnRequestClose={() => document.body.removeAttribute('style') }
              <button onClick={() => this.closeDialog(_id)}>Close</button>
              <pre>{JSON.stringify(mainImage, null, 2)}</pre>
              <h2>Full resolution image</h2>

ReactDOM.render(<ImageExample />, document.getElementById("app"))