Skip to content
Sanity
    • Platform

      Sanity Studio

      Flexible editing environment

      APIs

      Connect to anything

      Content Lake

      Real-time database

      Try product demo

      Features

      Real-time collaboration

      Fearlessly work with content

      Precise content querying

      Treat content as data with GROQ

      Localization

      Coherent messaging across territories

    • Use cases

      E-commerce

      Richer shopping experiences

      Marketing sites

      Control your story

      Products & services

      Innovate and automate

      Mobile apps

      Content backend for every OS

      View all

      Integrations

      Shopify
      Mux
      Vercel
      Netlify
      Algolia
      Cloudinary
      BigCommerce
      Commerce Layer
      Smartling
      Transifex
      View all
    • Learn

      Documentation
      Studio API Reference
      API reference
      Guides
      GROQ cheat sheet
      Sanity UI
      Get started

      Build and share

      Templates
      Tools and plugins
      Schemas and snippets
      Project showcase
      Share your work
      Browse Exchange

      Frameworks

      React
      Vue
      Next.js
      Nuxt.js
      Svelte
      Remix
      Gatsby
      Astro
      Angular
      Eleventy
      View all
    • Discover

      Blog
      Resource library
      Agency partners
      Become a partner
      Technical support
      Talk to sales

      Case studies

      Puma

      Source of truth for global markets

      Aether

      Unique digital shopping experience

      Morning Brew

      Omnichannel media distribution

      InVision

      Delivering exceptional customer experiences

      View all

      Popular guides

      Headless CMS
      Structured content
      Content modeling
      Headless SEO
      Static websites
      View all
    • Enterprise
    • Pricing
    • Log in
    • Contact sales
    • Get started
Contact salesGet started
Published August 19th 2018

Design with real content: How to connect Sanity with Sketch using InVision’s Craft plugin

How to use structured content and Sanity’s API to prototype design in Sketch.

Knut Melvær

Principal Developer Marketing Manager

One of the advantages with using Sanity as a headless CMS is that it allows a team to work more cross-disciplinary. After the two minute installation, a developer and an editor can sit together and create the editorial interface, and have the fields and the modell pop up on the screen, ready for work. The content is available through the API instantly, and can be queried.

We don't believe in a one-size-fits-all approach to design, but we're pretty certain that the success of a design process relies on everyone’s understanding of the problem to be solved. And that involves experimentation, mocking up and working together from different angels. In this post we want to demonstrate an small example of how that could be done with Sanity, Sketch and InVision’s Craft plugin (you should go ahead and install that right away).

Learn how to get started with Sanity

1. Create a query, copy the URL

Install the Vision-plugin for your Studio by running sanity install @sanity/vision in your terminal. You'll now have a new icon in your left sidebar and by clicking it you'll get to a tool where you can author and test queries in our Graph-based Query Language (GROQ).

The Vision plugin

Let's say we want to design our new listing of blog entries. We then need a title, an author with name and photo, and the publishing date. Something like this, coming from our own blog:

Input

*[_type == "post"]{
  title,
  "poster": poster.asset->url,
  "authors": authors[]->{name, "photo": mugshot.asset->url}
}

Output

{
  authors: [
    {
      name: "Knut Melvær",
      photo: "https://cdn.sanity.io/images/3do82whm/production/4db98bdd1a67ba86541c939bc9ee981575346f23-1906x1280.png"
    }
  ],
  poster: "https://cdn.sanity.io/images/3do82whm/production/dd54bdf65ecefcfbe312a56a117f51adeb698514-1420x918.png",
  title: "How to conditionally build an object in ES6"
}

If you successfully got the content you wanted in the right panel, you can go ahead and push the copy button up to the center. It will copy the URL of the same query.

2. Design some placeholders in Sketch

Start with drawing some placeholder boxes and texts.

I'm obviously not a designer.

3. Load the content from Sanity into the placeholders

In the Craft-plugin bar, click the button for “data” and go to the JSON tab. Paste in the URL you copied from Vision.

After you push “Import” you'll get a list where you can expand “results” to see the list of content you just fetched from Sanity.

If you select a placeholder, and then a label in this data list, you'l notice that the content is applied to the placeholder. And almost certainly, it will break your intended design. That is probably a good thing.

Applying content from Sanity to placeholders in Sketch

4. Duplicate the content in Sketch

And now for the exciting part. Select all your layers on the artboard, and push the “Duplicate content” button in the Craft pane, put in some numbers in “count” and “gutter”.

Gutter is the space you want between the repeated items

If I now zoom out, we'll see I have a list of duplicated placeholders, but filled with the different blog posts automatically. As you can see, there is some breakage in my initial design. But now I know I have to think about how long titles can be, and discuss with my team how to approach it. Perhaps we need some character limits on titles? Perhaps a warning in the Studio if a title goes over a certain number of characters, or perhaps I can use this content and adapt the layout for it.

---

This was a pretty basic example of how you can use structured content and Sanity’s API in design workflows. We're sure there are many other ways of doing this. There are even examples of people using Sanity to publish books, exporting the content into InDesign via XML. If you invent a way to use Sanity for design prototyping, we'd love to hear all about it in our community slack.

Join our Community Slack

Page content

  • 1. Create a query, copy the URL
  • 2. Design some placeholders in Sketch
  • 3. Load the content from Sanity into the placeholders
  • 4. Duplicate the content in Sketch

Product

Sanity StudioAPIsContent LakeSecurity & Compliance
  • Sanity vs Contentful
  • Sanity vs Strapi
  • Sanity vs Wordpress
  • Sanity vs Adobe Experience Manager
  • Sanity vs Hygraph
  • Sanity vs Sitecore
  • Sanity vs Storyblok
  • Sanity vs Contentstack
  • Sanity vs Prismic
  • Sanity vs Drupal
  • Sanity vs ButterCMS

Resources

DocumentationBlogResource libraryCase Studies
  • React Blog
  • Gatsby Blog
  • Next.js Landing Pages
  • Making a PWA
  • Single Page Application
  • Svelte & Typescript App
  • Vue & Tailwind Blog
  • Developer Portfolio Templates
  • Form validation with Yup
  • Live Preview with Next.js and Sanity.io
  • Next.js blog
  • Next.js personal website
  • Clean Next.js + Sanity app
  • Clean Remix + Sanity app
  • Clean SvelteKit + Sanity app
  • All Templates
  • Agency partners
  • Technology partners
  • Headless CMS 101
  • Static Sites 101
  • Headless Commerce 101
  • CMS for enterprise
  • Headless SEO
  • Localization
  • Content as a Service
  • What is a DXP?
  • Typescript 101
  • Ecommerce SEO
  • What is a Composable DXP?
  • What is an API?
  • GraphQL vs REST
  • React CMS
  • Next.JS CMS
  • CMS for Shopify
  • API-first CMS
  • Content platform
  • Multilingual CMS
  • Static Site CMS
  • Gatsby CMS
  • Node CMS
  • E-commerce CMS
  • Vue CMS
  • Angular CMS
  • GraphQL CMS
  • Newspaper CMS
  • Magazine CMS
  • CMS for apps
  • Remix CMS
  • Nuxt CMS
  • SvelteKit CMS
  • Agile CMS
  • Eleventy CMS

Company

Contact SalesEnterpriseCareersTerms of ServicePrivacy PolicyAccessibility Statement

Stay connected

  • GitHub
  • Slack
  • Twitter
  • YouTube
  • Stack Overflow
  • Blog RSS
  • Newsletter
©Sanity 2023