RibUI

Unstyled React components

The browser does it. You dress it.

React components on the native elements: a button stays a button, a switch is a checkbox. Rib UI adds the parts, the keyboard and the little JavaScript HTML lacks. Light and unstyled: the look is your classes.

get started

npm install rib-ui

3.7 kB of JavaScript and 1.5 kB of CSS, minified and gzipped, every component included

view on npm
import { Button } from "rib-ui";
import "rib-ui/button.css";

<Button className="btn" onClick={save}>
  <Button.Icon>
    <SaveIcon />
  </Button.Icon>
  <Button.Label>Save</Button.Label>
</Button>;

The idea

Where the browser can, the browser does.

Rib UI goes as far as the browser goes, and writes JavaScript only where it stops. It doesn't replace Radix, React Aria or Ariakit: it covers the components most interfaces are made of.

One shape. Every component is a root and its named parts: Button.Icon, Select.Control, Popover.Content. The root carries data-rib, each part a data- attribute of its own, so you style them all the same way.
The same props. render swaps the element and merges props, handlers and refs. clickable and disabled mean the same on a button, a checkbox and a select. State goes through the native pair: checked and onChange, open and onToggle.
Ready to use. Each component ships with a CSS file of behaviour, rib-ui/button.css, at zero specificity: any rule of yours wins. Buttons, fields, switches, sliders, popovers, dialogs cover most screens. This whole site is Tailwind classes on Rib UI parts.

Components

A button, on anything.

The native button by default, with type="button" so it never submits by accident. Give render a link and it stays a link; give it a div and Rib UI makes it a button: role, tab stop, Enter and Space. disabled is native, and emulated with aria-disabled where the element has none.

clicks: 0

docs
A cardA div that behaves as a button.

props

  • renderReactElementdefault button

    The element to render in place of the button: props, className, style, handlers and refs are merged. A link keeps its own keyboard; a div gets role="button", tabindex="0", Enter and Space.

  • clickablebooleandefault true

    false makes it non-interactive and takes it out of the tab order, without changing how it looks. For a loading button, a card in a skeleton.

  • disabledbooleandefault false

    Native on a button. On a link or a div, aria-disabled="true", tabindex="-1", click and keys blocked; a disabled link loses its href.

parts

  • Button.Iconspan

    aria-hidden, data-icon. Icon and label sit in the JSX order, with the button's gap between them.

  • Button.Labelspan

    data-label. Trimmed to the cap height and the baseline with text-box, so the text is optically centred in the padding.

<Button className="btn" onClick={save}>
  <Button.Icon>
    <MdSave />
  </Button.Icon>
  <Button.Label>save</Button.Label>
</Button>

<Button className="btn" render={<a href="/docs" />}>
  <Button.Label>docs</Button.Label>
</Button>

<Button className="card" render={<div />} onClick={open}>
  <h3>A card</h3>
  <p>A div that behaves as a button.</p>
</Button>

your turn

Dress it.

One design system today, the next one on the same bones.