Skip to content

Commit db430b4

Browse files
authored
Document order-independent responsive classes for module CSS (#16)
1 parent d6a47c2 commit db430b4

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎README.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,21 @@ A module that turns invoices into other documents, such as an EN 16931 e-invoice
253253

254254
These are Module API **1.5.0** additions; declare `"module_api": "^1.5.0"` to use them.
255255

256+
### Responsive classes
257+
258+
Your stylesheet is a Tailwind build of its own, loaded next to the host's, and the two share class names: both may define `.hidden` or `.w-full`. Between rules of equal weight the later sheet wins, so the host adds its stylesheet again after the module sheets, and a module can never break the app's layout. The cost lands on your markup: the host's plain utilities win over your breakpoint variants. `hidden sm:flex` stays hidden on desktop unless the host's own build happens to contain `sm:flex` too, and that changes from release to release.
259+
260+
Never pair a plain utility with a breakpoint variant for the same property. Split the property into ranges that don't overlap, so only one class matches at any width:
261+
262+
| Instead of | Write |
263+
| --- | --- |
264+
| `hidden sm:flex` | `max-sm:hidden sm:flex` |
265+
| `w-full sm:w-[480px] lg:w-[640px]` | `max-sm:w-full sm:max-lg:w-[480px] lg:w-[640px]` |
266+
| `grid-cols-1 sm:grid-cols-2 lg:grid-cols-4` | `max-sm:grid-cols-1 sm:max-lg:grid-cols-2 lg:grid-cols-4` |
267+
| `flex-col sm:flex-row` | `max-sm:flex-col` (row is the default) |
268+
269+
The same applies to a class you put on a host component. Its root carries the host's own classes, so `<BaseInputGroup class="sm:w-48">` loses to the `w-full` it already has; give the width to a wrapper element of your own.
270+
256271
### Thin clients
257272

258273
The InvoiceShelf mobile clients run the same frontend as the web app, but as a static app package

0 commit comments

Comments
 (0)