Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/routes/reference/jsx-attributes/classlist.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ The value passed into `classList` can be any expression (including a signal gett

```tsx
// Dynamic class name and value
;<div classList={{ [className()]: classOn() }} />
<div classList={{ [className()]: classOn() }} />

// Signal class list
const [classes, setClasses] = createSignal({})
setClasses((c) => ({ ...c, active: true }))
;<div classList={classes()} />
<div classList={classes()} />
```

It's also possible, but dangerous, to mix class and classList. The main safe situation is when class is set to a static string (or nothing), and classList is reactive. (class could also be set to a static computed value as in `class={baseClass()}`, but then it should appear before any classList pseudo-attributes.) If both class and classList are reactive, you can get unexpected behavior: when the class value changes, Solid sets the entire class attribute, so will overwrite any toggles made by classList.
Expand Down
Loading