import { KbqSidebarModule } from '@koobiq/components/sidebar';

KbqSidebar

componentCopy link to KbqSidebar
@Component({ selector: 'kbq-sidebar', exportAs: 'kbqSidebar' })
class KbqSidebar {
    opened = input<boolean | undefined>();
    readonly position = input<SidebarPositions>();
    readonly stateChanged = output<boolean>();
    get hasSavedState(): boolean;
    saveState(): void;
    clearSavedState(): void;
    toggle(): void;
}
useStateSavinginputCopy link to useStateSavingboolean

Whether the component remembers its state across reloads and restores it on the next render. Defaults to true, or to whatever KBQ_STATE_SAVING_ENABLED is provided as.

stateSavingKeyinputCopy link to stateSavingKeystring

The key the state is persisted under. While it is empty the key is derived from where the component sits in the document, which moves when the surrounding markup is restructured — an id on the component or any ancestor pins it just as well as this input does.

hasSavedStateCopy link to hasSavedStateboolean

Whether state is currently persisted for this sidebar — restored on init, or written since. Always false while useStateSaving is unset, and false again after clearSavedState().

saveState()Copy link to saveState()void

Persists whether the sidebar is open and the width it was last left at.

Called whenever opened changes. The width is only captured as the sidebar closes, so dragging it wider and reloading without closing it keeps the previous width — the same as before persistence.

clearSavedState()Copy link to clearSavedState()void

Removes the state persisted for this sidebar.

Persistence itself stays on — the next change is written again. Unset useStateSaving to stop it.

KbqSidebarClosed

directiveCopy link to KbqSidebarClosed
@Directive({ selector: '[kbq-sidebar-closed]', exportAs: 'kbqSidebarClosed' })
class KbqSidebarClosed {
    readonly width = input<string>();
}

KbqSidebarOpened

directiveCopy link to KbqSidebarOpened
@Directive({ selector: '[kbq-sidebar-opened]', exportAs: 'kbqSidebarOpened' })
class KbqSidebarOpened {
    readonly minWidth = input<string>();
    readonly width = input<string>();
    readonly maxWidth = input<string>();
}

KbqSidebarState

interfaceCopy link to KbqSidebarState

The persisted state of a sidebar — whether it was open, and the width it was last left at.

interface KbqSidebarState {
    opened: boolean;
    width?: string;
}
widthoptionalCopy link to widthstring

Absent while the sidebar has never been resized away from the width its content declares.

SidebarPositions

enumCopy link to SidebarPositions
enum SidebarPositions {
    Left = 'left',
    Right = 'right'
}
Suggestions for improvement
If you found a mistake or want to improve the article, create an issue on GitHub.