🎀 Builder Talk: The Story Behind Lady Gaga’s Digital Experience – Register now

How to Pass Props to the Desk Structure ICON

8 replies
Last updated: Feb 4, 2022
Wondering if there is a trick to pass props to the desk-structure ICON?

import {
  File
} from "phosphor-react";

S.listItem()
    .title("Pages")
    .id("pages")
    .child(S.documentTypeList("page").title("Pages overview"))
    .schemaType("page")
    .icon(File),
Want something like this:


S.listItem()
    .title("Pages")
    .id("pages")
    .child(S.documentTypeList("page").title("Pages overview"))
    .schemaType("page")
    .icon(<File color="#FF0000"/>),
Is there a trick to do this
πŸ˜„?
Feb 4, 2022, 10:15 PM
We do this pretty regularly in our internal tool Hyperdrive. For example:
S.listItem()
 .title('My Community Tracker Filters')
 .icon(() => <Tile color='#d0f4dc'><FilterIcon /></Tile>)
 .child(...)
Feb 4, 2022, 10:18 PM
user M
You are the bomb πŸ˜„
Feb 4, 2022, 10:18 PM
no you
Feb 4, 2022, 10:18 PM
We do this pretty regularly in our internal tool Hyperdrive. For example:
S.listItem()
 .title('My Community Tracker Filters')
 .icon(() => <Tile color='#d0f4dc'><FilterIcon /></Tile>)
 .child(...)
Feb 4, 2022, 10:18 PM
user M
Works good πŸ˜„
Feb 4, 2022, 10:30 PM
user M
Works good πŸ˜„
Feb 4, 2022, 10:30 PM
Fun colors! I was about to say "I didn't know you could return components" but of course that's what the React icons are πŸ˜ƒ
Feb 4, 2022, 11:49 PM
user S
Yeah for our company I am using the same colors for the front and back end πŸ˜ŠπŸ‘πŸ™Œ
Feb 4, 2022, 11:54 PM

Sanity– build remarkable experiences at scale

Sanity is a modern 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?

Related answers

Get more help in the community Slack

TopicCategoriesFeaturedRepliesLast Updated
How to turn PortableText into plain text in Javascript?Dec 7, 2020
Custom Document Views - Is it Even Possible to Use the Structure Builder?Apr 21, 2022
Error: unable to resolve image URL from source (undefined)Sep 11, 2022
How to Disallow Robots on a SubdomainNov 12, 2020
Adding a ref to the body tag using Helmet in ReactJul 2, 2020
Error when deploying Next.js + Sanity project to Vercel with Lerna and React-IconsJan 21, 2021
Organizing document types in Sanity Studio using Structure BuilderMay 13, 2020
Hello all! I’m trying to render a code block in a Portable Text Block, followed the instructions to add the serializer and...Feb 3, 2021
How to structure the content on the front page of a website using Sanity.io.Jun 19, 2020
Best practices for using image sizes in React projects with Sanity.ioMay 21, 2020

Related contributions

Turbo Start Sanity
- Template

The battle-tested Sanity template that powers Roboto Studio's websites

Go to Turbo Start Sanity

Schema UI - Next.js Sanity Starter
- Template

A Next.js starter template with Next.js 15, Tailwind CSS, shadcn/ui, and Sanity CMS with Live Editing. Get production-ready React components with matching Sanity schemas and queries. Build dynamic pages faster while keeping full control over customization.

Serge Ovcharenko
Go to Schema UI - Next.js Sanity Starter

The Swaddle
- Made with Sanity

A new brand identity to represent a more mature company, to signify The Swaddle’s evolution from publisher to production house, combined with an easier to navigate platform that can surface multiple content types - drawing readers through The Swaddle’s content offering.

Nightjar
Go to The Swaddle