crelte / bodyClass / BodyClass
Class: BodyClass
Constructors
Constructor
new BodyClass(inner, store?): BodyClass;Parameters
inner
PlatformBodyClass
store?
StagedWritable<void>
Returns
BodyClass
Methods
add()
add(...classes): void;Adds the given classes to the body
Parameters
classes
...string[]
Returns
void
contains()
contains(cls): boolean;Checks if the body contains the given class
Parameters
cls
string
Returns
boolean
remove()
remove(...classes): void;Removes the given classes from the body
Parameters
classes
...string[]
Returns
void
setVariant()
setVariant(variant, cls): void;Sets the class for the given variant removing the old class for that variant, if cls is null it will remove the variant class
If you just have like a dark or light mode and only for the dark mode a class, prefer toggle('dark', isDarkMode) over setVariant('mode', isDarkMode ? 'dark' : null)
Note
The variant name is only used for the internal state management and has no inpact on the actual class name
Parameters
variant
string
cls
string | null
Returns
void
subscribe()
subscribe(fn, invalidate?): () => void;Parameters
fn
(val) => void
invalidate?
() => void
Returns
() => void
toggle()
toggle(cls, force?): void;Toggles the given class on the body
Warning
toggle without force should almost never be used on the server. If you call this for example in loadData the server will add the class and the client will the remove it.
Parameters
cls
string
force?
boolean
Returns
void