Sofqi1k downloadsFine-tune theme, plugin, and snippet CSS variables with configurable controls.
像调音台一样,精细调校你的 Obsidian 外观。
中文为主文档语言,关键章节附英文对照;
/* @settings参考文档见文末(英文)。 Chinese is the primary language, with English alongside in key sections; the/* @settingsreference is at the bottom of this document.
📜 完整更新记录见 CHANGELOG · Full changelog: CHANGELOG
中文:主题变量调校 · CSS 片段可视化配置 · 独立标签页视图 · 外观面板(颜色模式 / 主题切换)· CSS 片段启停管理 · 打开片段文件夹 · 颜色选择器(亮/暗双模式)· 数值滑块 · 下拉选择 · 类开关 · 标题层级折叠 · 搜索过滤 · 按变量名搜索 · 变量名一键复制 · @settings 生态兼容 · 界面美化 · 已修改值高亮 · 两栏导出弹窗 · 按区块导出 / 导入 · 24 种界面语言 · Markdown 美化与 Lint(Obsidian Linter 引擎集成) · 列表设置项拖拽排序 · YAML 键属性类型(文本 / 列表 / 数字 / 复选框 / 日期 / 日期时间) · YAML 键顺序一键继承 · 与 obsidian-linter 插件共存
English: theme variable fine-tuning · visual CSS snippet configuration · standalone tabbed view · appearance panel (color mode / theme switching) · CSS snippet enable-disable management · open snippets folder · dual-mode color pickers (light/dark) · number sliders · dropdown selects · class toggles · collapsible heading groups · search filter · search by variable name · one-click variable-name copy · @settings ecosystem compatibility · beautified UI · modified-value highlighting · two-column export dialog · per-section export/import · 24 UI languages · markdown linting & formatting (Obsidian Linter engine, ported) · drag-to-reorder list settings · YAML property types (text / list / number / checkbox / date / datetime) · one-click inherit of a YAML key order · coexists with the obsidian-linter plugin
中文:Style Tuner 是一款 Obsidian 插件,让主题、CSS 片段与插件 CSS 声明一组可配置项,并把这些可调设置集中在同一个设置面板里:支持在 body 上开关类名,以及设置数值、文本、颜色等 CSS 变量——无需手动改 CSS,主题调校所见即所得。除了样式变量,面板还接管了 Obsidian 原生外观设置中的三件事:颜色模式(跟随系统 / 亮色 / 深色)、主题切换,以及 CSS 片段的启停管理——既可以作为插件设置页打开,也可以作为独立标签页打开,边调边看。它是 Style Settings(作者 mgmeyers)的独立维护分支,遵循 GPL-3.0 协议,解析与原版完全相同的 /* @settings 配置块,现有主题与片段无需任何修改即可使用。自 1.2.0 起,它还内置了 Obsidian Linter(作者 platers / Victor Tao,MIT 协议)的 Markdown 美化与格式化引擎,其全部设置项集成在面板标签组(格式化 / YAML规范 / 内容规范 / 空行规范 / 自定义规范)中,并附一组命令使用。内置 Linter 占用的全局命名空间已全部收窄到本插件前缀下(视图类型、CSS 类、图标 id),因此可以与 obsidian-linter 插件同时启用,不再互相顶掉。YAML 相关设置也做了增强:「插入 YAML 属性」的键可以指定属性类型(并登记进 Obsidian 的属性面板),「YAML 键排序」能一键继承它的键顺序,所有列表设置项都支持拖拽排序。它是独立插件,不要与 Style Settings 同时启用。
English: Style Tuner is an Obsidian plugin that lets themes, CSS snippets, and plugin CSS declare a set of configurable options, and collects them into a single settings panel: toggle classes on body, and set numeric, text, or color CSS variables — no hand-editing CSS, WYSIWYG theme tuning. Beyond style variables, the panel also takes over three native Obsidian appearance settings: color mode (system / light / dark), theme switching, and CSS snippet management — usable either as a plugin settings tab or as a standalone view, so you can tune and preview side by side. It is an independently maintained fork of Style Settings by mgmeyers, licensed under GPL-3.0. It parses the exact same /* @settings blocks, so existing themes and snippets work unchanged. Since 1.2.0, it also bundles the markdown styling & formatting engine of Obsidian Linter by platers / Victor Tao (MIT licensed), with all of its settings integrated into the panel tabs (Format / YAML Rules / Content Rules / Blank-line Rules / Custom Rules) plus a set of commands. Every global namespace the bundled linter used to occupy (view types, CSS classes, icon ids) is now namespaced under this plugin, so it can be enabled alongside the obsidian-linter plugin without the two knocking each other out. The YAML settings got extra work too: keys added by "Insert YAML attributes" can carry a property type (registered with Obsidian's property panel), "YAML key sort" can inherit that key order in one click, and every list setting supports drag-to-reorder. It is a separate plugin — do not enable it together with Style Settings.
中文:
/* @settings 配置块:标题层级、类开关、类下拉、文本/数值/滑块/下拉变量、单色与亮暗双色取色器、信息文本、颜色渐变,以及按语言后缀的多语言标题(title.zh、title.de 等)。parse-style-settings 事件与 style-settings-* 类名沿用原版,主题与插件无需改动。snippets 目录中的全部片段并显示数量,逐项开关启停、可手动刷新列表,并能在系统文件管理器中直接打开片段文件夹(刷新与打开文件夹是列表标题行的图标按钮,悬停有提示;目录不存在时自动创建;桌面端专属的打开文件夹,移动端隐藏)。--变量名 chip,单击即复制到剪贴板(成功/失败均有通知);变量名直接取设置项 id,不依赖本地化标题文本。--ribbon-padding 或 ribbon-padding 都能搜到,类开关可输入类名(如 wide-tables);命中后计数与自动展开行为与按标题搜索一致。装过 Settings Search 插件的话,它的全局设置搜索里也能按变量名命中。<configDir>/types.json 让属性面板直接按该类型显示(aliases / tags / cssclasses 的类型被 Obsidian 写死,界面里锁定为「列表」并跳过登记);「YAML 键排序」的优先级顺序可用「继承『要插入的键』」按钮一键并入,之后照常增删调序。YAML 标签页里「插入 YAML 属性 / YAML 键排序 / YAML 标题」三条固定排在最前。Attempting to register an existing view type)。现在全部收窄到 style-tuner- 前缀下,两个插件可以同时启用。<style> 元素,也不直接给元素写内联样式:动态样式一律走 Obsidian 的 setCssProps(CSS 变量写在 body 的内联自定义属性上,取色器的 --pcr-color 同理),无法用类名表达的少数场景才由 CSS 类兜底。每次发版都用官方 [email protected] 的 recommended 配置对 src/**(含移植的 Linter 代码)重跑一遍复查:error 级规则全部通过,其中审核要点「Sets styles directly instead of using CSS classes, setCssProps, or setCssStyles」(obsidianmd/no-static-styles-assignment)零命中。English:
/* @settings blocks: heading levels, class toggles and selects, text/number/slider/select variables, single and light/dark themed color pickers, info text, color gradients, and language-suffixed titles (title.zh, title.de, …). The parse-style-settings event and style-settings-* class names are kept from the original, so themes and plugins need no changes.snippets folder with a live count, toggles each one on/off, refreshes the list on demand, and opens the snippets folder in your system file manager (refresh and open-folder are icon buttons in the list header with tooltips; the folder is created automatically if missing; opening it is desktop only, hidden on mobile).--var chip next to its title; a single click copies the variable name to the clipboard (with success/failure notices). The name is taken from the setting id, independent of the localized title.--ribbon-padding or ribbon-padding finds the variable setting, and class toggles can be found by their class name (e.g. wide-tables); result counts and auto-expansion behave exactly as with title search. With the Settings Search plugin installed, its global settings search finds variables by name too.<configDir>/types.json so Obsidian's property panel shows it as that type straight away (aliases / tags / cssclasses have their types hard-coded by Obsidian, so they are locked to "list" and skipped when writing). The priority order of "YAML key sort" can be filled in with one click from that key list and then edited freely. In the YAML tab, "Insert YAML attributes", "YAML key sort" and "YAML title" are pinned to the top.Attempting to register an existing view type). All of them are now namespaced under style-tuner-, and the two plugins can run side by side.<style> elements and no inline styles written onto elements: dynamic styles always go through Obsidian's setCssProps (CSS variables land on body's inline custom properties, same for the picker's --pcr-color), with CSS classes covering the few cases a class name expresses better. Every release re-runs the official [email protected] recommended rule set over src/** (including the ported linter sources): every error-level rule passes, and the review item "Sets styles directly instead of using CSS classes, setCssProps, or setCssStyles" (obsidianmd/no-static-styles-assignment) reports zero hits.BRAT: Add a beta plugin for testing。Dyse-Sofqi/obsidian-style-tuner 并确认。English: Install and enable BRAT, run the command BRAT: Add a beta plugin for testing, then enter Dyse-Sofqi/obsidian-style-tuner.
main.js、manifest.json、styles.css。<vault>/.obsidian/plugins/style-tuner/ 目录下放入这三个文件。English: Download main.js, manifest.json and styles.css from the latest release, put the three files into <vault>/.obsidian/plugins/style-tuner/, then enable Style Tuner under Settings → Community plugins.
[!CAUTION] 不要同时启用 Style Tuner 与 Style Settings:两者都会渲染
/* @settings配置面板,同一变量被写入两次可能产生冲突。 Do not enable Style Tuner and Style Settings at the same time: both render/* @settingspanels, and the same variable may be written twice with conflicting results.
中文:自 1.2.0 起,Style Tuner 内置了 Obsidian Linter(MIT 协议,Copyright (c) 2021-2022 Victor Tao,完整许可文本见 src/linter/LICENSE)的 Markdown 美化引擎,其设置集成在面板标签组中(格式化 / YAML规范 / 内容规范 / 空行规范 / 自定义规范),并附一组命令运行:
<configDir>/types.json(aliases / tags / cssclasses 的类型由 Obsidian 写死,界面里锁定为「列表」);「YAML 键排序」的优先级顺序可一键继承这份键清单。YAML 标签页里「插入 YAML 属性 / YAML 键排序 / YAML 标题」固定排在最前;style-tuner- 前缀,两个插件可以同时启用;data-linter.json,与样式设置(data.json)互不影响。English: Since 1.2.0, Style Tuner bundles the markdown styling engine of Obsidian Linter (MIT licensed, Copyright (c) 2021-2022 Victor Tao; full license text in src/linter/LICENSE). Its settings live in the panel tabs (Format / YAML Rules / Content Rules / Blank-line Rules / Custom Rules) and it ships with a set of commands:
<configDir>/types.json (aliases / tags / cssclasses have their types hard-coded by Obsidian, so they are locked to "list"). The priority order of "YAML key sort" can be inherited from that key list in one click, and "Insert YAML attributes" / "YAML key sort" / "YAML title" are pinned to the top of the YAML tab;style-tuner-, so both plugins can run at the same time;data-linter.json and never mix with the style settings in data.json.你的全部调校值保存在 <vault>/.obsidian/plugins/style-tuner/data.json,只存储与默认值不同的覆盖项。卸载插件会删除该文件(主题与片段文件本身不受影响)——卸载前请用设置面板的导出功能备份,或直接复制 data.json。Linter(1.2.0 起内置)的设置保存在同目录的 data-linter.json,卸载时同样会被删除。
English: All of your tweaks are stored in <vault>/.obsidian/plugins/style-tuner/data.json, and only values differing from the defaults are written. Uninstalling the plugin deletes that file (your theme and snippet files are not affected) — export a backup from the panel, or copy data.json, before removing the plugin. Linter settings (bundled since 1.2.0) live in data-linter.json in the same directory and are deleted as well.
/* @settings 参考文档(英文)在 vault 的 snippets 目录(%yourVault%/.obsidian/snippets)中的 CSS 片段加入如下注释:
/* @settings
name: Your Section Name Here
id: a-unique-id
settings:
-
id: my-title
title: My Settings
type: heading
level: 3
-
id: accent
title: Accent Color
type: variable-color
format: hsl-split
default: '#007AFF'
*/
将得到:
Each setting definition must be separated by a dash (-). There are 7 setting types.
All settings definitions must have these parameters:
id: A unique id for the setting parametertitle: The name of the settingdescription (optional): a description of the settingtype: The type of setting. Can be one of:heading: a heading element for organizing settingsclass-toggle: a switch to toggle classes on the body elementclass-select: a dropdown menu of predefined options to add classes on the body elementvariable-text: a text-based CSS variablevariable-number: a numeric CSS variablevariable-number-slider: a numeric CSS variable represented by a slidervariable-select: a text-based CSS variable displayed as a dropdown menu of predefined optionsvariable-color: a color CSS variable with corresponding color pickerheadingheadings can be used to organize and group settings into collapsable nested sections. Along with the required attributes, headings must contain a level attribute between 1 and 6, and can optionally contain a collapsed attribute:
/* @settings
name: Your Section Name Here
id: a-unique-id
settings:
-
id: this-is-a-heading
title: My Heading
type: heading
level: 2
collapsed: true
*/
info-textinfo-text displays arbitrary informational text to users. The description may contain markdown if markdown is set to true.
/* @settings
name: Your Section Name Here
id: a-unique-id
settings:
-
id: my-info-text
title: Information
description: "This is *informational* text"
type: info-text
markdown: true
*/
class-toggleclass-toggles will toggle a css class on and off of the body element, allowing CSS themes and snippets to toggle features on and off. The id of the setting will be used as the class name. The default parameter can optionally be set to true. class-toggle also supports the addCommand property. When set to true a command will be added to obsidian to toggle the class via a hotkey or the command palette.
/* @settings
name: Your Section Name Here
id: a-unique-id
settings:
-
id: my-css-class
title: My Toggle
description: Adds my-css-class to the body element
type: class-toggle
*/
class-selectclass-select creates a dropdown of predefined options for a CSS variable. The id of the setting will be used as the variable name.
allowEmpty is false, a default option must be specified.allowEmpty is true, the default attribute is optional, and may be set to none./* @settings
name: Your Section Name Here
id: a-unique-id
settings:
-
id: theme-variant
title: Theme variant
description: Variations on a theme
type: class-select
allowEmpty: false
default: my-class
options:
- my-class
- my-other-class
- and-yet-another
*/
Options may also be given a label:
/* @settings
name: Your Section Name Here
id: a-unique-id
settings:
-
id: theme-variant
title: Theme variant
description: Variations on a theme
type: class-select
allowEmpty: false
default: my-class
options:
-
label: My Class
value: my-class
-
label: My Other Class
value: my-other-class
*/
variable-textvariable-text represents any text based CSS value. The id of the setting will be used as the variable name. The output will be wrapped in quotes if quotes is set to true. variable-text settings require a default attribute.
/* @settings
name: Your Section Name Here
id: a-unique-id
settings:
-
id: text
title: UI font
description: Font used for the user interface
type: variable-text
default: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif
*/
This will output the variable:
--text: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
Using quotes:
/* @settings
name: Your Section Name Here
id: a-unique-id
settings:
-
id: icon
title: Bullet Icon
description: Text used in bullet points
type: variable-text
default: •
quotes: true
*/
This will output the variable:
--icon: '•'
variable-numbervariable-number represents any numeric CSS value. The id of the setting will be used as the variable name. variable-number settings require a default attribute. Optionally, a format attribute can be set. This value will be appended to the number. Eg format: px will result in 42px
/* @settings
name: Your Section Name Here
id: a-unique-id
settings:
-
id: line-width
title: Line width
description: The maximum line width in rem units
type: variable-number
default: 42
format: rem
*/
This will output the variable:
--line-width: 42rem;
variable-number-slidervariable-number-slider represents any numeric CSS value. The id of the setting will be used as the variable name. variable-number-slider settings require a default attribute, as well as these three attributes:
min: The minimum possible value of the slidermax: The maximum possible value of the sliderstep: The size of each "tick" of the slider. For example, a step of 100 will only allow the slider to move in increments of 100.Optionally, a format attribute can be set. This value will be appended to the number. Eg format: px will result in 42px
/* @settings
name: Your Section Name Here
id: a-unique-id
settings:
-
id: line-width
title: Line width
description: The maximum line width in rem units
type: variable-number-slider
default: 42
min: 10
max: 100
step: 1
*/
This will output the variable:
--line-width: 42;
variable-selectvariable-select creates a dropdown of predefined options for a CSS variable. The id of the setting will be used as the variable name. variable-select settings require a default attribute as well as a list of options.
/* @settings
name: Your Section Name Here
id: a-unique-id
settings:
-
id: text
title: UI font
description: Font used for the user interface
type: variable-select
default: Roboto
options:
- Roboto
- Helvetica Neue
- sans-serif
- Segoe UI
*/
Options can optionally be given a label:
/* @settings
name: Your Section Name Here
id: a-unique-id
settings:
-
id: text
title: UI font
description: Font used for the user interface
type: variable-select
default: Roboto
options:
-
label: The best font
value: Roboto
-
label: The next best font
value: Helvetica Neue
*/
This will output the variable:
--text: Roboto;
variable-colorvariable-color creates a color picker with a variety of output format options. A default attribute is required in hex or rgb format. Note: hex color values must be wrapped in quotes. A format attribute is also required.
Optional parameters:
opacity to true will enable opacity support in all output formats.alt-format setting/* @settings
name: Your Section Name Here
id: a-unique-id
settings:
-
id: accent
title: Accent Color
type: variable-color
opacity: false
format: hex
alt-format:
-
id: accent-rgb
format: rgb
default: '#007AFF'
*/
This will output the variable:
--accent: #007AFF;
--accent-rgb: rgb(0, 123, 255);
variable-themed-colorvariable-themed-color is identical to variable-color except that it generates two color pickers for a light and dark variant.
/* @settings
name: Your Section Name Here
id: a-unique-id
settings:
-
id: accent
title: Accent Color
type: variable-themed-color
format: hex
opacity: false
default-light: '#007AFF'
default-dark: '#2DB253'
*/
This will apply the variables to the current theme:
// light theme active
--accent: #007AFF;
// dark theme active
--accent: #2DB253;
The variables are set inline on <body> (body keeps the css-settings-manager
class, so themes that scope overrides with body.css-settings-manager keep
working), and the light/dark variants follow the active theme automatically.
variable-color formatting optionsThere are 8 formatting options:
hex--accent: #007AFF;
When opacity is set to true:
--accent: #007AFFFF;
rgb--accent: rgb(0, 122, 255);
When opacity is set to true:
--accent: rgba(0, 122, 255, 1);
rgb-values--accent: 0, 122, 255;
When opacity is set to true:
--accent: 0, 122, 255, 1;
rgb-split--accent-r: 0;
--accent-g: 122;
--accent-b: 255;
When opacity is set to true:
--accent-r: 0;
--accent-g: 122;
--accent-b: 255;
--accent-a: 1;
hsl--accent: hsl(211, 100%, 50%);
When opacity is set to true:
--accent: hsla(211, 100%, 50%, 1);
hsl-values--accent: 211, 100%, 50%;
When opacity is set to true:
--accent: 211, 100%, 50%, 1;
hsl-split--accent-h: 211;
--accent-s: 100%;
--accent-l: 50%;
When opacity is set to true:
--accent-h: 211;
--accent-s: 100%;
--accent-l: 50%;
--accent-a: 1;
hsl-split-decimal--accent-h: 211;
--accent-s: 1;
--accent-l: 0.5;
When opacity is set to true:
--accent-h: 211;
--accent-s: 1;
--accent-l: 0.5;
--accent-a: 1;
color-gradientcolor-gradient outputs a fixed number of colors along a gradient between two existing color variables. A format attribute is also required. Note: The to variable must be set in style settings for the gradient to be generated. Also, gradients will only be generated using colors defined under the current style settings id.
Parameters:
from: The starting color, or color that will be at step 0to: The ending color, or color that will be at step 100step: The increment at which to output a CSS variable. For example, setting step to 10 will output --var-0, --var-10, --var-20, etc...format: Can be one of: hsl, rgb, or hex;pad?: When set, the number section of the variable will be padded with 0's until it contains this number of digits. For example, setting pad to 3 and step to 10 will output --var-000, --var-010, --var-020/* @settings
name: Your Section Name Here
id: a-unique-id
settings:
-
id: color-base
type: color-gradient
from: color-base-00
to: color-base-100
step: 5
pad: 2
format: hex
*/
Plugins can specify a style setting config in the plugin's CSS. Plugins must call app.workspace.trigger("parse-style-settings") when the plugin loads in order for Style Tuner to be notified of CSS changes. This event name is kept for compatibility with the original Style Settings plugin interface.
Translations for titles and descriptions can be supplied for each language Obsidian supports by using one of the following postfixes:
en: English
zh: 简体中文
zh-TW: 繁體中文
ru: Русский
ko: 한국어
it: Italiano
id: Bahasa Indonesia
ro: Română
pt-BR: Português do Brasil
cz: čeština
de: Deutsch
es: Español
fr: Français
no: Norsk
pl: język polski
pt: Português
ja: 日本語
da: Dansk
uk: український
sq: Shqip
tr: Türkçe (kısmi)
hi: हिन्दी (आंशिक)
nl: Nederlands (gedeeltelijk)
ar: العربية (جزئي)
For example:
/* @settings
name: Your Section Name Here
id: a-unique-id
settings:
-
id: my-css-class
title: My Toggle
title.de: Mein Toggle
title.ko: 내 토글
description: Adds my-css-class to the body element
description.de: Fügt my-css-class zum body-Element hinzu
description.ko: my-css-class를 body 요소에 추가합니다
type: class-toggle
*/
Style Tuner is licensed under the GNU General Public License v3.0, following the license of the upstream Style Settings project. Contributions are welcome under the same license.
本插件包含移植自 Obsidian Linter 的代码,该项目由 Victor Tao 以 MIT 协议发布(Copyright (c) 2021-2022 Victor Tao)。依照 MIT 协议要求,其版权与许可声明随源码一并保留(见 src/linter/LICENSE);合并后的作品整体以 GPL-3.0 发布,移植部分继续遵循其原 MIT 许可。
This repository contains code ported from Obsidian Linter by Victor Tao, released under the MIT License (Copyright (c) 2021-2022 Victor Tao). As required by the MIT license, its copyright and permission notice is preserved with the sources (see src/linter/LICENSE); the combined work is distributed under GPL-3.0, while the ported linter sources remain under their original MIT license.
致谢 / Credits: 感谢 mgmeyers 的 Style Settings 与 platers / Victor Tao 及 Obsidian Linter 的所有贡献者。Thanks to mgmeyers for Style Settings, and to platers / Victor Tao and all Obsidian Linter contributors.