Skip to content

@viamrobotics/prime-ui

@viamrobotics/prime-ui is Viam’s Svelte 5 component library. Components are built on top of design tokens from @viamrobotics/tailwind-config and styled with Tailwind CSS v4.

  1. Install the package, its svelte peer, and tailwindcss to compile the classes. @viamrobotics/tailwind-config comes with the package as a dependency, and installing it directly as well gives your own classes the same tokens:

    Terminal window
    pnpm add @viamrobotics/prime-ui @viamrobotics/tailwind-config svelte tailwindcss
  2. In your app’s main CSS, import Tailwind and the prime-ui stylesheet:

    @import "tailwindcss";
    @import "@viamrobotics/prime-ui/styles.css";

    Tailwind v4 skips node_modules when it detects which classes to generate, so the package ships a stylesheet that points Tailwind at its compiled components. It also imports the tokens from @viamrobotics/tailwind-config and declares the @source. Import it even if you also add your own @source: the tokens it imports carry the component classes (input, focus-ring) the controls wear, and an @source alone would leave every control without them.

<script lang="ts">
import { Field, Input, Label } from '@viamrobotics/prime-ui';
let value = $state('');
</script>
<Field class="flex flex-col gap-1">
<Label>Email</Label>
<Input type="email" bind:value />
</Field>

Every prime control shows the same focus indicator: a 2px link blue outline, offset 2px, on :focus-visible. It is an outline rather than a ring box-shadow so it survives Windows forced-colors mode and never collides with a real shadow. The tokens package defines it as two component classes you can reuse on your own controls so they match:

Class Use it on
focus-ring The focusable element itself. Also sets outline: none so the browser’s default ring does not double.
focus-ring-within A frame whose focus lives on a child, the way Input.Group wraps an Input.
<button class="focus-ring rounded-sm px-2 py-1">Save</button>

Buttons show the ring for keyboard focus only. Text inputs match :focus-visible on any focus, so they ring on click too, as native inputs do.

Icon takes an SVG path string or a Svelte icon component. Install @mdi/js for the Material Design icons, and import the Viam glyphs from @viamrobotics/prime-ui/icons.

Every component has a page with a live sandbox, usage snippets, and its states, rendered from source in dev and from the built package on deploy.

Browse the components

The clickOutside attachment and the keybindings registry cover outside presses and keyboard shortcuts. Coming from @viamrobotics/prime-core? See Migrating from prime-core.