Use Components in Claude Artifacts

Give Claude a short set of instructions so the artifacts it builds use UI SDK web components.

Let's get Claude to build its artifacts with UI SDK. An artifact is a page Claude makes for you in a chat, like a prototype, a form or a small tool.

We'll give Claude a short set of instructions once. After that, when an artifact needs a dialog, a select or a date picker, Claude builds it with the web components from @ui-sdk/web.

Copy the Instructions

Start by copying this block. It tells Claude which components to use, where to read about them and how to load them:

Prompt
Whenever I need UI components (in artifacts, HTML pages or prototypes), use UI SDK web components (@ui-sdk/web). Don't use another component library unless I ask.

When building with UI SDK web:
- Fetch https://data.jsdelivr.com/v1/packages/npm/@ui-sdk/web/resolved?specifier=latest to get the latest version.
- Before building, read https://cdn.jsdelivr.net/npm/@ui-sdk/web@<version>/docs/components.md. It has every component's composition, attributes and events in one file. Read docs/components/<name>.md at the same path only when you need a component's examples. If components.md is missing, read docs/llms.txt at the same path instead.
- Load the components with <script type="module" src="https://cdn.jsdelivr.net/npm/@ui-sdk/web@<version>/browser/web.js"></script>, pinned to that exact version.
- Fetch https://cdn.jsdelivr.net/npm/@ui-sdk/web@<version>/browser/web.css, publish it as one of the artifact's own files, and link it with <link rel="stylesheet" href="web.css" />. If the artifact can only be a single HTML file, put the contents of web.css in a <style> tag instead. Don't link it from the CDN; artifact pages block outside stylesheets.
- Style with the --ui-* tokens and data-slot selectors from web.css rather than your own design tokens.

Add Them to Claude

Paste the block where Claude keeps your instructions:

  • Claude on the web or desktop. Open Settings, choose Your Claude, and paste it into Instructions.
  • Claude Code. Paste it into ~/.claude/CLAUDE.md. Create the file if it isn't there yet.

Claude Code reads CLAUDE.md when a session starts. Start a new session, then run /memory to check that the file is loaded. For one project only, use the CLAUDE.md in that project's folder instead.

Ask for an Artifact

Now ask for something with a few components in it:

Prompt
Build an artifact for booking a table: a date picker, a select for the time, a number input for the party size and a dialog that confirms the booking.

Claude looks up the latest version, reads the docs and builds the page. Its HTML loads UI SDK with two tags:

<script
  type="module"
  src="https://cdn.jsdelivr.net/npm/@ui-sdk/web@0.4.1/browser/web.js"
></script>
<link rel="stylesheet" href="web.css" />

Try it with the keyboard. Open the dialog and press Escape. It closes, and focus goes back to the button that opened it.

Next