Skip to content

Commit ad171bd

Browse files
Added anchors to custom headings (#2241)
Fixes: #2240 In the spirit of reusability, I declared a new component called `Heading`. You need to specify the level (between 1 and 6), the ID (which is mandatory), and the content of the element. With this in place, I also declared `H2` through `H6` elements. Thus, instead of: ```html <h3 id="import-directive">@import</h3> ``` * [Preview](https://tailwindcss.com/docs/functions-and-directives#import-directive) you can use: ```html <H3 id="import-directive">@import</H3> ``` * [Preview](https://tailwindcss-com-git-fork-rozsazoltan-fix-he-f001db-tailwindlabs.vercel.app/docs/functions-and-directives#import-directive) what will be: ```html <h3 id="import-directive"> <a href="#import-directive" class="anchor">@import</a> </h3> ``` --------- Co-authored-by: Philipp Spiess <hello@philippspiess.com>
1 parent e0919ff commit ad171bd

File tree

1 file changed

+39
-13
lines changed

1 file changed

+39
-13
lines changed

src/docs/functions-and-directives.mdx

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ export const description = "A reference for the custom functions and directives
77

88
Directives are custom Tailwind-specific [at-rules](https://developer.mozilla.org/en-US/docs/Web/CSS/At-rule) you can use in your CSS that offer special functionality for Tailwind CSS projects.
99

10-
<h3 id="import-directive">@import</h3>
10+
<h3 id="import-directive">
11+
<a href="#import-directive">@import</a>
12+
</h3>
1113

1214
Use the `@import` directive to inline import CSS files, including Tailwind itself:
1315

@@ -16,7 +18,9 @@ Use the `@import` directive to inline import CSS files, including Tailwind itsel
1618
@import "tailwindcss";
1719
```
1820

19-
<h3 id="theme-directive">@theme</h3>
21+
<h3 id="theme-directive">
22+
<a href="#theme-directive">@theme</a>
23+
</h3>
2024

2125
Use the `@theme` directive to define your project's custom design tokens, like fonts, colors, and breakpoints:
2226

@@ -43,7 +47,9 @@ Use the `@theme` directive to define your project's custom design tokens, like f
4347

4448
Learn more about customizing your theme in the [theme variables documentation](/docs/theme).
4549

46-
<h3 id="source-directive">@source</h3>
50+
<h3 id="source-directive">
51+
<a href="#source-directive">@source</a>
52+
</h3>
4753

4854
Use the `@source` directive to explicitly specify source files that aren't picked up by Tailwind's automatic content detection:
4955

@@ -54,7 +60,9 @@ Use the `@source` directive to explicitly specify source files that aren't picke
5460

5561
Learn more about automatic content detection in the [detecting classes in source files documentation](/docs/detecting-classes-in-source-files).
5662

57-
<h3 id="utility-directive">@utility</h3>
63+
<h3 id="utility-directive">
64+
<a href="#utility-directive">@utility</a>
65+
</h3>
5866

5967
Use the `@utility` directive to add custom utilities to your project that work with variants like `hover`, `focus` and `lg`:
6068

@@ -67,7 +75,9 @@ Use the `@utility` directive to add custom utilities to your project that work w
6775

6876
Learn more about registering custom utilities in the [adding custom utilities documentation](/docs/adding-custom-styles#adding-custom-utilities).
6977

70-
<h3 id="variant-directive">@variant</h3>
78+
<h3 id="variant-directive">
79+
<a href="#variant-directive">@variant</a>
80+
</h3>
7181

7282
Use the `@variant` directive to apply a Tailwind variant to styles in your CSS:
7383

@@ -85,7 +95,9 @@ Use the `@variant` directive to apply a Tailwind variant to styles in your CSS:
8595

8696
Learn more using variants in the [using variants documentation](/docs/adding-custom-styles#using-variants).
8797

88-
<h3 id="custom-variant-directive">@custom-variant</h3>
98+
<h3 id="custom-variant-directive">
99+
<a href="#custom-variant-directive">@custom-variant</a>
100+
</h3>
89101

90102
Use the `@custom-variant` directive to add a custom variant in your project:
91103

@@ -98,7 +110,9 @@ This lets you write utilities `theme-midnight:bg-black` and `theme-midnight:text
98110

99111
Learn more about adding custom variants in the [adding custom variants documentation](/docs/adding-custom-styles#adding-custom-variants).
100112

101-
<h3 id="apply-directive">@apply</h3>
113+
<h3 id="apply-directive">
114+
<a href="#apply-directive">@apply</a>
115+
</h3>
102116

103117
Use the `@apply` directive to inline any existing utility classes into your own custom CSS:
104118

@@ -122,7 +136,9 @@ Use the `@apply` directive to inline any existing utility classes into your own
122136

123137
This is useful when you need to write custom CSS (like to override the styles in a third-party library) but still want to work with your design tokens and use the same syntax you’re used to using in your HTML.
124138

125-
<h3 id="reference-directive">@reference</h3>
139+
<h3 id="reference-directive">
140+
<a href="#reference-directive">@reference</a>
141+
</h3>
126142

127143
If you want to use `@apply` or `@variant` in the `<style>` block of a Vue or Svelte component, or within CSS modules, you will need to import your theme variables, custom utilities, and custom variants to make those values available in that context.
128144

@@ -166,7 +182,9 @@ If you’re just using the default theme with no customizations, you can import
166182

167183
Tailwind provides the following build-time functions to make working with colors and the spacing scale easier.
168184

169-
<h3 id="alpha-function">--alpha()</h3>
185+
<h3 id="alpha-function">
186+
<a href="#alpha-function">--alpha()</a>
187+
</h3>
170188

171189
Use the `--alpha()` function to adjust the opacity of a color:
172190

@@ -189,7 +207,9 @@ Use the `--alpha()` function to adjust the opacity of a color:
189207

190208
</CodeExampleStack>
191209

192-
<h3 id="spacing-function">--spacing()</h3>
210+
<h3 id="spacing-function">
211+
<a href="#spacing-function">--spacing()</a>
212+
</h3>
193213

194214
Use the `--spacing()` function to generate a spacing value based on your theme:
195215

@@ -226,7 +246,9 @@ This can also be useful in arbitrary values, especially in combination with `cal
226246

227247
The following directives and functions exist solely for compatibility with Tailwind CSS v3.x.
228248

229-
<h3 id="config-directive">@config</h3>
249+
<h3 id="config-directive">
250+
<a href="#config-directive">@config</a>
251+
</h3>
230252

231253
Use the `@config` directive to load a legacy JavaScript-based configuration file:
232254

@@ -237,7 +259,9 @@ Use the `@config` directive to load a legacy JavaScript-based configuration file
237259

238260
The `corePlugins`, `safelist`, and `separator` options from the JavaScript-based config are not supported in v4.0.
239261

240-
<h3 id="plugin-directive">@plugin</h3>
262+
<h3 id="plugin-directive">
263+
<a href="#plugin-directive">@plugin</a>
264+
</h3>
241265

242266
Use the `@plugin` directive to load a legacy JavaScript-based plugin:
243267

@@ -248,7 +272,9 @@ Use the `@plugin` directive to load a legacy JavaScript-based plugin:
248272

249273
The `@plugin` directive accepts either a package name or a local path.
250274

251-
<h3 id="theme-function">theme()</h3>
275+
<h3 id="theme-function">
276+
<a href="#theme-function">theme()</a>
277+
</h3>
252278

253279
Use the `theme()` function to access your Tailwind theme values using dot notation:
254280

0 commit comments

Comments
 (0)