# Style Manager

Source: https://developers.inkdrop.app/modules/style-manager

Available as `env.styles` on the [Environment](https://developers.inkdrop.app/modules/environment) passed to `activate(env)`, which you can use to globally query and observe the set of active style sheets.
The `StyleManager` doesn't add any style elements to the DOM on its own, but is instead subscribed to by individual `<inkdrop-styles>` elements, which clone and attach style elements in different contexts.

---

## Style Elements Observation `observeStyleElements(callback)`

Invoke the provided callback for all current and future style elements.

### Parameters

- **callback(styleElement)** (function, required)

  An `HTMLStyleElement` instance. The `.sheet` property will be null because this element isn't attached to the DOM. If you want to attach this element to the DOM, be sure to clone it first by calling `.cloneNode(true)` on it. The style element will also have the following non-standard properties:
  - **sourcePath** (string)

    A String containing the path from which the style element was loaded.
  - **context** (string)

    A String indicating the target context of the style element.

### Returns

Returns a [Disposable](https://developers.inkdrop.app/event-subscription/disposable) on which `.dispose()` can be called to unsubscribe.

---

## Style Element Addition Subscription `onDidAddStyleElement(callback)`

Invoke the provided callback when a style element is added.

### Parameters

- **callback(styleElement)** (function, required)

  Function called with each added `HTMLStyleElement` instance.

### Returns

Returns a [Disposable](https://developers.inkdrop.app/event-subscription/disposable) on which `.dispose()` can be called to unsubscribe.

---

## Style Element Removal Subscription `onDidRemoveStyleElement(callback)`

Invoke the provided callback when a style element is removed.

### Parameters

- **callback(styleElement)** (function, required)

  Function called with each removed `HTMLStyleElement` instance.

### Returns

Returns a [Disposable](https://developers.inkdrop.app/event-subscription/disposable) on which `.dispose()` can be called to unsubscribe.

---

## Style Element Update Subscription `onDidUpdateStyleElement(callback)`

Invoke the provided callback when an existing style element is updated.

### Parameters

- **callback(styleElement)** (function, required)

  Function called with each updated `HTMLStyleElement` instance.

### Returns

Returns a [Disposable](https://developers.inkdrop.app/event-subscription/disposable) on which `.dispose()` can be called to unsubscribe.

---

## Get Style Elements `getStyleElements()`

Retrieve all loaded style elements.

### Returns

Returns an array of `HTMLStyleElement` instances.

---

## Get User StyleSheet Path `getUserStyleSheetPath()`

Obtain the path of the user style sheet.

### Returns

Returns the path of the user style sheet located in [the config path](https://docs.inkdrop.app/reference/user-data-directory).
