Getting started

Get started

NyctoUI is installed by your coding agent, not from npm. Give it one prompt: it reads the installation guide, asks where files should go, and copies the components into your project.

Ask your agent

In a project you already have, paste this into Claude Code, Cursor or any agent that can read a URL and edit files:

Set up NyctoUI in this project. Follow https://r.nyctoui.dev/install.md

It asks where your components and styles should go, and whether to add a small demo, every component, or only the ones you name. Starting from nothing works too. The agent creates the project first:

Create a Vite + React project and use NyctoUI. Follow https://r.nyctoui.dev/install.md

After that, ask for components by name or by what they do (“add a date picker”, “I need a command palette”). The agent remembers your folders in nyctoui.json and won’t ask again.

If your agent can’t open links, paste the whole guide instead. This is install.md as Markdown, the same text as below:

# NyctoUI installation guide

NyctoUI is a set of React components for dense, quiet product interfaces,
built on ui-sdk for behavior and StyleX for styling. There is no npm package
to install: you, the agent, copy each component's source into the user's
project and adapt its imports, following this guide.

Everything lives at `https://r.nyctoui.dev`:

| What | URL |
|---|---|
| This guide | `https://r.nyctoui.dev/install.md` |
| Index of everything | `https://r.nyctoui.dev/llms.txt` |
| Registry (machine-readable) | `https://r.nyctoui.dev/registry.json` |
| Source files | `https://r.nyctoui.dev/<path>`, with `<path>` from the registry |
| Component specs | `https://r.nyctoui.dev/specs/<name>.md` |
| Every release | `https://r.nyctoui.dev/versions.json` |
| Any file, as released in one version | `https://r.nyctoui.dev/v<version>/<path>` |

These URLs serve the latest release. Each response carries an
`x-nyctoui-version` header naming the version it came from; record that
version, not a guess.

The guide has two flows:

- **Set up**, once per project: dependencies, StyleX, CSS, the shared style
  files in the tint the user picks, a `nyctoui.json` that records the user's
  choices, and the first components (a demo, all of them, or the ones the
  user names).
- **Add a component**, every time after that.

If the project has no `nyctoui.json` at its root, start with set up. If it
has one, go straight to adding components.

## Before you start

1. **Read the registry.** Fetch `registry.json`. `setup` lists the packages
   and style files every project needs. `components.<name>` lists each
   component's files, the other components it requires, and its packages.
   Use the versions given there; never upgrade them on your own.
2. **Know the project.** Find the framework from `package.json` and config
   files. This guide has a tested recipe for Vite with React. For another
   framework, follow the same steps and take the StyleX plugin setup from
   StyleX's installation guide (below).
3. **Requirements.** React 19 and TypeScript. If the project is on an older
   React, tell the user before going further.
4. **Look for another styling system.** NyctoUI brings its own reset,
   tokens and look, so a CSS framework already in the project competes with
   it: its global styles (Tailwind's Preflight, Bootstrap's Reboot) can
   override NyctoUI's components, and the two design languages sit side by
   side. Check for:

   | System | Signs |
   |---|---|
   | Tailwind CSS | `tailwindcss` or `@tailwindcss/*` in `package.json`; `tailwind.config.*`; `@import "tailwindcss"` or `@tailwind` in a CSS file |
   | shadcn/ui | `components.json` at the root; `class-variance-authority`, `tailwind-merge` or `@radix-ui/*` in `package.json` |
   | Other CSS frameworks | `bootstrap`, `bulma`, `daisyui`, `unocss`, `@pandacss/dev`, `@mui/material`, `@chakra-ui/react`, `@mantine/core`, `antd`, `styled-components`, `@emotion/react` in `package.json` |

   CSS modules and plain CSS files are not frameworks; step 7 covers them.

   If you find any, report them in set up step 1: what you found and the evidence
   (the package, config file or import), and ask whether the user wants to
   remove it or keep it alongside NyctoUI. This applies to fresh projects
   too: some templates, such as `create-next-app`, add Tailwind by default.
   If you find none, say nothing and don't ask.
5. **Read StyleX's guides.** NyctoUI is styled with StyleX, and StyleX
   publishes guides written for agents. Read them before you start; they
   cover what this guide doesn't repeat.

   | Guide | URL | Use it for |
   |---|---|---|
   | Installation | `https://raw.githubusercontent.com/facebook/stylex/main/packages/docs/static/llm/stylex-installation.md` | Wiring the StyleX plugin into any bundler or framework, and its troubleshooting list. |
   | Authoring | `https://raw.githubusercontent.com/facebook/stylex/main/packages/docs/static/llm/stylex-authoring.md` | Writing styles: `stylex.create`, `defineVars`, conditions, and the patterns StyleX rejects. Read it before passing `sx` overrides or building new UI with NyctoUI's tokens. |

   The same guides, for people, are at
   `https://stylexjs.com/docs/llm-resources`.

   **Where the two guides differ, this one wins**, because NyctoUI's
   components depend on these choices. Everything else, StyleX's guide
   decides.

   | Topic | StyleX's guide | For NyctoUI |
   |---|---|---|
   | `useCSSLayers` | Optional, off by default. | Always `true` (step 3). |
   | Layer order | Not covered. | `@layer reset, ui-sdk;` before any stylesheet (step 5). |
   | `.stylex` imports | Path aliases need the `aliases` option. | Keep them relative (see "Rewriting imports"). |
   | Browser targets | Not covered. | Modern targets, so `light-dark()` stays native (step 4). |
   | Vite config types | `import stylex from '@stylexjs/unplugin'`. | Under `"module": "nodenext"`, use the cast in step 3. |
   | `unstable_moduleResolution` | Listed as an option. | Not needed: NyctoUI's imports are relative. |

