Issue with paperclip icon not showing in array list of references

4 replies
Last updated: May 25, 2020
Is there a way to get the paperclip icon to show in the array list of references? Works in the dropdown, but not in the list it self oddly.
May 24, 2020, 3:16 PM
weird. can you paste your tag.js?
May 24, 2020, 3:24 PM
user K
tag.js looks like this

import iconTag from '../components/iconTag'


export default {

title: 'Tags',

name: 'tag',

type: 'document',

icon: iconTag,

fields: [

{

name: 'title',

title: 'Title',

type: 'string',

validation: Rule => Rule.required(),

},

{

title: 'Slug',

name: 'slug',

type: 'slug',

validation: Rule => Rule.required(),

options: {

source: 'title',

maxLength: 200,

slugify: input =>

input

.toLowerCase()

.replace(/\s+/g, '-')

.slice(0, 200),

},

},

],

preview: {

select: {

title: 'title',

media: 'iconTag',

},

},

}

and then I have this custom icon comp:


import React from 'react'

import icon from '../media/icon-tag.png'


const iconTag = () => (

<img style={{ width: '25px', height: '25px' }} src={icon} />

)


export default iconTag
May 25, 2020, 8:56 AM
does this work?
preview: {
    select: {
      title: "title",
    },
    prepare(selection) {
      const { title } = selection;
      return {
        title: title,
        media: iconTag
      };
    }
  }

May 25, 2020, 9:41 AM
Great, thanks! I forgot the prepare function exists..
May 25, 2020, 12:43 PM

Sanity– build remarkable experiences at scale

The Sanity Composable Content Cloud is the headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?