Studio

Tailor application configuration edition

Discover how to customize application config edition in Studio by providing schema. Ensure a smooth and structured content management experience.

When entering the Config tab of the editor, you can browse configurations to customize your website. These configurations represent the settings defined in your app.config.ts file.

app.config.ts

The app.config.ts file is a configuration file introduced in Nuxt 3. It's a TypeScript file that allows you to configure various aspects of your application settings. Developers can easily turn any website into a configurable experience using this file.

Ensure you have at least an empty file in your app:

app.config.ts
export default defineAppConfig({})

Customize edition

To create a customized editing experience for your app.config.ts in Studio, you need to create a nuxt.schema.ts file in your project. This schema serves as a representation of your app.config.ts.

Helpers

  • The group method allows you to customize parent objects.
  • The field method allows you to customize inputs (aka leaf).
nuxt.schema.ts
import { field, group } from '@nuxt/content/studio'

export default defineNuxtSchema({
  appConfig: {
    parent: group({
      title: 'Parent title',
      description: 'Parent description.',
      icon: 'i-icon-to-display',
      fields: {
        leaf: field({
          type: 'Type of component used to edit your field',
          title: 'Field title',
          description: 'Field Description',
          icon: 'i-icon-to-display',
          default: 'default value'
        })
      }
    })
  }
})
It is not mandatory to include all app config keys; only those you wish to showcase on the Studio interface need to be added.

Input Types

The type in the field() method's first parameter can accept various values:

  • string
  • number
  • boolean
  • array
  • object
  • icon
  • media

Based on these values, the Studio UI will adapt to display the appropriate input type. For instance, an icon picker is displayed for icon type or the media library is displayed for media type.

Text can be displayed as a select instead on a classical input if you provide a required key in the field() method:

nuxt.schema.ts
import { field, group } from '@nuxt/content/studio'

export default defineNuxtSchema({
  appConfig: {
    parent: group({
      title: 'UI',
      description: 'UI configuration',
      icon: 'i-ph-palette-fill',
      fields: {
        primary: field({
          type: 'string',
          title: 'Primary',
          description: 'Primary color of your UI.',
          icon: 'i-ph-palette',
          default: 'sky',
          required: ['sky', 'mint', 'rose', 'amber']
        })
      }
    })
  }
})

Edit on Studio

Once your schema is deployed. Any user can access the Config section and play with the generated form.

Any update in the form will be directly applied to the app.config.ts file. You can review those changes on the review page.

app config UI on Studio

Take a look at this section to validate your schema in local development.
For a practical example, take a look at the schema we've developed for the UI Pro Docs starter.