6. **Read ui-sdk's docs once it's installed.** NyctoUI's behavior (focus,
   keyboard, popups, ARIA) comes from ui-sdk, which ships its own docs for
   agents inside the package: start at
   `node_modules/@ui-sdk/react/docs/llms.txt`, and each component's page is
   at `docs/components/<name>.md`. Read them when you need to know what a
   part does or which props it takes beyond the NyctoUI spec.

## Set up

### 1. Ask where things go, and what to add

Ask the user once, with every question in a single message, and offer
defaults that fit the project:

- **Components folder.** Default: `src/components/ui`. If the project keeps
  components somewhere else (for example `components/` at the root, as in a
  Next.js app without `src/`), suggest that convention instead.
- **Styles folder.** Default: `src/styles`. NyctoUI adds three files there:
  `tokens.stylex.ts`, `markers.stylex.ts` and `reset.css`.
- **Tint.** Every neutral in NyctoUI (surfaces, borders, text, the
  near-black brand) carries a faint hue. The project gets one of them, and
  only that one: the other tints' colors are left out. Offer the choices by
  name, with Blue as the default, and say the user can preview each in the
  theme menu at the top of `https://nyctoui.dev/docs`:

  | Tint | Looks like |
  |---|---|
  | Blue (default) | A cool blue-gray. |
  | Gray | Pure grays, no hue. |
  | Purple, Pink, Red, Orange, Green | The same grays, turned to that hue. |

  Only the hue moves: lightness, and so contrast, is the same in every
  tint, and status colors (red errors, green success) stay as they are.

  Also offer **all tints**, for a project that lets its own users switch
  (as the docs' theme menu does). Then the project keeps every tint as a
  switchable theme, and one of them, Blue unless the user names another, is
  the default. Skip this question if the request already names a tint.
- **What to add.** Default: the demo.
  - **Demo:** Button and Dropdown, with a small example: a row of buttons
    and a menu opened from one. It is the quickest way to see NyctoUI
    working, and the menu proves popups, layers and motion work too.
  - **All components:** every component in the registry, plus
    the npm packages they need (`dependencies` across all entries).
  - **Only what I name:** specific components, or none for now.

  Skip this question when the user's request already says what to add
  ("set up NyctoUI and add a date picker").
- **Existing styling system**, only if "Before you start" found one. Name
  it and how you found it, then ask: remove it, or keep it alongside
  NyctoUI? Default: keep. Say what removing would take: the files whose
  markup uses it (for example how many components use Tailwind classes, or
  the shadcn components in `components/ui`) would lose their styles, and
  you won't rewrite them.

  - **Remove:** uninstall its packages, delete its config files
    (`tailwind.config.*`, `postcss.config.*` if Tailwind is its only
    plugin, `components.json`) and its imports and directives in CSS and
    in the bundler config. Don't delete or rewrite the user's components or
    markup; list the files that still use it so the user can replace them,
    with NyctoUI components where one fits.
  - **Keep:** change none of it. Its global CSS has to lose to NyctoUI's
    components, so in step 7 treat it like the project's other global CSS,
    and in "Verify" check a component in the browser, not just the build.
    Tell the user that the two can look different side by side.

Before suggesting a folder, look inside it. If it already has files with
NyctoUI's names (`button.tsx`, for example from shadcn/ui), say so and
suggest a separate folder such as `src/components/nyctoui`. Never overwrite
an existing file.

If the user says to just go ahead, or answers "defaults", use the defaults
and say which folders and tint you chose and that you'll add the demo.

### 2. Install the packages

Install `setup.dependencies` and `setup.devDependencies` from the registry.
**Pin ui-sdk exactly**: it is in beta and its API changes between releases,
so a `^` range can break components later.

```sh
npm install @stylexjs/stylex @fontsource-variable/geist @fontsource-variable/geist-mono
npm install --save-exact @ui-sdk/react@<version> @ui-sdk/core@<version>
npm install --save-dev @stylexjs/unplugin
```

Use the user's package manager (pnpm, yarn, bun) if the project has its
lockfile, and the version numbers from the registry.

### 3. Configure StyleX

#### Vite

```ts
// vite.config.ts
import react from '@vitejs/plugin-react'
import stylexUnplugin from '@stylexjs/unplugin'
import { defineConfig } from 'vite'

// @stylexjs/unplugin's types describe a CommonJS module, so under
// "module": "nodenext" TypeScript adds a `default` layer that the ESM build
// Vite loads doesn't have. This keeps the runtime value and fixes the type.
const stylex = stylexUnplugin as unknown as typeof stylexUnplugin.default

export default defineConfig({
  plugins: [
    // Before react(), to keep Fast Refresh.
    stylex.vite({ useCSSLayers: true }),
    react(),
  ],
})
```

Keep any plugins the config already has. The cast is for the current Vite
template, whose `tsconfig.node.json` uses `"module": "nodenext"`. If the
config is typechecked with `"moduleResolution": "bundler"` instead, write
`import stylex from '@stylexjs/unplugin'` and drop the cast.

`useCSSLayers: true` is required: the layer order in step 5 assumes StyleX
writes its rules into layers.

### 4. Set the browser targets

NyctoUI's colors use `light-dark()`. Without targets, the build lowers it
to a fallback for old browsers, and then setting `color-scheme` on an
element no longer switches its theme. There is no error. Add a `.browserslistrc` at the
project root (or merge these into an existing browserslist):

```
last 2 Chrome versions
last 2 Firefox versions
last 2 Safari versions
last 2 Edge versions
```

### 5. Declare the CSS layer order

Components, ui-sdk's base CSS and the reset each sit in a CSS layer, and a
layer declared earlier loses to one declared later. StyleX's layers have to
come last, so declare the other two **before any stylesheet loads**. In
Vite's dev server, StyleX's stylesheet arrives before the app's CSS, so this
has to go in `index.html`, first thing in `<head>`:

```html
<head>
  <meta charset="UTF-8" />
  <style>@layer reset, ui-sdk;</style>
  ...
</head>
```

With a framework that renders the document in React (Next.js, TanStack
Start, React Router), put the same `<style>` first in the root layout's
`<head>`.

Leave the project's viewport tag as it is unless the app is meant for
phones. Drawer, Sidebar Layout, Toast and Keyboard pad themselves with the
screen's safe areas (`env(safe-area-inset-*)`), which are 0 unless the page
opts in with `viewport-fit=cover`. If it does, the page itself must keep its
own content clear of the notch:

```html
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
```

Never add `maximum-scale` or `user-scalable=no`: NyctoUI's inputs are 16px
on touch screens, so iOS doesn't zoom into them, and people must still be
able to zoom.

### 6. Copy the style files

Copy every file in `setup.files` into the styles folder: `tokens.stylex.ts`,
`markers.stylex.ts` and `reset.css`. Copy them unchanged, then make the two
edits below for the tint from step 1, and no others.

In `tokens.stylex.ts`:

1. **Set the tint.** Change the one line

   ```ts
   const TINT: keyof typeof TINTS = 'blue'
   ```

   to the chosen tint's key: `'blue'`, `'gray'`, `'purple'`, `'pink'`,
   `'red'`, `'orange'` or `'green'` (the keys of `TINTS` just above it).
   With all tints, set it to the default one. Leave `TINTS` itself alone.
2. **One tint: delete the other tints.** Delete every line from
   `// nyctoui:tints:start` to `// nyctoui:tints:end`, both marker lines
   included. That section holds the switchable themes (`tintBlue`,
   `tintGreenHeatmap`, `tintSwatches` and the rest); StyleX writes CSS for
   each one, used or not, and no component imports them. With all tints,
   keep it as it is.

Then confirm the file still typechecks (it does after both edits; an error
means a line outside the section was cut).

### 7. Set up the global CSS

In the app's main CSS file (`src/index.css` in Vite), load the fonts and the
reset:

```css
@import '@fontsource-variable/geist/wght.css';
@import '@fontsource-variable/geist-mono/wght.css';
@import './styles/reset.css';
```

Adjust the reset path to the styles folder. **Existing global CSS** in the
project is unlayered, and unlayered CSS beats every layer, so a rule like
`button { … }` would override NyctoUI. For a fresh project template, remove
the template's demo CSS (Vite's `index.css` contents and `App.css`). In an
existing project, ask the user before touching their CSS; the fix is to wrap
it in `@layer app { … }` and declare `app` in the layer order from step 5:
`@layer reset, ui-sdk, app;`.

