Error when adding color-input plugin to schema

1 replies
Last updated: Apr 6, 2020
I’ve installed the Color-input plugin: https://www.sanity.io/plugins/color-input with the command
sanity install @sanity/color-input

And added it to my schema like shown in the example:


{
  name: 'myColor',
  type: 'color',
  title: 'Choose color'
}
but I get thrown an error of unknown type.

Unknown type: color. Valid types are: siteSettings, about, project, img, array, block, boolean, datetime, date, document, email, file, geopoint, image, number, object, reference, slug, string, telephone, text and url
AI Update

Based on the error you're seeing, this is a Studio v2 vs v3 compatibility issue. The command sanity install @sanity/color-input and the sanity.json plugins array are part of the Studio v2 workflow, which is now deprecated.

Here's what's happening: In Studio v2, plugins needed to be registered in the sanity.json file's plugins array for their custom types to become available. Just installing the package isn't enough - you need to explicitly add it to your configuration.

For Studio v2 (Legacy)

If you're still using Studio v2, you need to add the plugin to your sanity.json file:

{
  "root": true,
  "project": {
    "name": "Your Project"
  },
  "plugins": [
    "@sanity/base",
    "@sanity/components",
    "@sanity/default-layout",
    "@sanity/default-login",
    "@sanity/desk-tool",
    "@sanity/color-input"  // Add this line
  ]
}

After adding it to the plugins array, restart your Studio and the color type should be recognized.

If you're on Studio v3 (or should migrate to it), the process is different. Install the plugin with:

npm install @sanity/color-input

Then add it to your sanity.config.ts or sanity.config.js:

import {defineConfig} from 'sanity'
import {colorInput} from '@sanity/color-input'

export default defineConfig({
  // ... other config
  plugins: [
    colorInput()
  ]
})

The fact that you're using the sanity install command suggests you're on Studio v2. You can check by looking for either a sanity.json file (v2) or a sanity.config.ts/js file (v3) in your project root. Since Studio v2 is deprecated, I'd recommend migrating to v3 when possible.

Hm… Did you restart your Studio after running the
sanity install
command?
Oops! Just saw your comment below this one 😅

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?