Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | 3x 3x 3x 3x 3x 3x 15x 18x 42x 385x 12458x 322331x | /**
* How the Styling Hook Index groups and labels global hooks. `design-tokens`
* has no grouping metadata yet, so this MVP config lives in the site; the copy
* comes from the Zeroheight Styling Hook Index page (headings and descriptions). Groups match on the hook name
* (minus `--slds-g-`), not `category`, so `sizing-border-*` lands under Borders.
*
* Order matters: groups render in this order and the first match wins.
*/
export type ChipId =
| 'semantic'
| 'system'
| 'palette'
| 'shadow'
| 'border'
| 'typography'
| 'spacing'
| 'sizing'
| 'motion'
| 'ratio';
/** Which columns and preview a group's table uses. */
export type HookDisplay =
| 'color'
| 'shadow'
| 'radius'
| 'border-width'
| 'font-scale'
| 'font-weight'
| 'line-height'
| 'spacing'
| 'dimension'
| 'density'
| 'value';
export interface HookGroupConfig {
/** Heading anchor. */
id: string;
chip: ChipId;
/** H2. */
section: string;
/** Optional H3 between the section and the group (Color's Semantic Styling Hooks only). */
subsection?: string;
heading: string;
description?: string;
display: HookDisplay;
match: RegExp;
}
export const CHIPS: { id: ChipId; label: string }[] = [
{ id: 'semantic', label: 'Semantic Colors' },
{ id: 'system', label: 'System Palettes' },
{ id: 'palette', label: 'Global Palettes' },
{ id: 'shadow', label: 'Shadows' },
{ id: 'border', label: 'Borders' },
{ id: 'typography', label: 'Typography' },
{ id: 'spacing', label: 'Spacing' },
{ id: 'sizing', label: 'Sizing' },
{ id: 'motion', label: 'Motion' },
{ id: 'ratio', label: 'Aspect Ratio' },
];
/** Zeroheight copy under section and subsection headings, keyed by heading text. Links use site routes. */
export const HEADING_DESCRIPTIONS: Record<string, string> = {
'Semantic Styling Hooks':
'Semantic color styling hooks define purpose rather than static values. See [Semantic Colors](/styling-api/global-styling-hooks) for more information.',
'System Palettes':
'System Palette styling hooks provide fixed, non semantic values across SLDS. To learn more about how system colors are structured and applied, see the [System Palette](/styling-api/global-styling-hooks).',
'Color Palettes':
"SLDS provides a range of accessible color palettes. These colors hold no semantic meaning and you can use them anywhere in the UI. These values don't change.",
Shadows: 'To learn more about shadows, see [Shadows](/styling-api/global-styling-hooks).',
Typography:
'Typography styling hooks define text properties, including font families, sizes, weights, and line heights. These hooks enable consistent text hierarchy across your application. See [Typography](/styling-api/global-styling-hooks) for more information.',
Spacing:
'The [spacing](/styling-api/global-styling-hooks) values create space between elements. The styling hook values are relative to the root font size and follow a modular scale of 4. For example, use them to set values for margins and padding.',
Sizing: "Use these styling hooks for elements such as icons to set their height and width relative to the root element's `font-size`.",
};
const PALETTE_HUES: [string, string][] = [
['neutral', 'Neutral'],
['blue', 'Blue'],
['cloud-blue', 'Cloud Blue'],
['electric-blue', 'Electric Blue'],
['indigo', 'Indigo'],
['purple', 'Purple'],
['violet', 'Violet'],
['red', 'Red'],
['pink', 'Pink'],
['hot-orange', 'Hot Orange'],
['orange', 'Orange'],
['yellow', 'Yellow'],
['teal', 'Teal'],
['green', 'Green'],
];
const SYSTEM_INTENTS: [string, string][] = [
['neutral', 'Neutral'],
['brand', 'Brand'],
['error', 'Error'],
['warning', 'Warning'],
['success', 'Success'],
['info', 'Info'],
];
const FEEDBACK_INTENTS: [string, string][] = [
['error', 'Error'],
['warning', 'Warning'],
['success', 'Success'],
['info', 'Info'],
['disabled', 'Disabled'],
];
export const HOOK_GROUPS: HookGroupConfig[] = [
// ── Color ──
{
id: 'surface',
chip: 'semantic',
section: 'Color',
subsection: 'Semantic Styling Hooks',
heading: 'Surface Colors',
display: 'color',
match: /^color-surface-(inverse-)?\d+$/,
},
{
id: 'on-surface',
chip: 'semantic',
section: 'Color',
subsection: 'Semantic Styling Hooks',
heading: 'On Surface',
display: 'color',
match: /^color-on-surface-/,
},
{
id: 'container',
chip: 'semantic',
section: 'Color',
subsection: 'Semantic Styling Hooks',
heading: 'Container',
display: 'color',
match: /^color-surface-container-/,
},
{
id: 'accent',
chip: 'semantic',
section: 'Color',
subsection: 'Semantic Styling Hooks',
heading: 'Accent Colors',
display: 'color',
match: /^color-(on-|border-)?accent(-container|-dark|-light)?-\d+$/,
},
{
id: 'border-color',
chip: 'semantic',
section: 'Color',
subsection: 'Semantic Styling Hooks',
heading: 'Border',
display: 'color',
match: /^color-border-(inverse-)?\d+$/,
},
...FEEDBACK_INTENTS.map(
([intent, label]): HookGroupConfig => ({
id: `feedback-${intent}`,
chip: 'semantic',
section: 'Color',
subsection: 'Semantic Styling Hooks',
heading: `${label} Colors`,
display: 'color',
match: new RegExp(`^color-(on-|border-)?${intent}(-container)?-\\d+$`),
}),
),
...SYSTEM_INTENTS.map(
([intent, label]): HookGroupConfig => ({
id: `system-${intent}`,
chip: 'system',
section: 'System Palettes',
heading: `${label} Colors`,
display: 'color',
match: new RegExp(`^color-${intent}-base-\\d+$`),
}),
),
...PALETTE_HUES.map(
([hue, label]): HookGroupConfig => ({
id: `palette-${hue}`,
chip: 'palette',
section: 'Color Palettes',
heading: label,
display: 'color',
match: new RegExp(`^color-palette-${hue}-\\d+$`),
}),
),
// ── Shadows ──
{
id: 'shadow-elevation',
chip: 'shadow',
section: 'Shadows',
heading: 'Elevation',
display: 'shadow',
match: /^shadow-\d+$/,
},
{
id: 'shadow-directional',
chip: 'shadow',
section: 'Shadows',
heading: 'Directional Elevation',
display: 'shadow',
match: /^shadow-(block|inline)-?(start|end)-\d+$/,
},
{
id: 'shadow-focus',
chip: 'shadow',
section: 'Shadows',
heading: 'Focus and Inverse',
display: 'shadow',
match: /^shadow-(inset|insetinverse|inset-inverse|outset|outline)-focus-\d+$|^shadow-inverse-\d+$/,
},
// ── Borders ──
{
id: 'border-width',
chip: 'border',
section: 'Borders',
heading: 'Border Width',
description: 'Use these styling hooks to specify the pixel width of a border.',
display: 'border-width',
match: /^sizing-border-/,
},
{
id: 'border-radius',
chip: 'border',
section: 'Borders',
heading: 'Border Radius',
description: 'These styling hooks control the corner curvature of UI elements.',
display: 'radius',
match: /^radius-border-/,
},
// ── Typography ──
{
id: 'font-family',
chip: 'typography',
section: 'Typography',
heading: 'Font Family',
display: 'value',
match: /^font-family/,
},
{
id: 'font-scale',
chip: 'typography',
section: 'Typography',
heading: 'Font Scale',
description:
'Font sizes scale from the `--slds-g-font-scale-base` property, which sets the default font size of the application.',
display: 'font-scale',
match: /^font-(scale-(neg-)?\d+|scale-base|size-base)$/,
},
{
id: 'font-scale-density',
chip: 'typography',
section: 'Typography',
heading: 'Density-Aware Font Scale',
description:
'These density-aware styling hooks control the font scale when the display switches between comfy and compact display density settings. To learn how display density works in SLDS, see [Display Density](/visual-language/display-density).',
display: 'value',
match: /^font-scale-var-/,
},
{
id: 'font-weight',
chip: 'typography',
section: 'Typography',
heading: 'Font Weight',
description: 'Font weights are available in a range where `--slds-g-font-weight-4` is the default weight.',
display: 'font-weight',
match: /^font-weight-/,
},
{
id: 'line-height',
chip: 'typography',
section: 'Typography',
heading: 'Line Height',
description:
'Line height values are unitless numbers, which are multiplied by the font size used in the element to obtain the desired line height.',
display: 'line-height',
match: /^font-line-?height-(\d+|base)$/,
},
{
id: 'line-height-density',
chip: 'typography',
section: 'Typography',
heading: 'Density-Aware Line Height',
description:
'This density-aware styling hook controls the line height when the display switches between comfy and compact display density settings. To learn how display density works in SLDS, see [Display Density](/visual-language/display-density).',
display: 'value',
match: /^font-line-?height-var-base$/,
},
{
id: 'typography-other',
chip: 'typography',
section: 'Typography',
heading: 'Other Typography',
display: 'value',
match: /^font-(scale-ratio|line-clamp)$/,
},
// ── Spacing ──
{
id: 'spacing',
chip: 'spacing',
section: 'Spacing',
heading: 'Spacing',
display: 'spacing',
match: /^spacing-\d+$/,
},
{
id: 'spacing-density',
chip: 'spacing',
section: 'Spacing',
heading: 'Density-Aware Spacing',
description:
'These density-aware styling hooks control spacing that\'s applied equally to all sides of an element when the display switches between comfy and compact display density settings. The spacing corresponds to the top, bottom, left, and right margins or padding. To learn how display density works in SLDS, see [Display Density](/visual-language/display-density).',
display: 'density',
match: /^spacing-var-\d+$/,
},
{
id: 'spacing-density-block',
chip: 'spacing',
section: 'Spacing',
heading: 'Density-Aware Vertical Spacing',
description:
'These density-aware styling hooks control spacing along the vertical (block) axis when the display switches between comfy and compact display density settings. This spacing corresponds to the top and bottom margins or paddings. To learn how display density works in SLDS, see [Display Density](/visual-language/display-density).',
display: 'density',
match: /^spacing-var-block-/,
},
{
id: 'spacing-density-inline',
chip: 'spacing',
section: 'Spacing',
heading: 'Density-Aware Horizontal Spacing',
description:
'These density-aware styling hooks control spacing along the horizontal (inline) axis when the display switches between comfy and compact display density settings. This spacing corresponds to left and right margins or paddings. To learn how display density works in SLDS, see [Display Density](/visual-language/display-density).',
display: 'density',
match: /^spacing-var-inline-/,
},
// ── Sizing ──
{
id: 'sizing',
chip: 'sizing',
section: 'Sizing',
heading: 'Sizing',
display: 'dimension',
match: /^sizing-(\d+|base)$/,
},
{
id: 'sizing-content',
chip: 'sizing',
section: 'Sizing',
heading: 'Content Width',
display: 'value',
match: /^sizing-(content|heading)-/,
},
// ── Motion ──
{
id: 'duration',
chip: 'motion',
section: 'Motion',
heading: 'Duration',
display: 'value',
match: /^duration-/,
},
// ── Aspect Ratio ──
{
id: 'ratio',
chip: 'ratio',
section: 'Aspect Ratio',
heading: 'Aspect Ratio',
display: 'value',
match: /^ratio-/,
},
];
/** Anchor id for a section or subsection heading: `Semantic Colors` → `semantic-colors`. */
export function headingId(text: string): string {
return text.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '');
}
/** The group a global hook (`--slds-g-…` or `slds-g-…`) belongs to, if any. */
export function groupForHook(hook: string): HookGroupConfig | undefined {
const name = hook.replace(/^(--)?slds-g-/, '');
return HOOK_GROUPS.find((g) => g.match.test(name));
}
|