@@ -208,123 +208,66 @@ body .gv-container { --gv-color-primary: #7a1f1f; }
208208:root { --gv-color-primary: #7a1f1f; }` } </ code >
209209 </ pre >
210210
211- < h2 > Machine-readable token files </ h2 >
211+ < h2 > Target a View with placeholders </ h2 >
212212 < p >
213- Two generated files publish this reference as data. Both rebuild from GravityView's token registry on every
214- deploy, so anything you write into them is overwritten.
213+ When you enter rules in GravityView's < strong > Custom CSS</ strong > field (View Settings →{ ' ' }
214+ < strong > Custom Code</ strong > ), GravityView swaps three placeholders for that View's own values as the page
215+ loads, so you can target a single View without hardcoding its container ID:
215216 </ p >
216217 < table >
217218 < thead >
218219 < tr >
219- < th > File </ th >
220- < th > Format </ th >
221- < th > Use it for </ th >
220+ < th > Placeholder </ th >
221+ < th > Replaced with </ th >
222+ < th > Example output </ th >
222223 </ tr >
223224 </ thead >
224225 < tbody >
225226 < tr >
226- < td >
227- < a href = "/api/css-tokens.tokens.json" >
228- < code > /api/css-tokens.tokens.json</ code >
229- </ a >
230- </ td >
231- < td >
232- < a href = "https://www.designtokens.org/TR/2025.10/format/" > Design Tokens Format Module 2025.10</ a >
233- </ td >
234- < td > Design-tool interop: Style Dictionary, Terrazzo, Tokens Studio, Figma</ td >
227+ < td > < code > VIEW_SELECTOR</ code > </ td >
228+ < td > A high-specificity CSS selector targeting only this View</ td >
229+ < td > < code > .gv-container.gv-container-123</ code > </ td >
235230 </ tr >
236231 < tr >
237- < td >
238- < a href = "/api/css-tokens.json" >
239- < code > /api/css-tokens.json</ code >
240- </ a >
241- </ td >
242- < td > Flat GravityKit-specific JSON</ td >
243- < td > The lossless record: every token, every field, no exceptions</ td >
232+ < td > < code > VIEW_ID</ code > </ td >
233+ < td > The View's ID number</ td >
234+ < td > < code > 123</ code > </ td >
235+ </ tr >
236+ < tr >
237+ < td > < code > GF_FORM_ID</ code > </ td >
238+ < td > The connected Gravity Forms form ID</ td >
239+ < td > < code > 5</ code > </ td >
244240 </ tr >
245241 </ tbody >
246242 </ table >
247243 < p >
248- The DTCG file validates against the{ ' ' }
249- < a href = "https://www.designtokens.org/schemas/2025.10/format.json" >
250- Design Tokens Community Group's published JSON Schema
251- </ a >
252- , which the build enforces. Read < code > $extensions["com.gravitykit.tokens"].counts</ code > for how many tokens
253- it carries.
254- </ p >
255-
256- < h3 > Token paths are not CSS variable names</ h3 >
257- < p >
258- A token at < code > gravityview.border.entry_color</ code > is the CSS variable{ ' ' }
259- < code > --gv-entry-border-color</ code > . The registry reorders and rewrites segments, so only about a fifth of
260- tokens match a naive path-to-name transform. Drive your name transform from{ ' ' }
261- < code > $extensions["com.gravitykit.tokens"].cssVar</ code > , or you will generate variables GravityView never
262- reads.
244+ Prefer < code > VIEW_SELECTOR</ code > for token overrides: its double-class selector
245+ (< code > .gv-container.gv-container-123</ code > ) outranks the layered defaults, so your values win without{ ' ' }
246+ < code > !important</ code > and without pinning the View ID by hand.
263247 </ p >
264248 < pre >
265- < code > { `import SD from 'style-dictionary';
266-
267- const EXT = 'com.gravitykit.tokens';
268-
269- // Use the shipped CSS variable name, not the token path.
270- SD.registerTransform({
271- name: 'name/gv-cssvar',
272- type: 'name',
273- transform: (t) => t.$extensions[EXT].cssVar.replace(/^--/, ''),
274- });
275-
276- // Style Dictionary 5.x renders DTCG duration objects as "[object Object]".
277- SD.registerTransform({
278- name: 'duration/css-dtcg',
279- type: 'value',
280- transitive: true,
281- filter: (t) => t.$type === 'duration' && typeof t.$value === 'object',
282- transform: (t) => \`\${t.$value.value}\${t.$value.unit}\`,
283- });
284-
285- const sd = new SD({
286- source: ['css-tokens.tokens.json'],
287- platforms: {
288- css: {
289- prefix: '',
290- transforms: SD.hooks.transformGroups.css
291- .map((t) => (t === 'name/kebab' ? 'name/gv-cssvar' : t))
292- .concat('duration/css-dtcg'),
293- files: [{ destination: 'gravityview-tokens.css', format: 'css/variables' }],
294- },
295- },
296- });
297- await sd.buildAllPlatforms();` } </ code >
249+ < code > { `/* In GravityView's Custom CSS field. VIEW_SELECTOR resolves to this View. */
250+ VIEW_SELECTOR { --gv-color-primary: #7a1f1f; }` } </ code >
298251 </ pre >
299252 < p >
300- Terrazzo reads the file without configuration. Its < code > core/consistent-naming </ code > rule defaults to
301- kebab-case and will warn on GravityView's snake_case leaf names; set { ' ' }
302- < code > { '{ format: "snake_case" }' } </ code > on that rule to silence it.
303- </ p >
304- < p >
305- < strong > File-level metadata does not survive either tool. </ strong > Style Dictionary drops the root { ' ' }
306- < code > $description </ code > , the root < code > $extensions </ code > manifest and every group that has no { ' ' }
307- < code > $value </ code > ; Terrazzo keeps them only on the raw parsed document, not in its token model. Per-token { ' ' }
308- < code > $extensions </ code > (including < code > cssVar </ code > ) do survive both. If you need the counts, the derived
309- list or the unrepresentable list, read them from the JSON directly rather than from a tool's output .
253+ Placeholders resolve only inside a View's Custom CSS/JavaScript field, not in your theme's stylesheet.
254+ Developers can add or change them with the { ' ' }
255+ < a href = "/gravityview/filters/gk-gravityview-custom- code-placeholders" >
256+ < code > gk/gravityview/custom-code/placeholders </ code >
257+ </ a > { ' ' }
258+ filter. See { ' ' }
259+ < a href = "https://www.gravitykit.com/docs/gravityview/customizing-your-views/adding-custom-css-to-your-website/#available-placeholders" >
260+ Adding Custom CSS to Your Website
261+ </ a > { ' ' }
262+ for the full walkthrough .
310263 </ p >
311264
312- < h3 > Tokens with no DTCG equivalent</ h3 >
313- < p >
314- DTCG has no way to express a few CSS values GravityView ships: percentage widths, < code > em</ code > lengths,{ ' ' }
315- < code > clamp()</ code > and < code > min()</ code > , < code > color-mix()</ code > , and keywords like{ ' ' }
316- < code > inherit</ code > or < code > stretch</ code > . Rather than drop them or invent a type, each appears at its
317- normal path as a group with no < code > $value</ code > , carrying its description and raw CSS under{ ' ' }
318- < code > $extensions</ code > . Token-consuming tools skip these; nothing disappears silently. They are also listed
319- together under < code > $extensions["com.gravitykit.tokens"].metadataOnly</ code > .
320- </ p >
265+ < h2 > Using the tokens as data</ h2 >
321266 < p >
322- A second group of tokens is expressible but < em > resolved</ em > . < code > --gv-font-size-xs</ code > ships as{ ' ' }
323- < code > calc(var(--gv-font-size-base) * 0.75)</ code > , which DTCG cannot represent, so the file carries{ ' ' }
324- < code > 0.75rem</ code > , its value at GravityView's defaults. Change the base font size and the browser computes
325- something different from what a Figma library synced from this file shows. Every such token says so in its{ ' ' }
326- < code > $description</ code > and is listed under{ ' ' }
327- < code > $extensions["com.gravitykit.tokens"].derivedTokens</ code > .
267+ The same tokens are published as JSON, in the{ ' ' }
268+ < a href = "https://www.designtokens.org/TR/2025.10/format/" > Design Tokens (DTCG)</ a > format, if you want to pull
269+ them into Style Dictionary, Terrazzo, Tokens Studio or Figma. See{ ' ' }
270+ < a href = "/gravityview/design-tokens/" > Design Tokens (JSON)</ a > .
328271 </ p >
329272
330273 < h2 > Token reference</ h2 >
0 commit comments