Skip to content

@bynary.composables.class.Function.useClass

github-actions[bot] edited this page Jul 11, 2024 · 3 revisions

@bynary/composables / @bynary/composables/class / useClass

Function: useClass()

useClass(className, options?): WritableSignal<boolean>

Adds the given class to the host element if set to true.

Parameters

className: string

The name of the class to toggle

options?: IUseClassOptions

A set of options

Returns

WritableSignal<boolean>

Example

import { useClass } from '@bynary/composables/class';

@Component({
    selector: 'my-component'
})
class MyComponent {

    isLoading = useClass('loading');
}
<my-component></my-component>

This will output:

<my-component class="loading"></my-component>

Defined in

class/src/class.composable.ts:65

Clone this wiki locally