---
title: "swatch.library.add: Add to Swatches — Vector kit command — Kition"
description: "Adds swatches or colour groups from a library to the document's swatches, optionally applying the first to the selection."
canonical: "https://developer.kition.ai/docs/kits/vector/commands/swatch.library.add"
---

> Canonical HTML: [https://developer.kition.ai/docs/kits/vector/commands/swatch.library.add](https://developer.kition.ai/docs/kits/vector/commands/swatch.library.add)

# swatch.library.add

**Add to Swatches.** Adds swatches or colour groups from a library to the document's swatches, optionally applying the first to the selection.

- Kit: Vector 0.1.0 (.kvector); reference: [Vector kit commands](https://developer.kition.ai/docs/kits/vector.md)
- Changes the document: yes

## Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `apply` | `string` | no | like fill; one of several alternative parameters |
| `focus` | `boolean` | no | with apply: false keeps the active proxy |
| `library` | `string` | no |  |
| `names` | `any[]` | no | [swatch or colour group names in the library] (default: all of it; a group comes as a colour group, a single swatch ungrouped); default: all of it; a group comes as a colour group, a single swatch ungrouped |
| `stroke` | `any` | no | also apply the first one to the selection and the defaults, as paint.setFill / paint.setStroke; one of several alternative parameters |

## Call through vector_run

```text
vector_run {
  "path": "<file>.kvector",
  "steps": [{ "command": "swatch.library.add" }]
}
```

The required parameters, with placeholders for their types: not a tested example. Optional: `apply`, `focus`, `library`, `names`, `stroke`. vector_run answers the step’s result in `completed[i].result`.

## Result

The kit gives no result schema for this command.

## Parameter schema

```json
{
  "additionalProperties": false,
  "properties": {
    "apply": {
      "description": "like fill; one of several alternative parameters",
      "type": "string"
    },
    "focus": {
      "default": true,
      "description": "with apply: false keeps the active proxy",
      "type": "boolean"
    },
    "library": {
      "type": "string"
    },
    "names": {
      "description": "[swatch or colour group names in the library] (default: all of it; a group comes as a colour group, a single swatch ungrouped); default: all of it; a group comes as a colour group, a single swatch ungrouped",
      "items": {},
      "type": "array",
      "x-khp-name": "name",
      "x-khp-types": [
        "Swatch",
        "SwatchGroup"
      ]
    },
    "stroke": {
      "description": "also apply the first one to the selection and the defaults, as paint.setFill / paint.setStroke; one of several alternative parameters"
    }
  },
  "returns": "{library, added: [names in the document], existing: [names already there], applied?: name}",
  "type": "object"
}
```

Generated from the command list of @kition/vector-darwin-arm64@0.1.0 and the kit itself (vector_commands through @kition/cli@0.1.1, built from KitionAI/kition-vector@7cf908f).