A CSS framework the user chose to keep (step 1) follows the same rule:
every layer it uses must be declared before StyleX's. Tailwind v4 already
puts its CSS in the layers `theme, base, components, utilities`, so name
them in step 5's declaration: `@layer reset, ui-sdk, theme, base,
components, utilities;`. A framework whose CSS is unlayered (Tailwind v3,
Bootstrap) outranks NyctoUI wherever their rules meet; tell the user, and
check the result in the browser.

### 8. Record the setup

Create `nyctoui.json` at the project root:

```json
{
  "registry": "https://r.nyctoui.dev",
  "version": "<registry version>",
  "framework": "vite",
  "paths": {
    "components": "src/components/ui",
    "styles": "src/styles"
  },
  "tint": "blue",
  "allTints": false,
  "components": {}
}
```

Every later "add a component" reads the paths from here, so the user is
never asked twice. `tint` is the `TINT` set in step 6, and `allTints` says
whether the tints section was kept; updates (see "Updating") reapply both.

### 9. Add the first components

Do what the user chose in step 1, using "Add a component" below for the
mechanics:

- **Demo:** add `button` and `dropdown`. Then write the example as its own
  file, `NyctoUIDemo.tsx` next to the app's root component: a row with a
  primary, a secondary and a ghost Button, and a Dropdown whose trigger is
  a Button, with three or four items and a separator. Base it on the
  Dropdown spec's examples. In a freshly created project, render the demo
  from the root component in place of the template's content. In an
  existing project, don't touch the user's pages; tell them where the file
  is and how to render it.
- **All components:** add every entry in `components`. Check every file for
  clashes first, install the union of all `dependencies` in one command,
  then copy and rewrite the files. Don't build an example for each one;
  tell the user which components were added and that each has a spec.
- **Only what I name:** add those, or nothing.

Then verify (see "Verify"). With the demo, also open the menu: it should
appear on a raised, rounded surface with items you can move through with
the arrow keys.

## Add a component

1. **Read `nyctoui.json`.** No file means the project isn't set up yet: run
   set up first.
2. **Look it up.** Find the component in `registry.json` under `components`.
   Users name components loosely ("a dropdown menu", "date input"); match on
   the title and description. The entry gives:
   - `files`: every file to copy, including helpers and the components it
     builds on;
   - `requires`: the other NyctoUI components that come with it;
   - `dependencies`: npm packages to install.
3. **Check for clashes.** If a file already exists in the components folder
   and isn't listed in `nyctoui.json`, it belongs to the user: stop and ask.
   A file that is listed is an earlier NyctoUI install; see "Updating" below.
4. **Install** the `dependencies` with the user's package manager.
5. **Copy the files** into the components folder, and **rewrite imports**
   (see the next section). Change nothing else in the code.
6. **Record it** in `nyctoui.json`: add the component and each entry in
   `requires` to `components`, with the registry version:
   `"button": { "version": "0.1.0-beta.1" }`.
7. **Use it** where the user asked, or in a small example if they didn't.
   The spec at `specs/<name>.md` shows the parts, props and examples.
8. **Verify** (see below).

### Rewriting imports

NyctoUI's source has exactly two kinds of local import:

| In the source | Rewrite to |
|---|---|
| `from './other-component'` | Leave as is. All components share one folder. |
| `from '../styles/tokens.stylex'` (and `markers.stylex`) | The relative path from the components folder to the styles folder. |

For example, with components in `src/components/ui` and styles in
`src/styles`, `'../styles/tokens.stylex'` becomes
`'../../styles/tokens.stylex'`.

**Keep `.stylex` imports relative.** Do not rewrite them to a path alias
like `@/styles/tokens.stylex`. StyleX resolves these imports itself and
doesn't read the project's tsconfig or Vite aliases, so an aliased import
typechecks and then fails the build with `Could not resolve the path to the
imported file`. If you see that error, an import of a `.stylex` file isn't
relative. If the user insists on an alias, also add it to the StyleX
plugin's `aliases` option.

Examples and specs import components as `from 'nyctoui/button'` and tokens
as `from 'nyctoui/tokens.stylex'`. That is a placeholder: when you copy
example code into the project, rewrite it to the real location (an alias is
fine for components; tokens follow the rule above).

## Verify

Do this after set up and after every component you add. StyleX fails
quietly: a component can render with no styles at all and no error.

1. **Typecheck and build.** In Vite, `npm run build` does both. Both must
   pass.
2. **Check the built CSS.** Colors must keep `light-dark()`, every StyleX
   variable used must be defined, and the layers must be in order. The
   check reads the page the way the browser does: the inline `<style>` in
   `dist/index.html` (where step 5 put the layer order), then the CSS
   files.

   ```sh
   node -e "
   const fs = require('fs'), path = require('path');
   const dir = 'dist/assets';
   const html = fs.existsSync('dist/index.html') ? fs.readFileSync('dist/index.html', 'utf8') : '';
   const inline = [...html.matchAll(/<style[^>]*>([\s\S]*?)<\/style>/g)].map(m => m[1]).join('');
   const css = inline + fs.readdirSync(dir).filter(f => f.endsWith('.css')).map(f => fs.readFileSync(path.join(dir, f), 'utf8')).join('');
   const defined = new Set([...css.matchAll(/(--x[a-z0-9]+)\s*:/g)].map(m => m[1]));
   const missing = [...new Set([...css.matchAll(/var\((--x[a-z0-9]+)/g)].map(m => m[1]))].filter(v => !defined.has(v));
   const layers = [...new Set([...css.matchAll(/@layer\s*([\w.,\s-]+?)\s*[;{]/g)].flatMap(m => m[1].split(/\s*,\s*/)))];
   console.log('light-dark() kept:', css.includes('light-dark('));
   console.log('undefined StyleX vars:', missing.length ? missing : 'none');
   console.log('layer order:', layers.join(' < '));
   "
   ```

   `light-dark() kept` must be `true` (if not, recheck step 4),
   `undefined StyleX vars` must be `none`, and the layer order must start
   `reset < ui-sdk` and end with StyleX's `priority` layers. Frameworks
   without a built `index.html` (Next.js, TanStack Start) put the layer
   order in the root layout instead; check it there, or in the browser.
3. **Look at it in the dev server, if you can.** The build can be right
   while the dev server is wrong: a missing step 5 only shows there. With a
   browser or browser tool, open the dev server and check a component's
   computed style. A Button is a pill: 32px tall, `border-radius: 9999px`,
   14px text at weight 500. A transparent, square button means the reset is
   outranking StyleX (recheck step 5) or StyleX's CSS isn't loading
   (recheck step 3). If you have no browser, ask the user to look.

Then tell the user what you set up or added, which folders you used, and
anything you didn't do (for example, CSS of theirs you left untouched).

## Updating

`nyctoui.json` records the version each component came from. Every release
stays available: the source as it was in any release is at
`https://r.nyctoui.dev/v<version>/<path>`, unprefixed URLs serve the latest,
and `https://r.nyctoui.dev/versions.json` lists them all. NyctoUI is in beta: versions are
`0.1.0-beta.N`, and any new beta may change a component's API, so tell the
user when an update changes props or parts they use.

To update, compare the recorded version's source with the current one, and
the user's copy with both: users edit their copies. Bring upstream changes across as a merge,
show the user anything that conflicts with their edits, and never overwrite
a copy wholesale. Then update the versions in `nyctoui.json`.

`tokens.stylex.ts` is updated the same way, and always carries the step 6
edits: take the new release's file, set `TINT` to `tint` from
`nyctoui.json`, and delete the tints section unless `allTints` is true.

To change the tint later, set `TINT` to the new one and update `tint` in
`nyctoui.json`. To go from one tint to all, copy the tints section from the
recorded version's `tokens.stylex.ts` back in and set `allTints` to true.

## Theming and overrides

- Light and dark follow `color-scheme`. The reset sets `light dark` on the
  root, so the system setting decides; set `color-scheme: light` or `dark`
  on any element to force a theme for that subtree.
- With all tints kept, switch tint the same way: apply a tint's themes to
  an element, usually `<html>` or the app's root, and its subtree takes
  that tint. `stylex.props(tintGreen, tintGreenHeatmap)` (add
  `tintGreenLanding` only if the app uses the `landing` tokens).
  `tintSwatches` has one readable sample color per tint, for drawing a
  picker. With one tint, the tint is fixed by `TINT`.
- Components take no `className` or `style`. To adjust one, pass StyleX
  styles to its `sx` prop; they are merged last.
- Use the tokens (`colors`, `sizes`, `radii`, `fontSizes` and the rest, from
  `tokens.stylex.ts`) for any value, so new UI matches the components.

The installation guide

This is the guide your agent follows, exactly as it reads it at r.nyctoui.dev/install.md. You don’t need to run any of it yourself.

NyctoUI is a set of React components for dense, quiet product interfaces, built on ui-sdk for behavior and StyleX for styling. There is no npm package to install: you, the agent, copy each component's source into the user's project and adapt its imports, following this guide.

Everything lives at https://r.nyctoui.dev:

WhatURL
This guidehttps://r.nyctoui.dev/install.md
Index of everythinghttps://r.nyctoui.dev/llms.txt
Registry (machine-readable)https://r.nyctoui.dev/registry.json
Source fileshttps://r.nyctoui.dev/<path>, with <path> from the registry
Component specshttps://r.nyctoui.dev/specs/<name>.md
Every releasehttps://r.nyctoui.dev/versions.json
Any file, as released in one versionhttps://r.nyctoui.dev/v<version>/<path>

These URLs serve the latest release. Each response carries an x-nyctoui-version header naming the version it came from; record that version, not a guess.

The guide has two flows:

  • Set up, once per project: dependencies, StyleX, CSS, the shared style files in the tint the user picks, a nyctoui.json that records the user's choices, and the first components (a demo, all of them, or the ones the user names).
  • Add a component, every time after that.

If the project has no nyctoui.json at its root, start with set up. If it has one, go straight to adding components.

Before you start

  1. Read the registry. Fetch registry.json. setup lists the packages and style files every project needs. components.<name> lists each component's files, the other components it requires, and its packages. Use the versions given there; never upgrade them on your own.

  2. Know the project. Find the framework from package.json and config files. This guide has a tested recipe for Vite with React. For another framework, follow the same steps and take the StyleX plugin setup from StyleX's installation guide (below).

  3. Requirements. React 19 and TypeScript. If the project is on an older React, tell the user before going further.

  4. Look for another styling system. NyctoUI brings its own reset, tokens and look, so a CSS framework already in the project competes with it: its global styles (Tailwind's Preflight, Bootstrap's Reboot) can override NyctoUI's components, and the two design languages sit side by side. Check for:

    SystemSigns
    Tailwind CSStailwindcss or @tailwindcss/* in package.json; tailwind.config.*; @import "tailwindcss" or @tailwind in a CSS file
    shadcn/uicomponents.json at the root; class-variance-authority, tailwind-merge or @radix-ui/* in package.json
    Other CSS frameworksbootstrap, bulma, daisyui, unocss, @pandacss/dev, @mui/material, @chakra-ui/react, @mantine/core, antd, styled-components, @emotion/react in package.json

    CSS modules and plain CSS files are not frameworks; step 7 covers them.

    If you find any, report them in set up step 1: what you found and the evidence (the package, config file or import), and ask whether the user wants to remove it or keep it alongside NyctoUI. This applies to fresh projects too: some templates, such as create-next-app, add Tailwind by default. If you find none, say nothing and don't ask.

  5. Read StyleX's guides. NyctoUI is styled with StyleX, and StyleX publishes guides written for agents. Read them before you start; they cover what this guide doesn't repeat.

    GuideURLUse it for
    Installationhttps://raw.githubusercontent.com/facebook/stylex/main/packages/docs/static/llm/stylex-installation.mdWiring the StyleX plugin into any bundler or framework, and its troubleshooting list.
    Authoringhttps://raw.githubusercontent.com/facebook/stylex/main/packages/docs/static/llm/stylex-authoring.mdWriting styles: stylex.create, defineVars, conditions, and the patterns StyleX rejects. Read it before passing sx overrides or building new UI with NyctoUI's tokens.

    The same guides, for people, are at https://stylexjs.com/docs/llm-resources.

    Where the two guides differ, this one wins, because NyctoUI's components depend on these choices. Everything else, StyleX's guide decides.

    TopicStyleX's guideFor NyctoUI
    useCSSLayersOptional, off by default.Always true (step 3).
    Layer orderNot covered.@layer reset, ui-sdk; before any stylesheet (step 5).
    .stylex importsPath aliases need the aliases option.Keep them relative (see "Rewriting imports").
    Browser targetsNot covered.Modern targets, so light-dark() stays native (step 4).
    Vite config typesimport stylex from '@stylexjs/unplugin'.Under "module": "nodenext", use the cast in step 3.
    unstable_moduleResolutionListed as an option.Not needed: NyctoUI's imports are relative.
  6. Read ui-sdk's docs once it's installed. NyctoUI's behavior (focus, keyboard, popups, ARIA) comes from ui-sdk, which ships its own docs for agents inside the package: start at node_modules/@ui-sdk/react/docs/llms.txt, and each component's page is at docs/components/<name>.md. Read them when you need to know what a part does or which props it takes beyond the NyctoUI spec.

Set up

1. Ask where things go, and what to add

Ask the user once, with every question in a single message, and offer defaults that fit the project:

  • Components folder. Default: src/components/ui. If the project keeps components somewhere else (for example components/ at the root, as in a Next.js app without src/), suggest that convention instead.

  • Styles folder. Default: src/styles. NyctoUI adds three files there: tokens.stylex.ts, markers.stylex.ts and reset.css.

  • Tint. Every neutral in NyctoUI (surfaces, borders, text, the near-black brand) carries a faint hue. The project gets one of them, and only that one: the other tints' colors are left out. Offer the choices by name, with Blue as the default, and say the user can preview each in the theme menu at the top of https://nyctoui.dev/docs:

    TintLooks like
    Blue (default)A cool blue-gray.
    GrayPure grays, no hue.
    Purple, Pink, Red, Orange, GreenThe same grays, turned to that hue.

    Only the hue moves: lightness, and so contrast, is the same in every tint, and status colors (red errors, green success) stay as they are.

    Also offer all tints, for a project that lets its own users switch (as the docs' theme menu does). Then the project keeps every tint as a switchable theme, and one of them, Blue unless the user names another, is the default. Skip this question if the request already names a tint.

  • What to add. Default: the demo.

    • Demo: Button and Dropdown, with a small example: a row of buttons and a menu opened from one. It is the quickest way to see NyctoUI working, and the menu proves popups, layers and motion work too.
    • All components: every component in the registry, plus the npm packages they need (dependencies across all entries).
    • Only what I name: specific components, or none for now.

    Skip this question when the user's request already says what to add ("set up NyctoUI and add a date picker").

  • Existing styling system, only if "Before you start" found one. Name it and how you found it, then ask: remove it, or keep it alongside NyctoUI? Default: keep. Say what removing would take: the files whose markup uses it (for example how many components use Tailwind classes, or the shadcn components in components/ui) would lose their styles, and you won't rewrite them.

    • Remove: uninstall its packages, delete its config files (tailwind.config.*, postcss.config.* if Tailwind is its only plugin, components.json) and its imports and directives in CSS and in the bundler config. Don't delete or rewrite the user's components or markup; list the files that still use it so the user can replace them, with NyctoUI components where one fits.
    • Keep: change none of it. Its global CSS has to lose to NyctoUI's components, so in step 7 treat it like the project's other global CSS, and in "Verify" check a component in the browser, not just the build. Tell the user that the two can look different side by side.

Before suggesting a folder, look inside it. If it already has files with NyctoUI's names (button.tsx, for example from shadcn/ui), say so and suggest a separate folder such as src/components/nyctoui. Never overwrite an existing file.

If the user says to just go ahead, or answers "defaults", use the defaults and say which folders and tint you chose and that you'll add the demo.

2. Install the packages

Install setup.dependencies and setup.devDependencies from the registry. Pin ui-sdk exactly: it is in beta and its API changes between releases, so a ^ range can break components later.

npm install @stylexjs/stylex @fontsource-variable/geist @fontsource-variable/geist-mono
npm install --save-exact @ui-sdk/react@<version> @ui-sdk/core@<version>
npm install --save-dev @stylexjs/unplugin

Use the user's package manager (pnpm, yarn, bun) if the project has its lockfile, and the version numbers from the registry.

3. Configure StyleX

Vite

// vite.config.ts
import react from '@vitejs/plugin-react'
import stylexUnplugin from '@stylexjs/unplugin'
import { defineConfig } from 'vite'

// @stylexjs/unplugin's types describe a CommonJS module, so under
// "module": "nodenext" TypeScript adds a `default` layer that the ESM build
// Vite loads doesn't have. This keeps the runtime value and fixes the type.
const stylex = stylexUnplugin as unknown as typeof stylexUnplugin.default

export default defineConfig({
  plugins: [
    // Before react(), to keep Fast Refresh.
    stylex.vite({ useCSSLayers: true }),
    react(),
  ],
})

Keep any plugins the config already has. The cast is for the current Vite template, whose tsconfig.node.json uses "module": "nodenext". If the config is typechecked with "moduleResolution": "bundler" instead, write import stylex from '@stylexjs/unplugin' and drop the cast.

useCSSLayers: true is required: the layer order in step 5 assumes StyleX writes its rules into layers.

4. Set the browser targets

NyctoUI's colors use light-dark(). Without targets, the build lowers it to a fallback for old browsers, and then setting color-scheme on an element no longer switches its theme. There is no error. Add a .browserslistrc at the project root (or merge these into an existing browserslist):

last 2 Chrome versions
last 2 Firefox versions
last 2 Safari versions
last 2 Edge versions

5. Declare the CSS layer order

Components, ui-sdk's base CSS and the reset each sit in a CSS layer, and a layer declared earlier loses to one declared later. StyleX's layers have to come last, so declare the other two before any stylesheet loads. In Vite's dev server, StyleX's stylesheet arrives before the app's CSS, so this has to go in index.html, first thing in <head>:

<head>
  <meta charset="UTF-8" />
  <style>@layer reset, ui-sdk;</style>
  ...
</head>

With a framework that renders the document in React (Next.js, TanStack Start, React Router), put the same <style> first in the root layout's <head>.

Leave the project's viewport tag as it is unless the app is meant for phones. Drawer, Sidebar Layout, Toast and Keyboard pad themselves with the screen's safe areas (env(safe-area-inset-*)), which are 0 unless the page opts in with viewport-fit=cover. If it does, the page itself must keep its own content clear of the notch:

<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />

Never add maximum-scale or user-scalable=no: NyctoUI's inputs are 16px on touch screens, so iOS doesn't zoom into them, and people must still be able to zoom.

6. Copy the style files

Copy every file in setup.files into the styles folder: tokens.stylex.ts, markers.stylex.ts and reset.css. Copy them unchanged, then make the two edits below for the tint from step 1, and no others.

In tokens.stylex.ts:

  1. Set the tint. Change the one line

    const TINT: keyof typeof TINTS = 'blue'

    to the chosen tint's key: 'blue', 'gray', 'purple', 'pink', 'red', 'orange' or 'green' (the keys of TINTS just above it). With all tints, set it to the default one. Leave TINTS itself alone.

  2. One tint: delete the other tints. Delete every line from // nyctoui:tints:start to // nyctoui:tints:end, both marker lines included. That section holds the switchable themes (tintBlue, tintGreenHeatmap, tintSwatches and the rest); StyleX writes CSS for each one, used or not, and no component imports them. With all tints, keep it as it is.

Then confirm the file still typechecks (it does after both edits; an error means a line outside the section was cut).

7. Set up the global CSS

In the app's main CSS file (src/index.css in Vite), load the fonts and the reset:

@import '@fontsource-variable/geist/wght.css';
@import '@fontsource-variable/geist-mono/wght.css';
@import './styles/reset.css';

Adjust the reset path to the styles folder. Existing global CSS in the project is unlayered, and unlayered CSS beats every layer, so a rule like button { … } would override NyctoUI. For a fresh project template, remove the template's demo CSS (Vite's index.css contents and App.css). In an existing project, ask the user before touching their CSS; the fix is to wrap it in @layer app { … } and declare app in the layer order from step 5: @layer reset, ui-sdk, app;.

A CSS framework the user chose to keep (step 1) follows the same rule: every layer it uses must be declared before StyleX's. Tailwind v4 already puts its CSS in the layers theme, base, components, utilities, so name them in step 5's declaration: @layer reset, ui-sdk, theme, base, components, utilities;. A framework whose CSS is unlayered (Tailwind v3, Bootstrap) outranks NyctoUI wherever their rules meet; tell the user, and check the result in the browser.

8. Record the setup

Create nyctoui.json at the project root:

{
  "registry": "https://r.nyctoui.dev",
  "version": "<registry version>",
  "framework": "vite",
  "paths": {
    "components": "src/components/ui",
    "styles": "src/styles"
  },
  "tint": "blue",
  "allTints": false,
  "components": {}
}

Every later "add a component" reads the paths from here, so the user is never asked twice. tint is the TINT set in step 6, and allTints says whether the tints section was kept; updates (see "Updating") reapply both.

9. Add the first components

Do what the user chose in step 1, using "Add a component" below for the mechanics:

  • Demo: add button and dropdown. Then write the example as its own file, NyctoUIDemo.tsx next to the app's root component: a row with a primary, a secondary and a ghost Button, and a Dropdown whose trigger is a Button, with three or four items and a separator. Base it on the Dropdown spec's examples. In a freshly created project, render the demo from the root component in place of the template's content. In an existing project, don't touch the user's pages; tell them where the file is and how to render it.
  • All components: add every entry in components. Check every file for clashes first, install the union of all dependencies in one command, then copy and rewrite the files. Don't build an example for each one; tell the user which components were added and that each has a spec.
  • Only what I name: add those, or nothing.

Then verify (see "Verify"). With the demo, also open the menu: it should appear on a raised, rounded surface with items you can move through with the arrow keys.

Add a component

  1. Read nyctoui.json. No file means the project isn't set up yet: run set up first.
  2. Look it up. Find the component in registry.json under components. Users name components loosely ("a dropdown menu", "date input"); match on the title and description. The entry gives:
    • files: every file to copy, including helpers and the components it builds on;
    • requires: the other NyctoUI components that come with it;
    • dependencies: npm packages to install.
  3. Check for clashes. If a file already exists in the components folder and isn't listed in nyctoui.json, it belongs to the user: stop and ask. A file that is listed is an earlier NyctoUI install; see "Updating" below.
  4. Install the dependencies with the user's package manager.
  5. Copy the files into the components folder, and rewrite imports (see the next section). Change nothing else in the code.
  6. Record it in nyctoui.json: add the component and each entry in requires to components, with the registry version: "button": { "version": "0.1.0-beta.1" }.
  7. Use it where the user asked, or in a small example if they didn't. The spec at specs/<name>.md shows the parts, props and examples.
  8. Verify (see below).

Rewriting imports

NyctoUI's source has exactly two kinds of local import:

In the sourceRewrite to
from './other-component'Leave as is. All components share one folder.
from '../styles/tokens.stylex' (and markers.stylex)The relative path from the components folder to the styles folder.

For example, with components in src/components/ui and styles in src/styles, '../styles/tokens.stylex' becomes '../../styles/tokens.stylex'.

Keep .stylex imports relative. Do not rewrite them to a path alias like @/styles/tokens.stylex. StyleX resolves these imports itself and doesn't read the project's tsconfig or Vite aliases, so an aliased import typechecks and then fails the build with Could not resolve the path to the imported file. If you see that error, an import of a .stylex file isn't relative. If the user insists on an alias, also add it to the StyleX plugin's aliases option.

Examples and specs import components as from 'nyctoui/button' and tokens as from 'nyctoui/tokens.stylex'. That is a placeholder: when you copy example code into the project, rewrite it to the real location (an alias is fine for components; tokens follow the rule above).

Verify

Do this after set up and after every component you add. StyleX fails quietly: a component can render with no styles at all and no error.

  1. Typecheck and build. In Vite, npm run build does both. Both must pass.

  2. Check the built CSS. Colors must keep light-dark(), every StyleX variable used must be defined, and the layers must be in order. The check reads the page the way the browser does: the inline <style> in dist/index.html (where step 5 put the layer order), then the CSS files.

    node -e "
    const fs = require('fs'), path = require('path');
    const dir = 'dist/assets';
    const html = fs.existsSync('dist/index.html') ? fs.readFileSync('dist/index.html', 'utf8') : '';
    const inline = [...html.matchAll(/<style[^>]*>([\s\S]*?)<\/style>/g)].map(m => m[1]).join('');
    const css = inline + fs.readdirSync(dir).filter(f => f.endsWith('.css')).map(f => fs.readFileSync(path.join(dir, f), 'utf8')).join('');
    const defined = new Set([...css.matchAll(/(--x[a-z0-9]+)\s*:/g)].map(m => m[1]));
    const missing = [...new Set([...css.matchAll(/var\((--x[a-z0-9]+)/g)].map(m => m[1]))].filter(v => !defined.has(v));
    const layers = [...new Set([...css.matchAll(/@layer\s*([\w.,\s-]+?)\s*[;{]/g)].flatMap(m => m[1].split(/\s*,\s*/)))];
    console.log('light-dark() kept:', css.includes('light-dark('));
    console.log('undefined StyleX vars:', missing.length ? missing : 'none');
    console.log('layer order:', layers.join(' < '));
    "

    light-dark() kept must be true (if not, recheck step 4), undefined StyleX vars must be none, and the layer order must start reset < ui-sdk and end with StyleX's priority layers. Frameworks without a built index.html (Next.js, TanStack Start) put the layer order in the root layout instead; check it there, or in the browser.

  3. Look at it in the dev server, if you can. The build can be right while the dev server is wrong: a missing step 5 only shows there. With a browser or browser tool, open the dev server and check a component's computed style. A Button is a pill: 32px tall, border-radius: 9999px, 14px text at weight 500. A transparent, square button means the reset is outranking StyleX (recheck step 5) or StyleX's CSS isn't loading (recheck step 3). If you have no browser, ask the user to look.

