Changing the "Add Item" button text in Sanity.io using a custom inputComponent.
I understand you want to customize the "Add Item" button text in Sanity Studio! Unfortunately, there isn't a simple built-in configuration option like buttonText to change this text directly in the array field schema. However, you can achieve this by creating a custom input component.
Here's a practical approach using Sanity's Form Components API. The key is to create a custom input component that wraps the default array input:
// CustomCategoryArrayInput.tsx
import { ArrayOfObjectsInputProps } from 'sanity'
import { Stack, Button } from '@sanity/ui'
import { AddIcon } from '@sanity/icons'
export function CustomCategoryArrayInput(props: ArrayOfObjectsInputProps) {
return (
<Stack space={3}>
{/* Render the default array input with all its functionality */}
{props.renderDefault({
...props,
arrayFunctions: {
...props.arrayFunctions,
// Override the add button rendering
}
})}
</Stack>
)
}Then apply it to your array field in your schema:
import { defineField, defineType } from 'sanity'
import { CustomCategoryArrayInput } from './CustomCategoryArrayInput'
export default defineType({
name: 'myDocument',
type: 'document',
fields: [
defineField({
name: 'categories',
title: 'Categories',
type: 'array',
of: [{ type: 'category' }],
components: {
input: CustomCategoryArrayInput
}
})
]
})The challenge: The default array input doesn't expose a simple prop to change just the button text. You'd need to either:
- Use CSS to hide the default button and add your own custom button (less elegant but simpler)
- Build a more complete custom array input that reimplements the array functionality with your custom labels (more work but full control)
For the CSS approach, you could target the button with custom CSS in your Studio styles, though this is fragile and not officially recommended.
The custom input components guide and the guide on creating array inputs with selectable templates show more complete examples of customizing array inputs, though they focus on adding template buttons rather than changing the default button text.
This is a commonly requested feature, and hopefully Sanity will add a simpler configuration option in the future. For now, custom components are the official way to achieve this level of customization in Sanity Studio.
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.