Show notice message for field independent of validation rules
Yes, absolutely! You can add a persistent notice message to a field using the description property in your schema definition. This description will always be visible below the field title, regardless of validation state.
Here's how to do it:
defineField({
name: 'title',
type: 'string',
title: 'Page Title',
description: 'This title will appear in search engine results and browser tabs',
})The description appears as persistent help text below the field label and stays visible at all times - it's not dependent on validation rules or user interaction.
Enhanced formatting with JSX
If you need more complex formatting or styling in your notice message, you can use JSX in the description:
defineField({
name: 'url',
type: 'url',
title: 'Canonical URL',
description: (
<>
<strong>Important:</strong> This URL will be used by search engines to index this content.
Make sure it matches your production URL.
</>
),
})Combining with validation messages
The description field is completely independent of validation rules. So you can have:
- A persistent description that's always visible
- Validation errors/warnings that appear conditionally when rules aren't met
defineField({
name: 'email',
type: 'string',
title: 'Contact Email',
description: 'This email will be publicly visible on your contact page',
validation: (Rule) => Rule.required().email(),
})In this example, the description is always shown, while validation messages only appear when the field is empty or contains an invalid email.
This approach is covered in the Sanity schema documentation on field definitions, where descriptions are recommended as a best practice for providing context to content editors about how fields will be used.
Show original thread13 replies
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.