> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.knapsack.cloud/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.knapsack.cloud/_mcp/server.

# Asset Sets

## Overview

Patterns and components in your workspace can have multiple asset sets, allowing users to quickly swap between different versions. For example, you could use asset sets to manage brands, color schemes, dark vs. light mode, or any other collection of styling you want to enable across your patterns.

![Demo of toggling asset set to switch between a dark and light theme](https://fdr-prod-docs-files-public.s3.us-east-1.amazonaws.com/knapsack-docs.docs.buildwithfern.com/9b4f4e47bcda8eea7a570e02368032453a9f52d45e9aa4fd1ea04cc267bfa80a/docs/assets/images/5c321dbf-asset-set-demo-jbkcvtwq7e.gif?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIA6KXJSKKNFOCF7G4B%2F20260724%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20260724T211409Z&X-Amz-Expires=604800&X-Amz-Signature=0a6396f34b53599ec764d008c3675a926f80cbe1491fba391f767e9412bcbff8&X-Amz-SignedHeaders=host&x-amz-checksum-mode=ENABLED&x-id=GetObject)

Each asset set is a collection of CSS and Javascript files that determine how your components look and behave. When you add an asset set to a given component, all templates in that component are affected, allowing you to apply fundamental changes without updating each template manually.

***

## Creating Asset Sets

To create and apply an asset set in your workspace, follow these steps:

### Step 1: Open the Configuration File

Navigate to `knapsack/data/knapsack.asset-sets.json`.

### Step 2: Add Your Desired Asset Sets

Define your asset sets under the `allAssetSets` section.

Here is an example configuration:

```json
{
  "globalAssetSetIds": ["default", "dark"],
  "allAssetSets": {
    "default": {
      "id": "default",
      "title": "Light",
      "assets": [
        {
          "src": "../packages/design-tokens/dist/design-tokens.css"
        },
        {
          "src": "../packages/styles/dist/styles.css"
        },
        {
          "src": "../packages/styles/dist/default.css"
        },
      ]
    },
    "dark": {
      "id": "dark",
      "title": "Dark",
      "inlineJs": "document.body.classList.add('dark')",
      "inlineCss": "body { padding: 1rem }"
      "assets": [
        {
          "src": "../packages/design-tokens/dist/design-tokens.css"
        },
        {
          "src": "../packages/styles/dist/styles.css"
        },
        {
          "src": "../packages/styles/dist/dark-mode.css"
        },
      ]
    }
  }
}
```

* `globalAssetSetIds`: Lists the IDs of globally available asset sets.
* `allAssetSets`: Contains the definitions of each asset set.

Here we've added our default assetSet which maps to our "Light" theme as well as our "Dark" theme. The src for these assets should point to the path of your file relative to the `knapsack/data` folder.

You can also see in our above example that we are leveraging the `inlineJs` property to execute a small DOM modification. You can use this property to execute any js you need to help facilitate rendering your patterns.

Here we are also using the `inlineCss` property to add an additional style to the body selector.

***

## Managing Asset Sets

Now that you've created an asset set in your workspace, you must apply the asset set before you see it in the UI.

### Step 1: Visit the pattern you want to adjust the asset sets for

Click the "Edit Template" button.

![](https://fdr-prod-docs-files-public.s3.us-east-1.amazonaws.com/knapsack-docs.docs.buildwithfern.com/249bf4cfb4518a3d3fb988005e9559adf9c2090a585beed044630a46940ebaba/docs/assets/images/37f79531-screenshot-2023-11-30-at-1.17-1--1--nlkhhkayn-.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIA6KXJSKKNFOCF7G4B%2F20260724%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20260724T211409Z&X-Amz-Expires=604800&X-Amz-Signature=6f35baf7eeddb4467503ace0d7d3ca091cb4257546d7fed7cbb3b5b47403daaf&X-Amz-SignedHeaders=host&x-amz-checksum-mode=ENABLED&x-id=GetObject)

### Step 2: From the expanded side panel we need to select the "Asset Sets" tab

We can now select the asset sets we want to available to use in the current pattern. Be sure to save your changes.

![](https://fdr-prod-docs-files-public.s3.us-east-1.amazonaws.com/knapsack-docs.docs.buildwithfern.com/37ce55c54f348a87caceb43ae8326c13c27c0c4c31e07e78b5d7709c944c6e2d/docs/assets/images/1f72c5b9-screenshot-2023-11-30-at-1.45-1-0gnpfie7-f.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIA6KXJSKKNFOCF7G4B%2F20260724%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20260724T211409Z&X-Amz-Expires=604800&X-Amz-Signature=434097503e4aceed999a63f0e96bd074642f8bbe462637557912b84f9e390efe&X-Amz-SignedHeaders=host&x-amz-checksum-mode=ENABLED&x-id=GetObject)

### Step 3: You will now be able to toggle the available asset sets

![](https://fdr-prod-docs-files-public.s3.us-east-1.amazonaws.com/knapsack-docs.docs.buildwithfern.com/7cee732f86c6682ac15fde8b34f5d3fe5d97ca981f48537bdc884cdefef404dc/docs/assets/images/445403b2-screenshot-2023-11-30-at-3.09.53-pm-nkk5c1il_o.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIA6KXJSKKNFOCF7G4B%2F20260724%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20260724T211409Z&X-Amz-Expires=604800&X-Amz-Signature=de7498ff78eac472c6d53e74260ffd55b529d758e6da73198ed6f117d3430afb&X-Amz-SignedHeaders=host&x-amz-checksum-mode=ENABLED&x-id=GetObject)