Getting started
ARC UI is 169 Web Components built with Lit. They work as plain HTML, and React, Vue, Svelte, Angular, Solid and Preact each get a generated wrapper package with typed props.
Install
npm install @arclux/arc-ui lit
pnpm add @arclux/arc-ui lit
yarn add @arclux/arc-ui lit
Lit is a peer dependency, so you install it alongside ARC UI. ARC UI needs a bundler. For pages with no build step, the HTML package has CSS-only versions of many components.
Your first component
- Import the tokens and register the components
base.cssdefines the design tokens, andregisterdefines the components.jsimport '@arclux/arc-ui/base.css'; import '@arclux/arc-ui/register'; - Load the fonts
ARC UI ships no font files.
base.cssnames three reference faces (Host Grotesk for body text, Tomorrow for labels, JetBrains Mono for code) and loads none of them. Skip this step and text renders insystem-ui, and code inui-monospace. A font CDN is the quickest way to load them:html<link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Host+Grotesk:wght@300..800&family=JetBrains+Mono:wght@400..700&family=Tomorrow:wght@400;500;600&display=swap">To self-host, or to use your own typefaces instead, seeLoading the font files.
- Write the markup
These are plain HTML elements, with no provider or wrapper component to set up.
html<arc-button variant="primary">Get Started</arc-button> <arc-input label="Email" placeholder="you@example.com"></arc-input> <arc-toggle label="Dark mode"></arc-toggle> - The result
This is the markup above, rendered on this page.
Get Started
Import patterns
The three entry points differ in how much they load:
@arclux/arc-ui/registerRegisters every component (except arc-code-block, below). The simplest choice while you're trying things out.@arclux/arc-ui/buttonRegisters one component and the components it uses. Use these in production to keep the bundle small.{ ArcButton } from '@arclux/arc-ui'The class, for extending it or creating elements in script. Loads and registers every component except arc-code-block and the marketing and media groups (@arclux/arc-ui/marketing, @arclux/arc-ui/media).arc-code-block isn't in register or any other barrel, because
it carries a syntax highlighter. Import it from @arclux/arc-ui/code-block.
Framework setup
Prism, the project's code generator, writes each wrapper package from the Lit source. Only the import changes:
import { Button, Card } from '@arclux/arc-ui-react'; // React
import { Button, Card } from '@arclux/arc-ui-vue'; // Vue
import { Button, Card } from '@arclux/arc-ui-svelte'; // Svelte
import { Button, Card } from '@arclux/arc-ui-angular'; // Angular
import { Button, Card } from '@arclux/arc-ui-solid'; // Solid
import { Button, Card } from '@arclux/arc-ui-preact'; // Preact
The Frameworks guide covers install and usage for each one, and using the elements without a wrapper.
Theming
The data-theme attribute on <html> picks one of three modes:
<html data-theme="dark"> <!-- default -->
<html data-theme="light">
<html data-theme="auto"> <!-- follows OS preference -->
The theme toggle in this site's top bar sets that attribute. For a theme of your own, override the tokens (see Theming) or build one in theTheme Synthesizer and export it.
Design tokens
base.css defines 237 custom properties, and the components read the same ones. Your own CSS can use them too:
@import '@arclux/arc-ui/base.css';
.my-component {
color: var(--text-primary);
background: var(--bg-card);
padding: var(--space-md);
border-radius: var(--radius-md);
font-family: var(--font-body);
box-shadow: var(--shadow-md);
}
--space-xs · sm · md · lg · xl · 2xl--radius-xs · sm · md · lg · xl · full--shadow-xs · sm · md · lg · xlThe Design tokens page lists them by group.
TypeScript
The framework wrappers ship their own types. To type arc-* tags in React, Preact or Solid JSX without a wrapper, add the generated declaration file to your program as a file. A types entry in compilerOptions does nothing here (see Without a wrapper).
{
"include": [
"src",
"node_modules/@arclux/arc-ui/types/react-jsx.d.ts"
]
}
Your own components
A component you write with Lit has its own shadow root, and a shadow root does not see document styles. The *, *::before, *::after { box-sizing: border-box }reset in your global stylesheet stops at its boundary, so padded boxes inside it overflow and nothing in your page's CSS shows why.
Adopt tokenStyles, the styles ARC UI's own components start from. It has the box-sizing and margin reset, the static token defaults and the reduced-motion rule:
import { LitElement, html, css } from 'lit';
import { tokenStyles } from '@arclux/arc-ui/shared-styles';
class AppPanel extends LitElement {
static styles = [
tokenStyles,
css`
:host { display: block; padding: var(--space-md); }
`,
];
render() {
return html`<slot></slot>`;
}
}
customElements.define('app-panel', AppPanel);
Themed tokens (colors, shadows, gradients) aren't in it. Custom properties inherit through the shadow boundary, so they reach your component from base.css on the document, as they do for every ARC UI component.
tokenStyles also zeroes every margin and padding, as ARC UI's components expect. To add only the box-sizing reset to components you already have, adoptresetStyles from the same module instead.
Testing
Some components read the children you write as data and render their own copies. Thearc-menu-items inside arc-dropdown-menu and thearc-options inside arc-segmented-control andarc-select are display: none. The visible, clickable item is the copy in the parent's shadow root, so a test that clicks the element you wrote fails with "element is not visible". Each component that works this way says "read as data" on its default slot, in the API reference and incustom-elements.json, where each parent also lists the elements it expects under children, with their slot.
Find the rendered item the way a user does, by its role and its text. The rendered copies carry the roles (menuitem, radio, option), and Playwright's role locators pierce shadow roots:
// Playwright: the rendered copy, found by its role and text
await page.getByRole('menuitem', { name: 'Rename' }).click();
await page.getByRole('radio', { name: 'Weekly' }).click();
// Not the element you authored: it is display: none, and never receives the click
// await page.locator('arc-menu-item[value="rename"]').click();
Going to production
A custom element renders its fallback content until JavaScript registers it.base.css hides that fallback (:not(:defined) { opacity: 0 }), so unregistered components stay hidden and fade in as their definitions load. On a page with many components, two more steps make them appear sooner and stop the layout shifting.
Register what's above the fold first. Import the components visible on first paint statically, so they land in a small chunk, and load the full registry with a dynamic import after them.
import '@arclux/arc-ui/base.css';
// Shell components visible on first paint — small synchronous chunk
import '@arclux/arc-ui/top-bar';
import '@arclux/arc-ui/button';
import '@arclux/arc-ui/badge';
// Everything else — lazy chunk that fades in when ready
import('@arclux/arc-ui/register');
Reserve space for layout-critical elements. A hidden element still takes up space, so give shell components their final size before they upgrade and nothing moves when they do.
arc-top-bar:not(:defined) {
display: block;
height: 64px;
}
arc-button:not(:defined) {
display: inline-flex;
min-height: 40px;
}
This site loads its top bar, navigation and buttons this way. If you server-render, every component arrives as declarative shadow DOM, styled before any JavaScript runs. SeeServer rendering.