Watch a live product demo 👀 See how Sanity powers richer commerce experiences

How to add Custom Input Fields onto Product Pages to allow Product Customization by Customers

10 replies
Last updated: Jul 7, 2022
Question: would this be the guide I need to follow if I wanted to add custom input fields on my single products page for customers to input their desired customizable text, colors, and more customizable features on a product? Would this take that information from the customer and when they press my add to cart button it sends that information with the original product name, price, etc to the cart. And then when the purchase is successful it sends it to either my sanity studio or an automated email? That's what I'm trying to do but the guide although we'll written is a little bit out of my realm of experience. But ill struggle through it I just want to make sure I'm in the right place.


Is it portable text I'm trying to achieve?
Jul 7, 2022, 3:50 PM
That's not quite what you need here. Are customers able to choose any color, or are they selecting from a set of available colors. Is the text just a string field?
Jul 7, 2022, 5:24 PM
Whichever would be easier to implement. I assume a required text string where they can put any color, and any text (another required text string)
For the third option I'd like a dropdown box with about 10 font options but if a string would be a lot easier to implement I would probably opt for that.
Jul 7, 2022, 5:28 PM
But I need these fields to be required before they can add to cart, and I need to be able to access this information via sanity studio or my email
Jul 7, 2022, 5:35 PM
You'll need to create some sort of form with validation on your frontend, then. That's going to be outside of the realm of Sanity. The only time that would interact with your content is if you're doing something like writing orders to your content lake after they're placed.
Jul 7, 2022, 5:45 PM
Is react hook form compatible? I feel like that would be a good solution
Jul 7, 2022, 5:48 PM
Yep! It's a React component so you can use that package.
Jul 7, 2022, 5:49 PM
Beautiful. Final question, is there anything specific I should do while installing react hook form with npm? I tried messing with some packages and dependencies in my previous attempt at building this project and it broke my sanity studio. How can I properly install the package for react hook form? Which directory does it go in? Pleasr be as specific as possible, this is my first react app and I'm not familiar with package libraries very much. My project structure is repos/ecom/nailedit/sanity
Nailed It is where next.js lives and sanity is obviously all of my sanity files

Would I cd to the nailedit directory and install the package there?
Jul 7, 2022, 5:56 PM
You don't want to install any of those packages in your Sanity Studio. They are entirely separate and go on your frontend. The best place to find instructions for installing packages would be on npm or the package's repo.
Jul 7, 2022, 6:02 PM
So install where the front end lives which is in Nailed It. Got it. Thank you
Jul 7, 2022, 6:03 PM

Sanity– build remarkable experiences at scale

The Sanity Composable Content Cloud is the 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.

Related answers

Get more help in the community Slack

TopicCategoriesFeaturedRepliesLast Updated
After adding the subtitle and running this code npm run graphql-deploy It does nothingSep 15, 2020
how to limit a reference to just one entry in Studio reference input side versus the default as-many-entries-as-you-fill-in-an-array...Sep 18, 2020
Is it possible to fetch more than one "_type" using GROQ?Nov 2, 2020
I want to add a view with the Structure builder (S.view.component) where I list similar documents based on the title. What...Sep 23, 2020
Is there a structure builder example where the format of each preview for the document list is modified?Feb 3, 2021
I have an array of references to a country schema type but it always just returns NULL values for meJan 30, 2021
Hi, I need help with a query for getting the url of an image asset. Here is what I've been trying, but I only get the _ref...Dec 1, 2020
Sanity UI looks brilliant :smiley: Is something like the current date picker possible at the moment? I’m not sure if anicon...Dec 21, 2020
Hey everyone. I have been coding and may have potentially accidentally deleted something. Does anyone know how to resolve...Dec 26, 2020
Hello everyone and happy new year :raised_hands::skin-tone-2:, I have a problem with outputting Portable Text :disappointed:...Jan 1, 2021

Related contributions

Clean Next.js + Sanity app
- Template

Official(made by Sanity team)

A clean example of Next.js with embedded Sanity ready for recomposition.

Cody Olsen
Go to Clean Next.js + Sanity app

Blog with Built-in Content Editing
- Template

Official(made by Sanity team)

A Sanity-powered blog with built-in content editing and instant previews.

Go to Blog with Built-in Content Editing