@ryanhelsing/ry-ui
v1.0.1
Published
Framework-agnostic, Light DOM web components. CSS is the source of truth.
Maintainers
Readme
ry-ui
Framework-agnostic, Light DOM web components. CSS is the source of truth.
North Star
There are only so many types of things we do in any app. There should be one opinionated default way to do each of them. Invent all the wheels once, then never again.
Every app is a composition of the same finite primitives: layout, navigation, data display, data entry, feedback, actions, auth, state. The patterns are solved. The industry just keeps re-solving them because engineers enjoy the puzzle.
ry-ui normalizes this. No decisions to make. No architecture to debate. An LLM can leverage these primitives to build any app, anywhere, with a structure that is grokkable, dumb, and repeatable. Over-engineering becomes irrelevant when there's nothing left to over-engineer.
The goal: Write once in HTML/CSS/JS. Deploy to web, iOS, Android, desktop. The primitives are portable because they're universal.
[x] separate the css minimal structure from the theme
[x] separate the component behavior from the design (see
docs/arch/behavior-style-separation.md)[ ] Slider, Knob, Menu, Placeholder, Step/Wizard, Loader/Progress, Breadcrumb, Comment/Feed, Statistic/Graph, Hero, Calendar, Rating , Search, Shape, Sticky, color-picker, dialog/alert, tree, carousel, qr-code, diff, split-panel, format-bytes-number-currency(rails things), mutation-observer and resize observer,
[ ] bring in examples and extract and normalize - Flat Clean (accord/tailwind) / Flat Fun Waves (zevo) / Game (mario/astrobot/stardew/animal crossing) / Brute (square game) / Skeuomorphic / Glass ( dark and light, color sets 1,2,3 )
[ ] cross-platform transpiler - Swift/SwiftUI (see
docs/arch/cross-platform-transpiler.md)[ ] animation system with GSAP (see
docs/plans/animation-system.md)[ ] could use to write apps on ry-os lol.. rust based linux DE with html/js/css -> Dioxus -> rust apps / with an llm on device
Quick Start
<link rel="stylesheet" href="https://cdn.example.com/ry-ui.css">
<script type="module" src="https://cdn.example.com/ry-ui.js"></script>Components
Layout (CSS-only)
<ry-page>- Page container<ry-header>/<ry-footer>- Page sections<ry-main>/<ry-section>- Content areas<ry-grid cols="3">- Responsive grid<ry-stack>/<ry-cluster>- Flex layouts
Interactive
<ry-button>- Buttons with variants<ry-modal>- Modal dialogs<ry-drawer>- Slide-out panels<ry-accordion>- Collapsible sections<ry-tabs>- Tabbed content<ry-dropdown>- Dropdown menus<ry-select>- Custom select<ry-switch>- Toggle switch<ry-tooltip>- Hover tooltips<ry-toast>- Notifications
Display
<ry-card>- Card containers<ry-badge>- Status badges<ry-alert>- Alert messages
Clean Syntax
Use <ry> wrapper to write unprefixed markup:
<ry>
<accordion>
<accordion-item title="FAQ" open>
No ry- prefix needed inside the wrapper.
</accordion-item>
</accordion>
</ry>Examples
<!-- Modal -->
<ry-button modal="demo">Open Modal</ry-button>
<ry-modal id="demo" title="Hello">Content here</ry-modal>
<!-- Drawer -->
<ry-button drawer="menu">Open</ry-button>
<ry-drawer id="menu" side="left">Menu content</ry-drawer>
<!-- Select -->
<ry-select placeholder="Country" name="country">
<ry-option value="us">United States</ry-option>
<ry-option value="uk">United Kingdom</ry-option>
</ry-select>
<!-- Toast (programmatic) -->
<script>
RyToast.success('Saved!');
RyToast.error('Failed');
</script>Themes
<html data-ry-theme="dark">Available: light, dark, ocean
CSS Architecture
ry-ui separates structure (layout/behavior) from theme (visual styling):
ry-tokens.css # Design tokens (CSS variables)
ry-structure.css # Pure layout - no colors, shadows, or borders
ry-theme.css # All visual styling
ry-ui.css # Bundled (all three combined)Custom Themes
For completely custom styling, load only structure + your own theme:
<!-- Use default look -->
<link rel="stylesheet" href="ry-ui.css">
<!-- OR: Custom theme -->
<link rel="stylesheet" href="ry-structure.css">
<link rel="stylesheet" href="your-tokens.css">
<link rel="stylesheet" href="your-theme.css">Structure CSS contains only:
- Display modes, positioning, flexbox, grid
- Sizing, padding, margins, gaps
- State transitions (opacity, visibility, transform)
Theme CSS contains:
- Colors, backgrounds, borders
- Shadows, border-radius
- Typography styling
- Focus rings
Development
npm install
npm run dev # Dev server with HMR
npm run build # Production build
npm run typecheckTypeScript Philosophy
ry-ui is written in strict TypeScript with a "vanilla-first" approach:
No Decorators, No Magic
We use plain class syntax with private fields (#field) instead of decorators. The code reads like standard JavaScript with type annotations.
// What we do
class RySelect extends RyElement {
#highlightedIndex = -1;
#typeahead = '';
setup(): void { ... }
}
// What we avoid
@customElement('ry-select')
class RySelect extends LitElement {
@property() value = '';
@state() private _open = false;
}Strict Mode, No Exceptions
{
"strict": true,
"noUncheckedIndexedAccess": true,
"noImplicitReturns": true
}Type Patterns
Explicit over inferred for public APIs:
get value(): string { return this.getAttribute('value') ?? ''; }
emit<T = void>(name: string, detail?: T): boolean { ... }Union types for constrained values:
type ToastVariant = 'info' | 'success' | 'warning' | 'error';
static observedAttributes = ['value', 'disabled'] as const;Extend globals for custom events:
declare global {
interface HTMLElementEventMap {
'ry:change': CustomEvent<{ value: string }>;
}
}Build Output
Single bundled ESM file for CDN simplicity:
dist/
├── ry-ui.js # 32KB (7KB gzip)
├── ry-ui.js.map # Source maps
└── ry-ui.d.ts # Type declarationsVite builds with esbuild for speed, Rollup for optimization, and generates .d.ts for library consumers.
See CLAUDE.md for component development guide.
