> ## Documentation Index
> Fetch the complete documentation index at: https://docs.devias.io/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> The docs are served at https://docs.devias.io. Every path in these docs is relative to that root: /llms.txt is https://docs.devias.io/llms.txt.
> Devias is an open-source platform that works as an operating system for a business: a core (records, views, workflows, agents, permissions) with installable modules.
> Pages are typed by folder. concepts/ explains what things are, guides/ gives procedures, reference/ is exhaustive (SDK, CLI, HTTP API), operate/ covers hosting. Use /start/glossary for exact terms.
> Every id in a module (module, object, field, view, action, workflow, step, connection, variable, event, policy) is a uuid. Generate them with `devias id <count>`. Never invent dotted or readable ids.
> Run `devias plan` and read its output before `devias apply`. Apply only what the plan says.
> The OpenAPI document, including the routes of the modules in the reference setup, is at /reference/api/openapi.json.
> Devias is young and changes quickly. If a page and the source repository (github.com/devias-io/devias) disagree, the repository is right.

# Field and view types

> How a module adds a new field type or view type from its ./studio export. Lists the parts of defineFieldType (type, label, icon, cell, editor, toText, filter, sortable, groupable) and defineViewType with its capabilities, and when to use a built-in instead.

Devias ships built-in field types and view types. A module can add more from its `./studio` export with `defineFieldType` and `defineViewType`. The built-in field types are listed in [Data model](https://docs.devias.io/concepts/data-model.md#built-in-field-types).

## Add a field type with defineFieldType

A field type says how a value is stored, shown and edited. The CRM's star **rating** is an example.

```tsx theme={"dark"}
export const ratingType = defineFieldType<number>({
  type: 'rating',
  label: 'Rating',
  icon: 'star',
  cell: ({ value }) => <Stars value={value} />,
  editor: ({ value, onChange }) => <Stars value={value} onPick={onChange} />,
  toText: (value) => (value ? `${value} of 5` : ''),
})
```

| Part | What it is for |
| - | - |
| `type`, `label`, `icon` | How the type is named and shown in the data model settings. |
| `cell` | How a value looks in a table or a card. |
| `editor` | How a person changes it. |
| `toText` | The value as plain text, for search and export. |
| `filter`, `sortable`, `groupable` | Whether views can filter, sort and group by it. |

Register it on the module's studio side with `fieldTypes: [ratingType]`. Fields of that `type` are then declared in the manifest like built-in ones.

## Add a view type with defineViewType

The built-in view types are `table`, `kanban` and `calendar`. A view type is a React component that receives the records and the view's settings, plus flags (`capabilities`) saying which toolbar controls apply: filter, sort, group by, fields, search.

```tsx theme={"dark"}
defineViewType({
  type: 'gallery',
  label: 'Gallery',
  icon: 'layout-grid',
  capabilities: { filter: true, sort: true, groupBy: false },
  component: GalleryView,
})
```

Register it with `viewTypes: [...]`. Views in a manifest can then use `type: 'gallery'`.

A custom type is needed only when no built-in fits. Most needs for a new field are a built-in type with the right `settings`, and most needs for a new view are a better table.

## Related

* [Blocks](https://docs.devias.io/guides/customize-studio/blocks.md): add pieces to Home and record pages.
* [Objects and fields in a module](https://docs.devias.io/guides/modules/objects-and-fields.md): declare fields of a type.
* [Data model](https://docs.devias.io/concepts/data-model.md): the built-in field types.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.