Skip to content

Commit b6e88c4

Browse files
committed
Use native font stack (#417)
It ensures that the text is displayed in the font that the user is most comfortable with, and it also reduces the size of the data transferred. Breaking change: The Titillium web font has been replaced with native font stack. Migration: To keep the Titillium web font in your project, load the web font and override the `--rui-font-family-base` custom property: ``` --rui-font-family-base: 'Titillium Web', helvetica, roboto, arial, sans-serif; ```
1 parent c2b0b44 commit b6e88c4

File tree

6 files changed

+73
-53
lines changed

6 files changed

+73
-53
lines changed

README.md

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,7 @@ To install React UI in your app:
5353
npm install --save @react-ui-org/react-ui
5454
```
5555

56-
2. Load the Titillium Web font:
57-
58-
```html
59-
<link
60-
href="https://fonts.googleapis.com/css2?family=Titillium+Web:wght@300;400;600;700&display=swap"
61-
rel="stylesheet"
62-
/>
63-
```
64-
65-
3. Load React UI CSS in your app:
56+
2. Load React UI CSS in your app:
6657

6758
<!-- eslint-env browser -->
6859
<!-- eslint-disable import/no-unresolved -->
@@ -73,7 +64,7 @@ To install React UI in your app:
7364

7465
<!-- eslint-env browser -->
7566

76-
4. Import and use any of React UI components in your app:
67+
3. Import and use any of React UI components in your app:
7768

7869
```jsx
7970
import { Button } from '@react-ui-org/react-ui';

mkdocs.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ theme:
2929
language: 'en'
3030
favicon: 'favicon.ico'
3131
custom_dir: 'src/docs/_overrides'
32-
font:
33-
text: 'Titillium Web'
3432
palette:
3533
- media: "(prefers-color-scheme: light)"
3634
scheme: default

src/docs/_assets/stylesheets/extra.css

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ code, kbd, pre {
8181
.md-search-result__terms,
8282
.md-source,
8383
.md-top {
84-
font-size: 1rem;
84+
font-size: 0.875rem;
8585
}
8686

8787
.md-nav,
@@ -92,11 +92,11 @@ code, kbd, pre {
9292
.md-typeset .footnote,
9393
.md-typeset .footnote-ref,
9494
.md-typeset .tabbed-labels > label {
95-
font-size: 0.85rem;
95+
font-size: 0.875rem;
9696
}
9797

9898
.md-typeset {
99-
font-size: 1.125rem;
99+
font-size: 1rem;
100100
}
101101

102102
.md-typeset a {
@@ -117,36 +117,37 @@ code, kbd, pre {
117117
.md-typeset h1 {
118118
margin-top: 0.8rem;
119119
margin-bottom: 2rem;
120-
font-size: 3rem;
120+
font-weight: 800;
121+
font-size: 2.4rem;
121122
color: inherit;
122123
}
123124

124125
.md-content .md-typeset h1 + p {
125-
font-size: 1.5rem;
126+
font-size: 1.3rem;
126127
}
127128

128129
.md-typeset h2 {
129130
margin-top: 3.2rem;
130131
margin-bottom: 0.8rem;
131-
font-size: 2rem;
132+
font-size: 1.65rem;
132133
}
133134

134135
.md-typeset h3 {
135136
margin-top: 2.4rem;
136137
margin-bottom: 0.8rem;
137-
font-size: 1.75rem;
138+
font-size: 1.45rem;
138139
}
139140

140141
.md-typeset h4 {
141142
margin-top: 1.6rem;
142143
margin-bottom: 0.4rem;
143-
font-size: 1.5rem;
144+
font-size: 1.25rem;
144145
}
145146
.md-typeset h5,
146147
.md-typeset h6 {
147148
margin-top: 1.6rem;
148149
margin-bottom: 0.4rem;
149-
font-size: 1.25rem;
150+
font-size: 1.125rem;
150151
}
151152

152153
.md-typeset blockquote {
@@ -172,15 +173,14 @@ code, kbd, pre {
172173
}
173174

174175
.md-typeset :is(ol, ul) li {
175-
margin-bottom: 0.25rem;
176+
margin-bottom: 0.55rem;
176177
}
177178

178179
.md-typeset ol li blockquote,
179180
.md-typeset ol li p,
180181
.md-typeset ul li blockquote,
181182
.md-typeset ul li p {
182-
margin-top: 0;
183-
margin-bottom: 0.8rem;
183+
margin-block: 0;
184184
}
185185

186186
.md-typeset hr {
@@ -199,12 +199,12 @@ table {
199199
}
200200

201201
.md-typeset table:not([class]) {
202-
font-size: 1rem;
202+
font-size: 0.875rem;
203203
border: none;
204204
}
205205

206206
.md-typeset table:not([class]) :is(th, td) {
207-
padding: 0.75rem 0.5rem;
207+
padding: 1rem 0.5rem;
208208
vertical-align: middle;
209209
border-style: none none solid;
210210
border-width: 1px;
@@ -386,8 +386,13 @@ pre[class*="language-"] {
386386
}
387387

388388
pre[class*="language-"],
389-
.docoff-Root,
389+
.docoff-Root {
390+
margin-top: 0;
391+
margin-bottom: 2.4rem;
392+
}
393+
390394
.md-typeset :is(p, ul, ol, dl) {
395+
max-width: 40rem;
391396
margin-top: 0;
392397
margin-bottom: 1.6rem;
393398
}
@@ -398,6 +403,15 @@ docoff-react-props {
398403
overflow-x: auto;
399404
}
400405

406+
docoff-react-props > table tr {
407+
transition: background-color 125ms;
408+
}
409+
410+
docoff-react-props > table tr:hover {
411+
background-color: var(--md-typeset-table-color--light);
412+
box-shadow: 0 .05rem 0 var(--md-default-bg-color) inset;
413+
}
414+
401415
@media screen and (max-width: 44.9375em) {
402416
docoff-react-props,
403417
.docoff-Root,

src/docs/foundation/typography.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,22 @@ Styling of basic HTML elements:
5959

6060
## Font
6161

62-
React UI is designed with [Titillium Web] font, a geometric sans with a wide
63-
variety of weights and styles. You can change it to a custom font by
64-
[overriding](/docs/customize/theming/overview) the `--rui-font-family-base` CSS
65-
custom property:
62+
React UI uses [native font stack][sm-native-font-stack], which means it uses
63+
the default font of the browser. This is a good practice because it ensures that
64+
the text is displayed in the font that the user is most comfortable with, and
65+
it also reduces the size of the data transferred.
66+
67+
You can change it to a custom font by loading the font in your project:
68+
69+
```html
70+
<link
71+
href="https://fonts.googleapis.com/css2?family=Titillium+Web:wght@300;400;700&display=swap"
72+
rel="stylesheet"
73+
/>
74+
```
75+
76+
… and [overriding](/docs/customize/theming/overview) the
77+
`--rui-font-family-base` CSS custom property:
6678

6779
```css
6880
:root {
@@ -101,4 +113,4 @@ Font size, font weight, and line height values can be
101113
}
102114
```
103115

104-
[Titillium Web]: https://fonts.google.com/specimen/Titillium+Web
116+
[sm-native-font-stack]: https://www.smashingmagazine.com/2015/11/using-system-ui-fonts-practical-guide/

src/docs/getting-started/usage.md

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,6 @@ add the responsive viewport meta tag to your `<head>` element:
1111
<meta name="viewport" content="width=device-width, initial-scale=1" />
1212
```
1313

14-
## Fonts
15-
16-
React UI is designed with the Titillium Web font. Add it to your project e.g. via
17-
Google Fonts in your `<head>` element:
18-
19-
```html
20-
<link
21-
href="https://fonts.googleapis.com/css2?family=Titillium+Web:wght@300;400;700&display=swap"
22-
rel="stylesheet"
23-
/>
24-
```
25-
26-
Remember to include all necessary font weights (and only them — for better
27-
performance).
28-
2914
## CSS
3015

3116
React UI styles are written in Sass and compiled to CSS. You can import them
@@ -80,10 +65,6 @@ Example HTML:
8065
<meta charset="utf-8" />
8166
<meta name="viewport" content="width=device-width, initial-scale=1" />
8267
<title>React UI Example</title>
83-
<link
84-
href="https://fonts.googleapis.com/css2?family=Titillium+Web:wght@300;400;700&display=swap"
85-
rel="stylesheet"
86-
/>
8768
</head>
8869
<body>
8970
<div id="app"></div>

src/theme.scss

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,31 @@
4949
// Font Families
5050
// =============
5151

52-
--rui-font-family-base: "Titillium Web", helvetica, roboto, arial, sans-serif;
52+
// Native font stack inspired by Bootstrap.
53+
// @see https://getbootstrap.com/docs/5.0/content/reboot/#native-font-stack
54+
// @see https://css-tricks.com/snippets/css/system-font-stack/
55+
--rui-font-family-base:
56+
/* Cross-platform generic font family (default user interface font) */
57+
system-ui,
58+
/* Safari for macOS and iOS (San Francisco)*/
59+
-apple-system,
60+
/* Windows*/
61+
"Segoe UI",
62+
/* Android*/
63+
roboto,
64+
/* Basic web fallback*/
65+
"Helvetica Neue",
66+
arial,
67+
/* Linux*/
68+
"Noto Sans",
69+
"Liberation Sans",
70+
/* Sans serif fallback*/
71+
sans-serif,
72+
/* Emoji fonts*/
73+
"Apple Color Emoji",
74+
"Segoe UI Emoji",
75+
"Segoe UI Symbol",
76+
"Noto Color Emoji";
5377
--rui-font-family-monospace:
5478
"SFMono-Regular",
5579
"Menlo",

0 commit comments

Comments
 (0)