Then tell the user what you set up or added, which folders you used, and anything you didn't do (for example, CSS of theirs you left untouched).

Updating

nyctoui.json records the version each component came from. Every release stays available: the source as it was in any release is at https://r.nyctoui.dev/v<version>/<path>, unprefixed URLs serve the latest, and https://r.nyctoui.dev/versions.json lists them all. NyctoUI is in beta: versions are 0.1.0-beta.N, and any new beta may change a component's API, so tell the user when an update changes props or parts they use.

To update, compare the recorded version's source with the current one, and the user's copy with both: users edit their copies. Bring upstream changes across as a merge, show the user anything that conflicts with their edits, and never overwrite a copy wholesale. Then update the versions in nyctoui.json.

tokens.stylex.ts is updated the same way, and always carries the step 6 edits: take the new release's file, set TINT to tint from nyctoui.json, and delete the tints section unless allTints is true.

To change the tint later, set TINT to the new one and update tint in nyctoui.json. To go from one tint to all, copy the tints section from the recorded version's tokens.stylex.ts back in and set allTints to true.

Theming and overrides

  • Light and dark follow color-scheme. The reset sets light dark on the root, so the system setting decides; set color-scheme: light or dark on any element to force a theme for that subtree.
  • With all tints kept, switch tint the same way: apply a tint's themes to an element, usually <html> or the app's root, and its subtree takes that tint. stylex.props(tintGreen, tintGreenHeatmap) (add tintGreenLanding only if the app uses the landing tokens). tintSwatches has one readable sample color per tint, for drawing a picker. With one tint, the tint is fixed by TINT.
  • Components take no className or style. To adjust one, pass StyleX styles to its sx prop; they are merged last.
  • Use the tokens (colors, sizes, radii, fontSizes and the rest, from tokens.stylex.ts) for any value, so new UI matches the components.