Reablocks React Component Library
repository·master·Indexed 41 days ago
https://github.com/reaviz/reablocksA React-based UI component library featuring over 50 components styled with Tailwind CSS. Designed with a dark-first approach, Reablocks provides a comprehensive design system including semantic color tokens, a typography scale using Inter and Fira Code, and specific layout guidelines for rapid interface development. Version 10.3.1.
What's inside Reablocks
- reablocks is a collection of UI components for React built on top of Tailwind CSS. It provides a set of reusable blocks designed to accelerate UI development within the React ecosystem using Tailwind's utility-first styling approach.
Overview of Reablocks
masterReablocks is a collection of over 50+ UI components for React built on top of Tailwind CSS. It is designed to provide ready-to-use blocks for building modern user interfaces.Understand the reablocks color system and semantic tokens
masterreablocks uses a semantic token API for styling. Instead of using raw color values, you should use semantic tokens which adapt automatically between dark and light modes.
Core Semantic Tokens
primary: The brand accent (electric blue#105eff). Used for primary actions, selected states, and links. Hover state brightens toprimary-hoverin dark mode.secondary: Charcoal (#242433) for secondary button fills. In light mode, this resolves to a pale blue (#c3d7ff).panel: The base background (#02020fin dark).panel-accent: The hairline border color used for cards, inputs, and dialogs.surface: Raised interactive surfaces like toggle tracks and dividers.text-primary: Main text color (#f7f7fain dark).text-secondary: Muted text/labels (#77778cin dark).on-primary: The color for labels/icons sitting on top of primary/success/error/warning surfaces. Note: This is always near-white in both dark and light modes.
State Colors
success,error,warning,info: Used for state-specific feedback. Each has a-hovervariant and a dark-backgroundtint for callouts in dark mode.
Theme Mapping Reference
Token Dark (Default) Light primary#105eff#105effsecondary#242433#c3d7ffpanel#02020f#ffffffpanel-accent#242433#e6e6f0surface#242433#c9c9d6text-primary#f7f7fa#11111ftext-secondary#77778c#242433Understand the reablocks design system principles
masterreablocks is a Tailwind CSS-powered React component library designed with a dark-first approach.
Key design characteristics:
- Theme Strategy: The semantic tokens are defined by their default dark theme values.
- Light Mode Support: Light mode is achieved through
<token>-lightvariants (e.g.,primary-light). The underlying palette primitives remain unchanged. - Typography: Primarily driven by the Inter font family, with Fira Code used for monospace elements.
- Compactness: The system is designed to be compact and highly structured using semantic tokens.
Visual Design Specifications for Reablocks Components
masterReablocks components follow a strict design system based on semantic tokens and shared scales.
Buttons
- Variants: Filled, outline, and text.
- Filled Buttons: Use semantic tokens for fill (e.g.,
primary,success). Labels use{colors.on-primary}(white in both modes) except forbutton-secondarywhich uses{colors.text-primary}. - Outline Buttons: Transparent with a 1px border and variant-colored text.
- Text Buttons: Borderless with colored text that brightens on hover.
- Sizes:
small(12px label),medium(14px label, default),large(20px label). - Disabled: Filled buttons use
{colors.gray-600}with{colors.gray-400}text.
Inputs
- Appearance: Flex wrapper on
{colors.panel}with a 1px{colors.panel-accent}border and{rounded.xs}corners. - Focus/Hover: No focus ring; instead, a 1px radial-gradient underline is painted at the bottom edge.
- Error State: Border swaps to
{colors.error}. - Disabled: Text is pinned to waterloo
#77778cin both modes; background is a muted tint; underline is removed.
Selection Controls (Checkbox, Radio, Toggle)
- Checkbox: 1rem SVG box. Unchecked is transparent with
{colors.gray-400}stroke; checked is{colors.blue-500}with a white check. - Radio: 1rem circle with a 1px
{colors.surface}border. Selected state uses{colors.primary-active}border and a{colors.primary}dot. - Toggle: Pill track (3rem × 1.5rem medium) in
{colors.surface}. Turns{colors.primary}when 'on'.
Chips & Badges
- Chips: Compact pills with
{rounded.xs}corners. Default is{colors.panel}with primary text. Color variants fill with semantic tokens and flip text to{colors.panel}for contrast. - Badges: 18×18px fully-round dots used for counts/alerts.
Containers (Cards, Tooltips, Dialogs)
- Card:
{colors.panel}with a 1px{colors.panel-accent}border and{rounded.xs}corners. - Tooltip:
{colors.panel-accent}background,{rounded.sm}corners, and 0.375rem padding. - Dialog:
{colors.panel}sheet with{colors.panel-accent}border,{rounded.sm}corners, andshadow-2xl.
Best Practices for Reablocks Development
masterTo maintain visual consistency and ensure theme compatibility, follow these rules:
Do's
- Use Semantic Tokens: Always use
primary,panel,surface, andtext-primaryfor surfaces and text. These resolve correctly in both light and dark modes. - Use Shared Scales: Stick to the established scales for radius (
xs–4xl), typography (10–16px), and spacing (0.25rem grid). - Mode Switching: Keep dark mode as the default. Switch modes using
theme-light/theme-darkclasses ordata-themeattributes on the root element. - Accents: Reserve raw palette steps (e.g.,
teal-500,violet-400) for non-semantic accents like charts or category colors. - Customization: Use the theme system (
extendTheme,extendComponentTheme, or thethemeprop) instead of external CSS or!importantto ensure deep-merging works correctly.
Don'ts
- Hardcode Hex Values: Never use hex codes where a semantic token exists; this breaks light-mode support and theme overrides.
- Use Raw Grays for Surfaces: Avoid
gray-700orgray-950for surfaces/text; usesurfaceorpanelinstead. - Add Heavy Elevation: Do not use large corner radii or heavy drop shadows on buttons, cards, or inputs. Reablocks uses hairline borders and layered darkness for separation.
- Modify Typography: Do not introduce new font families or increase body text above 14px by default.
- Use Semantic Tokens: Always use
Run Reablocks locally with Storybook
masterTo run the Reablocks development environment locally and explore components in Storybook, follow these steps:
- Clone the repository.
- Install dependencies using
npm i. - Start the development server with
npm start.
This will automatically open your browser to the Storybook page where you can interact with the components.
npm i npm startApply layout, spacing, and shape guidelines
masterTo maintain the 'engineered' reablocks aesthetic, follow these layout and shape constraints:
Spacing and Density
- Use a 4px grid based on
spacing.unit(0.25rem). - Prefer tight, even rhythm over generous whitespace.
- Standard component padding:
- Medium buttons:
0.5rem x 1rem - Inputs:
0.375rem x 0.625rem - Cards:
1.75remall around
- Medium buttons:
Shapes and Radii
Avoid medium-rounded corners (8–12px) as they break the visual identity. Use the following:
rounded.xs(2px): For structural elements like buttons, cards, inputs, and chips.rounded.sm(4px): For tooltips and dialogs.rounded.full: For small controls like toggles, radios, and badges.
Elevation
Avoid heavy shadows. Hierarchy is achieved through layered darkness and hairline borders:
- Base:
colors.panel(#02020f) - Raised:
colors.surface(#242433) - Separation: 1px
colors.panel-accentborder. - Shadows: Use sparingly. Only dialogs should use the strongest shadow (
shadow-2xl).
- Use a 4px grid based on
Run visual regression tests
masterReablocks uses Playwright to perform visual regression testing by taking screenshots of every Storybook story to detect unintended visual changes.
Prerequisites: Storybook must be running on
localhost:9009. If it is not running, Playwright will attempt to start it automatically.Use the following commands to manage visual tests:
- To run tests against the existing baseline screenshots:
npm run test:visual - To update the baseline screenshots (use this after making intentional visual changes):
npm run test:visual:update
Note:
test:visual:extractruns automatically during these commands to fetch the story list from Storybook.# Run visual tests against existing baseline screenshots npm run test:visual # Update baseline screenshots (after intentional visual changes) npm run test:visual:update- To run tests against the existing baseline screenshots:
Activate the light theme in reablocks
masterBy default, reablocks uses a dark-first theme. To switch to the complete light theme, add the
theme-lightclass or thedata-theme="light"attribute to a root element in your application.All component styling is driven by a centralized theme system. To ensure correct rendering in both modes, always reference semantic tokens (e.g.,
primary,panel) rather than hardcoding hex values. The theme system automatically resolves semantic tokens to their-lightcounterparts when the light theme is active.<!-- Using class --> <div class="theme-light"> <!-- components here --> </div> <!-- Using data attribute --> <div data-theme="light"> <!-- components here --> </div>Get support for reablocks
masterIf you encounter issues or need assistance with
reablocks, you can use the following channels:- Community Support: Open a GitHub issue or submit a Pull Request (PR) to contribute fixes.
- Professional Support: For extra support or enterprise-level needs, the team at Good Code offers dedicated support plans and consultation.
Explore Reablocks Theme API entrypoints
masterThe
src/utils/Theme/index.tsfile serves as the central export point for the Reablocks theming system. It aggregates all necessary components, types, and utilities required to manage and apply themes across your application.To implement theming, you will primarily interact with the following modules:
ThemeProvider: The component used to inject theme context into your component tree.themes: Pre-defined theme objects or definitions.hooks: React hooks for consuming theme data (e.g., accessing current colors or spacing) within functional components.types: TypeScript definitions for theme structures and configuration.blocks: Theme-aware block configurations.helpers: Utility functions for theme manipulation and calculation.