Skip to main content
Every Prefab component accepts a css_class prop for Tailwind styling and an id prop for targeting with custom CSS selectors.

Component IDs

The id prop sets the HTML id attribute on a component’s outermost element. This is useful when you need to target a specific component with custom CSS or anchor links:
For components that render multiple DOM elements, id is always applied to the outermost wrapper.

Tailwind Classes

A plain css_class string works fine until you start mixing hover states, focus rings, and breakpoints — then the prefixes pile up:
The prefab_ui.css module provides helpers that eliminate the repetition.

Composing with Lists

css_class accepts a list of strings, joined with spaces at build time. This lets you group related concerns and mix in helpers without worrying about spacing:
Each helper returns a plain string — FocusVisible("border-b border-border") produces "focus-visible:border-b focus-visible:border-border". The list stitches everything together.

Variant Helpers

Each helper takes a string of space-separated classes and prefixes every one with its variant:

Breakpoint Helpers

Same pattern, for responsive breakpoints:
These match Tailwind’s default breakpoints — each applies from that width and up.

Putting It Together

Variants and breakpoints compose freely. Here’s a card that adjusts padding at breakpoints, lifts on hover, and shows a focus ring for keyboard navigation:
Each line reads as a single concern — base styles, medium breakpoint, large breakpoint, hover, focus. No prefix repetition, and the list makes it easy to add or remove a line without touching the others.

Responsive Layout Props

Layout props like columns and gap accept a separate Responsive helper that translates values into the right Tailwind classes — see Responsive Columns for an example.