Use CSS variables for font-family definition #5224

Closed
opened 2025-11-02 06:18:25 -06:00 by GiteaMirror · 0 comments
Owner

Originally created by @silverwind on GitHub (Apr 11, 2020).

Fonts are currently set by Less variables which cannot be overridden at runtime. I'd propose a method that makes this possible so users can do this both via a custom .css file or even using a userstyle in their browser if they so desire. In our code we would have something like:

:root {
  --fonts-proportional: -apple-system, BlinkMacSystemFont, system-ui, 'Segoe UI', Roboto;
  --fonts-monospace: 'SF Mono', Consolas, Menlo, 'Liberation Mono', Monaco, 'Lucida Console';
  --fonts-emoji: "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
}

body {
  font-family: var(--fonts-proportional) var(--fonts-emoji);
}

pre, code {
  font-family: var(--fonts-monospace);
}

A user can then override via:

@font-face {
  font-family: 'Lato';
}

:root {
  --fonts-proportional: Lato;
}

Depends on: https://github.com/go-gitea/gitea/issues/6147

Originally created by @silverwind on GitHub (Apr 11, 2020). Fonts are currently set by Less variables which cannot be overridden at runtime. I'd propose a method that makes this possible so users can do this both via a custom `.css` file or even using a userstyle in their browser if they so desire. In our code we would have something like: ````css :root { --fonts-proportional: -apple-system, BlinkMacSystemFont, system-ui, 'Segoe UI', Roboto; --fonts-monospace: 'SF Mono', Consolas, Menlo, 'Liberation Mono', Monaco, 'Lucida Console'; --fonts-emoji: "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; } body { font-family: var(--fonts-proportional) var(--fonts-emoji); } pre, code { font-family: var(--fonts-monospace); } ```` A user can then override via: ````css @font-face { font-family: 'Lato'; } :root { --fonts-proportional: Lato; } ```` Depends on: https://github.com/go-gitea/gitea/issues/6147
GiteaMirror added the topic/uitype/proposal labels 2025-11-02 06:18:25 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#5224