9 | Until now, trying to style an article, document, or blog post with Tailwind has been a tedious
10 | task that required a keen eye for typography and a lot of complex custom CSS.
11 |
12 |
13 | By default, Tailwind removes all of the default browser styling from paragraphs, headings, lists and more. This ends up being really useful for building application UIs because you spend less time undoing user-agent styles, but when you _really are_ just trying to style some content that came from a rich-text editor in a CMS or a markdown file, it can be surprising and unintuitive.
14 |
15 | We get lots of complaints about it actually, with people regularly asking us things like:
16 |
17 | > Why is Tailwind removing the default styles on my `h1` elements? How do I disable this? What do you mean I lose all the other base styles too?
18 |
19 | We hear you, but we're not convinced that simply disabling our base styles is what you really want. You don't want to have to remove annoying margins every time you use a `p` element in a piece of your dashboard UI. And I doubt you really want your blog posts to use the user-agent styles either — you want them to look _awesome_, not awful.
20 |
21 | The `@tailwindcss/typography` plugin is our attempt to give you what you _actually_ want, without any of the downsides of doing something stupid like disabling our base styles.
22 |
23 | It adds a new `prose` class that you can slap on any block of vanilla HTML content and turn it into a beautiful, well-formatted document:
24 |
25 | ```html
26 | ` elements aren't given a child `` tag unless there are multiple paragraphs in the list item. That means I have to worry about styling that annoying situation too.
149 |
150 | - **For example, here's another nested list.**
151 |
152 | But this time with a second paragraph.
153 |
154 | - These list items won't have `
` tags
155 | - Because they are only one line each
156 |
157 | - **But in this second top-level list item, they will.**
158 |
159 | This is especially annoying because of the spacing on this paragraph.
160 |
161 | - As you can see here, because I've added a second line, this list item now has a `
` tag.
162 |
163 | This is the second line I'm talking about by the way.
164 |
165 | - Finally here's another list item so it's more like a list.
166 |
167 | - A closing list item, but with no nested list, because why not?
168 |
169 | And finally a sentence to close off this section.
170 |
171 | ## There are other elements we need to style
172 |
173 | I almost forgot to mention links, like [this link to the Tailwind CSS website](https://tailwindcss.com). We almost made them blue but that's so yesterday, so we went with dark gray, feels edgier.
174 |
175 | We even included table styles, check it out:
176 |
177 | | Wrestler | Origin | Finisher |
178 | | ----------------------- | ------------ | ------------------ |
179 | | Bret "The Hitman" Hart | Calgary, AB | Sharpshooter |
180 | | Stone Cold Steve Austin | Austin, TX | Stone Cold Stunner |
181 | | Randy Savage | Sarasota, FL | Elbow Drop |
182 | | Vader | Boulder, CO | Vader Bomb |
183 | | Razor Ramon | Chuluota, FL | Razor's Edge |
184 |
185 | We also need to make sure inline code looks good, like if I wanted to talk about `` elements or tell you the good news about `@tailwindcss/typography`.
186 |
187 | ### Sometimes I even use `code` in headings
188 |
189 | Even though it's probably a bad idea, and historically I've had a hard time making it look good. This _"wrap the code blocks in backticks"_ trick works pretty well though really.
190 |
191 | Another thing I've done in the past is put a `code` tag inside of a link, like if I wanted to tell you about the [`tailwindcss/docs`](https://github.com/tailwindcss/docs) repository. I don't love that there is an underline below the backticks but it is absolutely not worth the madness it would require to avoid it.
192 |
193 | #### We haven't used an `h4` yet
194 |
195 | But now we have. Please don't use `h5` or `h6` in your content, Medium only supports two heading levels for a reason, you animals. I honestly considered using a `before` pseudo-element to scream at you if you use an `h5` or `h6`.
196 |
197 | We don't style them at all out of the box because `h4` elements are already so small that they are the same size as the body copy. What are we supposed to do with an `h5`, make it _smaller_ than the body copy? No thanks.
198 |
199 | ### We still need to think about stacked headings though.
200 |
201 | #### Let's make sure we don't screw that up with `h4` elements, either.
202 |
203 | Phew, with any luck we have styled the headings above this text and they look pretty good.
204 |
205 | Let's add a closing paragraph here so things end with a decently sized block of text. I can't explain why I want things to end that way but I have to assume it's because I think things will look weird or unbalanced if there is a heading too close to the end of the document.
206 |
207 | What I've written here is probably long enough, but adding this final sentence can't hurt.
--------------------------------------------------------------------------------
/public/avatar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexcarpenter/nextjs-mdx-blog-theme/76ba30e806f34edc6129edb681f36841925ac2e6/public/avatar.png
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexcarpenter/nextjs-mdx-blog-theme/76ba30e806f34edc6129edb681f36841925ac2e6/public/favicon.ico
--------------------------------------------------------------------------------
/public/og-image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexcarpenter/nextjs-mdx-blog-theme/76ba30e806f34edc6129edb681f36841925ac2e6/public/og-image.png
--------------------------------------------------------------------------------
/public/vercel.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/styles/globals.css:
--------------------------------------------------------------------------------
1 | @tailwind base;
2 | @tailwind components;
3 | @tailwind utilities;
4 |
5 | html,
6 | body,
7 | #__next {
8 | height: 100%;
9 | }
10 |
11 | /**
12 | * Code block styles
13 | * MIT License
14 | * Copyright (c) 2018 Sarah Drasner
15 | * Sarah Drasner's[@sdras] Night Owl
16 | * Ported by Sara vieria [@SaraVieira]
17 | * Added by Souvik Mandal [@SimpleIndian]
18 | */
19 |
20 | code[class*="language-"],
21 | pre[class*="language-"] {
22 | color: #d6deeb;
23 | font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace;
24 | text-align: left;
25 | white-space: pre;
26 | word-spacing: normal;
27 | word-break: normal;
28 | word-wrap: normal;
29 | line-height: 1.5;
30 |
31 | -moz-tab-size: 4;
32 | -o-tab-size: 4;
33 | tab-size: 4;
34 |
35 | -webkit-hyphens: none;
36 | -moz-hyphens: none;
37 | -ms-hyphens: none;
38 | hyphens: none;
39 | }
40 |
41 | pre[class*="language-"]::-moz-selection,
42 | pre[class*="language-"] ::-moz-selection,
43 | code[class*="language-"]::-moz-selection,
44 | code[class*="language-"] ::-moz-selection {
45 | text-shadow: none;
46 | background: rgba(29, 59, 83, 0.99);
47 | }
48 |
49 | pre[class*="language-"]::selection,
50 | pre[class*="language-"] ::selection,
51 | code[class*="language-"]::selection,
52 | code[class*="language-"] ::selection {
53 | text-shadow: none;
54 | background: rgba(29, 59, 83, 0.99);
55 | }
56 |
57 | @media print {
58 | code[class*="language-"],
59 | pre[class*="language-"] {
60 | text-shadow: none;
61 | }
62 | }
63 |
64 | /* Code blocks */
65 | pre[class*="language-"] {
66 | padding: 1em;
67 | overflow: auto;
68 | }
69 |
70 | :not(pre) > code[class*="language-"],
71 | pre[class*="language-"] {
72 | @apply text-gray-50 border bg-gray-900 border-gray-700;
73 | }
74 |
75 | :not(pre) > code[class*="language-"] {
76 | padding: 0.1em;
77 | border-radius: 0.3em;
78 | white-space: normal;
79 | }
80 |
81 | .token.comment,
82 | .token.prolog,
83 | .token.cdata {
84 | color: rgb(99, 119, 119);
85 | font-style: italic;
86 | }
87 |
88 | .token.punctuation {
89 | color: rgb(199, 146, 234);
90 | }
91 |
92 | .namespace {
93 | color: rgb(178, 204, 214);
94 | }
95 |
96 | .token.deleted {
97 | color: rgba(239, 83, 80, 0.56);
98 | font-style: italic;
99 | }
100 |
101 | .token.symbol,
102 | .token.property {
103 | color: rgb(128, 203, 196);
104 | }
105 |
106 | .token.tag,
107 | .token.operator,
108 | .token.keyword {
109 | color: rgb(127, 219, 202);
110 | }
111 |
112 | .token.boolean {
113 | color: rgb(255, 88, 116);
114 | }
115 |
116 | .token.number {
117 | color: rgb(247, 140, 108);
118 | }
119 |
120 | .token.constant,
121 | .token.function,
122 | .token.builtin,
123 | .token.char {
124 | color: rgb(130, 170, 255);
125 | }
126 |
127 | .token.selector,
128 | .token.doctype {
129 | color: rgb(199, 146, 234);
130 | font-style: italic;
131 | }
132 |
133 | .token.attr-name,
134 | .token.inserted {
135 | color: rgb(173, 219, 103);
136 | font-style: italic;
137 | }
138 |
139 | .token.string,
140 | .token.url,
141 | .token.entity,
142 | .language-css .token.string,
143 | .style .token.string {
144 | color: rgb(173, 219, 103);
145 | }
146 |
147 | .token.class-name,
148 | .token.atrule,
149 | .token.attr-value {
150 | color: rgb(255, 203, 139);
151 | }
152 |
153 | .token.regex,
154 | .token.important,
155 | .token.variable {
156 | color: rgb(214, 222, 235);
157 | }
158 |
159 | .token.important,
160 | .token.bold {
161 | font-weight: bold;
162 | }
163 |
164 | .token.italic {
165 | font-style: italic;
166 | }
167 |
--------------------------------------------------------------------------------
/tailwind.config.js:
--------------------------------------------------------------------------------
1 | const defaultTheme = require("tailwindcss/defaultTheme");
2 |
3 | module.exports = {
4 | darkMode: "class",
5 | content: [
6 | "./pages/**/*.{js,ts,jsx,tsx}",
7 | "./components/**/*.{js,ts,jsx,tsx}",
8 | ],
9 | theme: {
10 | extend: {
11 | fontFamily: {
12 | sans: ["Inter var", ...defaultTheme.fontFamily.sans],
13 | },
14 | },
15 | },
16 | plugins: [require("@tailwindcss/typography")],
17 | };
18 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "baseUrl": ".",
4 | "paths": {
5 | "@/components/*": ["components/*"],
6 | "@/data/*": ["data/*"],
7 | "@/lib/*": ["lib/*"],
8 | "@/styles/*": ["styles/*"],
9 | },
10 | "target": "es5",
11 | "lib": ["dom", "dom.iterable", "esnext"],
12 | "allowJs": true,
13 | "skipLibCheck": true,
14 | "strict": true,
15 | "forceConsistentCasingInFileNames": true,
16 | "noEmit": true,
17 | "esModuleInterop": true,
18 | "module": "esnext",
19 | "moduleResolution": "node",
20 | "resolveJsonModule": true,
21 | "isolatedModules": true,
22 | "jsx": "preserve",
23 | "incremental": true
24 | },
25 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
26 | "exclude": ["node_modules"]
27 | }
28 |
--------------------------------------------------------------------------------