rl-react-components
v3.0.2
Published
React components and hooks with no app knowledge: form fields, layout, cards, Markdown, toasts and canvas effects.
Maintainers
Readme
rl-react-components
React 19 components and hooks built on one design system: layout, navigation, form fields, tags, cards, Markdown, toasts and canvas effects. Dark and light modes, TypeScript types, and no text of their own: every word a visitor reads comes in as a prop, in any language.
See every one working, in both modes, on the demo page.
Install
npm install rl-react-componentsReact and React DOM 19 are the only peer dependencies.
Usage
Import the stylesheet once, at the root of the app, then use the components anywhere below it:
import 'rl-react-components/styles.css';
import { Button, TextInput, ToastProvider, useToast } from 'rl-react-components';
function NewsletterForm() {
const { addToast } = useToast();
return (
<form
onSubmit={(event) => {
event.preventDefault();
addToast('You are subscribed.');
}}
>
<TextInput label="Email" type="email" required />
<Button type="submit">Subscribe</Button>
</form>
);
}
export default function App() {
return (
<ToastProvider dismissLabel="Dismiss notification">
<NewsletterForm />
</ToastProvider>
);
}The components need no CSS reset: each sets the box model, margins and fonts it relies on.
Fonts
The package ships no fonts. The design system suggests the three of the demo page: Inter for text
and controls, Space Grotesk for titles, JetBrains Mono for labels and code. To use them, load them
in the page's <head>:
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap"
/>Then set Inter on the page, since buttons, fields and tags take the page's font:
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
line-height: 1.6;
}Using the same fonts also shows how to host them with the app, use other fonts, and give the app's own text the same hierarchy.
Light mode
Dark is the default. Put data-theme="light" on <html> to switch the page, or on any element to
switch just that part:
document.documentElement.dataset.theme = 'light';Every colour is a CSS custom property (--color-accent, --color-bg and so on), so an app can
override any of them in its own CSS.
What is inside
| Group | Components and hooks |
| -------------- | ------------------------------------------------------------------------------------------------------------- |
| Foundations | Text, Icon |
| Layout | Container, Section, PageHero, PageTransition |
| Navigation | SideNav, Tabs |
| Forms | Button, IconButton, TextInput, TextArea, Select, Checkbox, Switch, SegmentedControl, Slider |
| Tags | Tag, TagFilter, TagGroup, LevelChip |
| Content | Card, Accordion, Markdown, MarkdownEditor, ShimmerImage |
| Feedback | ToastProvider, useToast |
| Canvas effects | MatrixContainer, OrbitalDots |
| Hooks | useDragReorder, useRotatingMessage |
Documentation
- Components: what each one does, with a link to its props and examples.
- Getting started: routers, server rendering and upgrading.
- The design system: the ideas behind the components, typography and icons.
- Theming: the colour tokens and how to override them.
- Accessibility: what the components handle, and what the app supplies.
Questions and bug reports: GitHub issues.
License
MIT
