Skip to content

自动补齐

¥Autocomplete

可以针对 在线运行VS Code 扩展 中的 UnoCSS 智能建议自定义自动补齐功能。

¥Autocomplete can be customized for UnoCSS's intelligent suggestions in playground and the VS Code extension.

ts
autocomplete: {
  templates: [
    // theme inferring
    'bg-$color/<opacity>',
    // short hands
    'text-<font-size>',
    // logic OR groups
    '(b|border)-(solid|dashed|dotted|double|hidden|none)',
    // constants
    'w-half',
  ],
  shorthands: {
    // equal to `opacity: "(0|10|20|30|40|50|60|70|90|100)"`
    'opacity': Array.from({ length: 11 }, (_, i) => i * 10),
    'font-size': '(xs|sm|base|lg|xl|2xl|3xl|4xl|5xl|6xl|7xl|8xl|9xl)',
    // override built-in short hands
    'num': '(0|1|2|3|4|5|6|7|8|9)',
  },
  extractors: [
      // ...extractors
  ],
}
  • templates 使用简单的 DSL 来指定自动补齐建议。

    ¥templates uses a simple DSL to specify the autocomplete suggestions.

  • shorthands 是速记名称与其模板的映射。如果是 Array,那么它将是一个逻辑 OR 组。

    ¥shorthands is a map of shorthand names to their templates. If it's a Array, it will be a logic OR group.

  • extractors 选取可能的类并将类名样式建议转换为正确的格式。例如,你可以查看我们如何实现 属性自动补齐提取器

    ¥extractors to pickup possible classes and transform class-name style suggestions to the correct format. For example, you could check how we implement the attributify autocomplete extractor

  • 如需其他帮助,请参阅 此处

    ¥For additional help, please refer to here.