How to edit array Add-button text in Sanity Studio?
Unfortunately, there's no built-in schema option to directly customize the "Add item" button text in array fields. The standard array field configuration doesn't provide properties like buttonTitle or similar for changing this text through schema alone.
However, you can customize it by creating a custom input component. This is the recommended approach when you need to modify the array's add button or other UI elements.
Custom Input Component Solution
You'll need to create a custom input component that wraps the default array input. The key is using the renderDefault function to preserve all the standard array functionality while customizing just the add button:
import { ArrayOfObjectsInputProps } from 'sanity'
import { Button, Stack } from '@sanity/ui'
import { AddIcon } from '@sanity/icons'
function CustomArrayInput(props: ArrayOfObjectsInputProps) {
const { renderDefault, onItemAppend, schemaType } = props
const handleAdd = () => {
const newItem = {
_type: schemaType.of[0].name,
_key: `${Date.now()}` // Generate unique key
}
onItemAppend(newItem)
}
return (
<Stack space={3}>
<Button
icon={AddIcon}
mode="ghost"
onClick={handleAdd}
text="Add new category" // Your custom text here
/>
{renderDefault(props)}
</Stack>
)
}Then apply it in your schema:
defineField({
name: 'categories',
title: 'Categories',
type: 'array',
of: [{ type: 'category' }],
components: {
input: CustomArrayInput
}
})Important Clarification
You might see references to insertMenu.groups in array configuration - this is not for customizing the add button text. The insertMenu.groups feature is specifically for organizing different types into named groups when your array accepts multiple types in the of array. It helps categorize what types of items can be added, but doesn't change the button text itself.
Benefits of This Approach
- Keeps all default array functionality (drag-and-drop, item rendering, validation)
- Full control over button appearance and behavior
- Can add multiple custom buttons or other UI elements
- Maintains accessibility and collaboration features
For more detailed examples of customizing array inputs, check out the Form Components API documentation and guides on creating custom input components, which provide similar patterns for array customization.
Show original thread4 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.