Debian Codegraph @

docs/content/en/functions/css/Unquoted.md

raw
1 ---
2 title: css.Unquoted
3 description: Returns the given string, setting its data type to indicate that it must not be quoted when used in CSS.
4 categories: []
5 keywords: []
6 params:
7 functions_and_methods:
8 aliases: []
9 returnType: css.UnquotedString
10 signatures: [css.Unquoted STRING]
11 ---
12
13 > [!NOTE]
14 > This function is only applicable to the `vars` option passed to the [`css.Sass`][] function.
15
16 When passing a `vars` map to the `css.Sass` function, Hugo detects common typed CSS values such as `24px` or `#FF0000` using regular expression matching. If necessary, you can bypass automatic type inference by using the `css.Unquoted` function to explicitly indicate that the value must be treated as an unquoted string.
17
18 In the example below, we use `css.Unquoted` to ensure the value for the `font-family` property is injected without quotes.
19
20 ```go-html-template
21 {{ $vars := dict
22 "font-main" ("sans-serif" | css.Unquoted)
23 }}
24
25 {{ $opts := dict "vars" $vars "transpiler" "dartsass" }}
26 {{ with resources.Get "sass/main.scss" | css.Sass $opts }}
27 <link rel="stylesheet" href="{{ .RelPermalink }}">
28 {{ end }}
29 ```
30
31 Using the `hugo:vars` identifier in your stylesheet:
32
33 ```scss
34 @use "hugo:vars" as h;
35
36 body {
37 font-family: h.$font-main;
38 }
39 ```
40
41 The resulting CSS contains an unquoted string:
42
43 ```css
44 body {
45 font-family: sans-serif;
46 }
47 ```
48
49 [`css.Sass`]: /functions/css/sass/#vars