v3.2 — now with dark mode tokens

Build better UIs with MyUI

MyUI is an open-source component library of accessible, themeable building blocks for React. Copy, paste, ship — no lock-in, no bloat.

Getting Started

Everything you need to go from an empty folder to a fully themed MyUI app in under five minutes.

Introduction

MyUI is a collection of 40+ accessible React components built on a design-token core. Every component ships unstyled where it matters and styled where it helps — so your brand stays in control while you skip the boring parts.

Components are tree-shakeable, keyboard-friendly by default, and tested against WCAG 2.2 AA contrast ratios.

Installation

Install the core package with your favorite package manager:

$ npm install myui

Prefer another registry? yarn add myui or pnpm add myui work exactly the same.

Setup

Wrap your app in the MyUIProvider once, and every component inherits your tokens automatically.

main.jsx
import { MyUIProvider } from 'myui';

createRoot(document.getElementById('root')).render(
  <MyUIProvider theme="brand">
    <App />
  </MyUIProvider>
);

Theming

Tokens live in a single theme.js file. Override accent colors, radii, and typography — every component picks them up instantly, including dark mode.

theme.js
export const brand = {
  accent: '#7c3aed',
  radius: 12,
  font: 'Inter, sans-serif',
};

Your First Component

Import a component and drop it anywhere in your tree. It just works — focus rings, ARIA attributes and all.

App.jsx
import { Button } from 'myui';

export default function App() {
  return <Button variant="primary">Hello, MyUI!</Button>;
}

Button

Buttons trigger actions. MyUI ships five variants, three sizes, and full keyboard support out of the box.

Overview

The Button component renders a native <button> element with consistent sizing, focus management, and loading states. It supports icons, full-width layouts, and disables automatically while an async action is pending.

API Reference

All props are optional. Unknown props are forwarded to the underlying element.

PropTypeDefaultDescription
variant"primary" | "outline" | "ghost" | "destructive""primary"Visual style of the button.
size"sm" | "md" | "lg""md"Controls padding and font size.
loadingbooleanfalseShows a spinner and disables interaction.
disabledbooleanfalsePrevents all interaction.
onClick(event) => voidFired on click and Enter/Space.

Default

variant="primary"
<Button variant="primary">
  Primary
</Button>
Edit in Playground

Outline

variant="outline"
<Button variant="outline">
  Outline
</Button>
Edit in Playground

Ghost

variant="ghost"
<Button variant="ghost">
  Ghost
</Button>
Edit in Playground

Loading

loading
<Button loading>
  Saving…
</Button>
Edit in Playground

No components match your search.

Accessibility

Every Button meets WCAG 2.2 AA. No extra work needed on your side.

  • Renders a native <button> — no ARIA role hacking, works with every screen reader.
  • Visible focus ring on all variants, including :focus-visible with a 3:1 contrast outline.
  • Hit target is at least 24×24 px even at the sm size, per WCAG 2.5.8.
  • Loading state sets aria-busy="true" and keeps the accessible name intact.

Interactive Playground

Code
1
Preview
Copied to clipboard