Fields
Fields define the schema of a Base table. Each field has a type, a configuration, a default value, and capabilities such as sorting, filtering, grouping, or display on a card.
Bases UI configuration
UniverBasesUIPlugin
attachmentobjectUpload an attachment and return its metadata.acceptstring[]Limit the files that the attachment picker offers.maxSizenumberMaximum attachment size, in bytes.upload(file: File) => Promise<IBaseAttachment>Upload an attachment and return its metadata.
personOptionsobject[]The people that the Person picker offers.idstringStable ID that identifies this option.namestringName displayed in the picker.avatarstringURL of the option's avatar.
groupOptionsobject[]The groups that the Group picker offers.idstringStable ID that identifies this option.namestringName displayed in the picker.avatarstringURL of the option's avatar.
Attachment uploads
Configure upload handling in the same place where the Bases UI plugin is registered:
univer.registerPlugin(UniverBasesUIPlugin, { attachment: { accept: ['image/*', '.pdf'], maxSize: 10 * 1024 * 1024, upload: uploadAttachment, },})uploadAttachment is a function that the application provides, with the signature (file: File) => Promise<IBaseAttachment>, and it returns an attachment object such as the one in the example below. maxSize is measured in bytes. If no uploader is supplied, the plugin tries image IO and then Base64, which makes the snapshot larger. A production deployment should connect real file storage and validate file type, size, and download permissions on the backend.
People and groups
Pass the picker candidates through the personOptions and groupOptions options of the Bases UI plugin. Each item has id, name, and an optional avatar. These options control only what the pickers display; login and access permissions remain the responsibility of the application.
Field types
| Purpose | BaseFieldType |
|---|---|
| Text and contact details | Text, Link, Phone, Email |
| Numbers and progress | Number, Currency, Progress, Rating |
| Choices and members | Checkbox, SingleSelect, MultiSelect, Person, Group |
| Dates and attachments | Date, Attachment |
| Calculations and relationships | Formula, RecordLink |
| Generated values and audit fields | Numbering, RecordId, CreatedBy, UpdatedBy, CreatedAt, UpdatedAt |
Select values use option IDs, and Person and Group values use member IDs from the application. The system manages numbering and audit fields. Calculations are described in Formulas, and relationships in Records, links, and hierarchy.
Add fields
const table = base.getTableById('tasks')if (!table) throw new Error('Tasks table not found')const title = table.addField('Title', univerAPI.Enum.BaseFieldType.Text)const priority = table.addField( 'Priority', univerAPI.Enum.BaseFieldType.SingleSelect, { field: { config: { options: [ { id: 'high', name: 'High', color: '#ef4444' }, { id: 'low', name: 'Low', color: '#22c55e' }, ], }, }, },)Update fields
priority.setName('Impact')priority.update({ description: 'Business priority' })priority.setConfig({ options: [ { id: 'p0', name: 'P0', color: '#dc2626' }, { id: 'p1', name: 'P1', color: '#f97316' }, ],})Change field type
priority.changeType(univerAPI.Enum.BaseFieldType.Text, {})Changing the type of a field may normalize existing values. Verify the data in the application before applying a schema change to a production table.
Attachment fields
An attachment requires a stable ID, a name, and a source that the browser can reach. The example assumes that the application has already uploaded the file:
const attachments = table.addField('Files', univerAPI.Enum.BaseFieldType.Attachment)const record = table.getRecords()[0]if (!record) throw new Error('Create a record first')record.setAttachments(attachments.getId(), [{ id: 'brief-1', name: 'brief.pdf', mimeType: 'application/pdf', source: 'https://example.com/files/brief.pdf',}])setAttachments() replaces the entire attachment list for the cell. Use getAttachments() to read the list and deleteAttachments() to remove individual entries. Replace the example URL with an address that users can reach.
How is this guide?