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-ui3.7 kB of JavaScript and 1.5 kB of CSS, minified and gzipped, every component included
view on npmimport { 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.
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.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.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.
props
renderReactElementdefault buttonThe element to render in place of the
button: props,className,style, handlers and refs are merged. A link keeps its own keyboard; adivgetsrole="button",tabindex="0", Enter and Space.clickablebooleandefault truefalsemakes 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 falseNative on a
button. On a link or adiv,aria-disabled="true",tabindex="-1", click and keys blocked; a disabled link loses itshref.
parts
Button.Iconspanaria-hidden,data-icon. Icon and label sit in the JSX order, with the button'sgapbetween them.Button.Labelspandata-label. Trimmed to the cap height and the baseline withtext-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.