-
-
Notifications
You must be signed in to change notification settings - Fork 106
/
active.d.ts
23 lines (20 loc) · 914 Bytes
/
active.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/** Options for the `active` action */
interface ActiveOptions {
/** Path to match; if empty, will default to the link's target */
path?: string | RegExp
/** Name of the CSS class to add when the route is active; default is "active" */
className?: string
/** Name of the CSS class to add when the route is inactive; nothing added by default */
inactiveClassName?: string
}
/**
* Svelte Action for automatically adding the "active" class to elements (links, or any other DOM element) when the current location matches a certain path.
*
* @param node - The target node (automatically set by Svelte)
* @param opts - Can be an object of type `ActiveOptions`, or a string (or regular expressions) representing `ActiveOptions.path`.
* @returns Destroy function
*/
export default function active(
node: HTMLElement,
opt?: ActiveOptions | string | RegExp
): {destroy: () => void}