Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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


Save Automatically?

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.

Editor Settings

Code Indentation

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

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.


              <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"))