Foundations
Customization
Five levels, from global to local. Use the highest one that does the job.
The five levels
- Theme tokens —
createTheme()for brand colours, radii and fonts. - Component tokens —
--pl-button-radius,--pl-input-radius,--pl-card-radius,--pl-dialog-width. - Props —
variant,size,radius. - Class names —
classNameand per-slotclassNames. - State attributes —
[data-variant],[data-size],[data-invalid],[data-loading],[data-state].
Tokens, slots and class names
import { Button, HStack, Input, Stack } from '@reactloom/ui';
import type { CSSProperties } from 'react';
const pill = { '--pl-button-radius': '999px' } as CSSProperties;
export default function Example() {
return (
<Stack gap="4" style={{ width: '100%', maxWidth: 380 }}>
<style>{`.soft-field { background: var(--pl-color-bg-subtle); border-color: transparent; box-shadow: none; }`}</style>
{/* Slot class name */}
<Input label="Search accounts" classNames={{ control: 'soft-field' }} placeholder="Acme" />
<HStack>
{/* Component token */}
<Button style={pill}>Pill button</Button>
{/* Plain className */}
<Button variant="secondary" className="uppercase-cta" style={{ textTransform: 'uppercase', letterSpacing: '0.06em' }}>
Custom
</Button>
</HStack>
</Stack>
);
}What each component exposes
Every component page ends with a Customization section listing its slot class names, CSS variables, the data-* state attributes you can target, and the theme tokens it reads. It is extracted from the source on every build (and checked in CI), so it always matches the code — for example, Button exposes --pl-button-radius and [data-variant].
Why your CSS always wins
All library CSS lives in @layer pl.theme and @layer pl.components. Any un-layered CSS — your stylesheets, CSS Modules, Tailwind utilities — beats layered CSS regardless of specificity. No !important.
The flip side: global element rules also win. Put them in a lower layer:
/* index.html: <style>@layer reset, base, pl;</style> */
@layer base {
a { color: var(--pl-color-fg-link); }
}
.my-overrides { /* un-layered: still wins over ReactLoom */ }Tailwind CSS
Tailwind is optional. Its utilities override ReactLoom automatically, and you can map its theme to ReactLoom tokens:
@theme {
--color-accent: var(--pl-color-accent-solid);
--radius-md: var(--pl-radius-md);
}