Common mistakes
Common mistakes in the Styling guide.
- Mixing dynamic
classwithclass:orclassList. Theclassrewrite removes the toggled names. Put every conditional name in the oneclassobject. - Calling an accessor wrong in a derived class.
class={{ on: !flag }}withflaga signal is always the opposite of what you want; writeflag(). - A number where another unit is meant.
width: 10is10px, as in React. Write a string forrem,%orvh, such aswidth: "50%". - Composing Tailwind class names. See Tailwind CSS 4.
- Expecting
stylestrings to merge. A string replaces all inline styles on that element. Use an object, orstyle:name, when several bindings share an element. - Reading styles from the DOM in an effect before it is attached. Refs run when the element is
created, before it is inserted; read layout in
onMount.