Skip to content

UUID Field

The UUID field type provides a read-only field that automatically generates and displays a Universally Unique Identifier (UUID). It’s useful for uniquely identifying entries within the CMS.

User Interface

Editor

Read-only display of a UUID (Universally Unique Identifier) value. The UUID is automatically generated when a new entry is created and cannot be modified by the user.

Preview

A read-only view of the UUID value.

Data Type

A string representing a UUID in the standard 36-character format (e.g., df733d7e-d2f7-4e4f-8f27-803046b64040). Alphabetic characters are in lowercase.

If use_b32_encoding is set to true, the UUID will be represented in a 26-character Base32 format (e.g., C5T6KX3M6N7G4Y2Z1A0B9C8D7E).

Data Validation

No specific data validation is applied to the UUID field, as its value is automatically generated.

Options

In addition to the common field options, the UUID field supports the following options:

Required Options

widget

  • Type: string
  • Default: string

Must be set to uuid.

Optional Options

Deprecation Notice

The read_only option has been deprecated in favor of the readonly common field option. The read_only option will be removed in Sveltia CMS v1.0.0. If you are upgrading from an older version, update your configuration accordingly.

default

  • Type: string
  • Default: A newly generated UUID

The default value for the field. If not provided, a new UUID will be generated when the entry is created.

prefix

  • Type: string
  • Default: ""

A string prefix to prepend to the generated UUID. Useful for adding context or categorization to the UUID.

use_b32_encoding

  • Type: boolean
  • Default: false

Whether to use Base32 encoding for the UUID. If set to true, the UUID will be represented in a 26-character Base32 format instead of the standard 36-character format.

Examples

Basic UUID Field

This example demonstrates a basic UUID field that generates a standard UUID.

yaml
- name: product_id
  label: Product ID
  widget: uuid
toml
[[fields]]
name = "product_id"
label = "Product ID"
widget = "uuid"
json
{
  "name": "product_id",
  "label": "Product ID",
  "widget": "uuid"
}
js
{
  name: 'product_id',
  label: 'Product ID',
  widget: 'uuid',
}

Output example:

yaml
product_id: df733d7e-d2f7-4e4f-8f27-803046b64040
toml
product_id = "df733d7e-d2f7-4e4f-8f27-803046b64040"
json
{
  "product_id": "df733d7e-d2f7-4e4f-8f27-803046b64040"
}

UUID Field with Prefix and Base32 Encoding

This example demonstrates a UUID field that includes a prefix and uses Base32 encoding.

yaml
- name: order_id
  label: Order ID
  widget: uuid
  prefix: ORD-
  use_b32_encoding: true
toml
[[fields]]
name = "order_id"
label = "Order ID"
widget = "uuid"
prefix = "ORD-"
use_b32_encoding = true
json
{
  "name": "order_id",
  "label": "Order ID",
  "widget": "uuid",
  "prefix": "ORD-",
  "use_b32_encoding": true
}
js
{
  name: 'order_id',
  label: 'Order ID',
  widget: 'uuid',
  prefix: 'ORD-',
  use_b32_encoding: true,
}

Output example:

yaml
order_id: ORD-C5T6KX3M6N7G4Y2Z1A0B9C8D7E
toml
order_id = "ORD-C5T6KX3M6N7G4Y2Z1A0B9C8D7E"
json
{
  "order_id": "ORD-C5T6KX3M6N7G4Y2Z1A0B9C8D7E"
}

Released under the MIT License.