Drupal out of the box & with contributed modules provides plenty of field types that cover most of the use cases while creating a content type for a data model. One such field type which Drupal core provides is the List type which allows users to select an option or multiple options from a list of options. These options have to be manually fed to the field configuration where a user can choose from the predefined list of items.

However, there can be a situation where the options in the List type will have dynamic items. For example, the options need to come from a REST API, or the options list is generated from an entity query. The List type field UI doesn't provide any field to have a callback to generate the options dynamically.

To achieve this, the field storage configuration needs to be overridden to pass a callback to the default_value_callback key.


...
default_value: {  }
default_value_callback: 'example_dynamic_list_options'
settings: {  }
field_type: list_string
...

The callback will be a function in a module field in any custom module of the project as the case may be.


function example_dynamic_list_options(FieldStorageConfig $definition, ContentEntityInterface $entity = NULL, $cacheable) {
  return [1, 2, 3, 4, 5];
}

After importing the configurations the field will list out the options being returned by the callback function. Also, the Field settings of the field will show "The value of this field is being determined by the example_dynamic_list_options function and may not be changed."  for the field.

Having dynamic options for list fields can be argued by having a vocabulary setup and a term reference field. However, the behavior and what needs to be achieved are quite different in both cases and complements each other. Using a term reference field tied to a vocabulary will be useful when the contents need to be categorized or filtered based on terms and the terms are managed by the site owners. But, the dynamic option lists will be useful for a situation where the options need to be generated dynamically which should be updated/managed by site owners.