styles - Luakit

# Luakit Documentation / Modules / styles

# Module `styles`

User stylesheets

This module provides support for Mozilla-format user stylesheets, as a replacement for the old `domain_props`-based `user_stylesheet_uri` method (which is no longer supported). User stylesheets from https://userstyles.org are supported, giving access to a wide variety of already-made themes.

User stylesheets are automatically detected and loaded when luakit starts up. In addition, user stylesheets can be enabled/disabled instantly, without refreshing the web pages they affect, and it is possible to reload external changes to stylesheets into luakit, without restarting the browser.

## Adding user stylesheets

1. Ensure the `styles` module is enabled in your `rc.lua`.
2. Locate the `styles` sub-directory within luakit's data storage directory. Normally, this is located at `~/.local/share/luakit/styles/`. Create the directory if it does not already exist.
3. Move any CSS rules to a new file within that directory. In order for the `styles` module to load the stylesheet, the filename must end in `.css`.
4. Make sure you specify which sites your stylesheet should apply to. The way to do this is to use `@-moz-document` rules. The Stylish wiki page Applying styles to specific sites may be helpful.
5. Run `:styles-reload` to detect new stylesheet files and reload any changes to existing stylesheet files; it isn't necessary to restart luakit.

## Using the styles menu

To open the styles menu, run the command `:styles-list`. Here you can enable/disable stylesheets, open stylesheets in your text editor, and view which stylesheets are active.

If a stylesheet is disabled for all pages, its state will be listed as "Disabled". If a stylesheet is enabled for all pages, but does not apply to the current page, its state will be listed as "Enabled". If a stylesheet is enbaled for all pages and it applies to the current page, its state will be listed as "Active".

## Functions

### styles.load_file (path)

Load the contents of a file as a stylesheet for a given domain.

#### Parameters

- path
  Type: string
  The path of the file to load.

### styles.detect_files ()

Detect all files in the stylesheets directory and automatically load them.

### styles.watch_styles (guard, path)

Watch a stylesheet in the styles directory for changes and apply them immediately.

#### Parameters

- guard
  Type: table
  a table that controls the watch process. Set `guard[1] = nil` to turn off the watch.
- path
  Type: string
  the path of the watched style.

### styles.new_style (w)

Create and immediately edit a new style for the current uri.

#### Parameters

- w
  Type: table
  The window table for the window providing the uri.

### styles.toggle_sheet (title)

Toggle the enabled status of a style by filename.

#### Parameters

- title
  Type: string
  the style to toggle.

## Attribution

#### Copyright

- 2017 Aidan Holm