css_class prop for Tailwind styling. A plain string works fine until you start mixing hover states, focus rings, and breakpoints — then the prefixes pile up:
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:
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:| Helper | Prefix | Use case |
|---|---|---|
Hover(...) | hover: | Mouse-over styles |
Focus(...) | focus: | Focus ring / outline |
FocusVisible(...) | focus-visible: | Keyboard-only focus |
FocusWithin(...) | focus-within: | Parent has a focused child |
Active(...) | active: | Mouse-down / tap |
Disabled(...) | disabled: | Disabled state styles |
Breakpoint Helpers
Same pattern, for responsive breakpoints:| Helper | Prefix | Min width |
|---|---|---|
Sm(...) | sm: | 640px |
Md(...) | md: | 768px |
Lg(...) | lg: | 1024px |
Xl(...) | xl: | 1280px |
Xxl(...) | 2xl: | 1536px |
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:Responsive Layout Props
Layout props likecolumns and gap accept a separate Responsive helper that translates values into the right Tailwind classes — see Responsive Columns for an example.