Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Configure and use UnoCSS atomic CSS engine with presets like Wind (Tailwind-compatible), Icons, and Attributify.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/preset-tagify.md
1---2name: preset-tagify3description: Use utilities as HTML tag names4---56# Preset Tagify78Use CSS utilities directly as HTML tag names.910## Installation1112```ts13import { defineConfig, presetTagify } from 'unocss'1415export default defineConfig({16presets: [17presetTagify(),18],19})20```2122## Basic Usage2324Instead of:2526```html27<span class="text-red">red text</span>28<div class="flex">flexbox</div>29<span class="i-line-md-emoji-grin"></span>30```3132Use tag names directly:3334```html35<text-red>red text</text-red>36<flex>flexbox</flex>37<i-line-md-emoji-grin />38```3940Works exactly the same!4142## With Prefix4344```ts45presetTagify({46prefix: 'un-'47})48```4950```html51<!-- Matched -->52<un-flex></un-flex>5354<!-- Not matched -->55<flex></flex>56```5758## Extra Properties5960Add CSS properties to matched tags:6162```ts63presetTagify({64// Add display: inline-block to icons65extraProperties: matched => matched.startsWith('i-')66? { display: 'inline-block' }67: {},68})69```7071Or apply to all:7273```ts74presetTagify({75extraProperties: { display: 'block' }76})77```7879## Options8081```ts82presetTagify({83// Tag prefix84prefix: '',8586// Excluded tags (won't be processed)87excludedTags: ['b', /^h\d+$/, 'table'],8889// Extra CSS properties90extraProperties: {},9192// Enable default extractor93defaultExtractor: true,94})95```9697## Excluded Tags9899By default, these tags are excluded:100- `b` (bold)101- `h1` through `h6` (headings)102- `table`103104Add your own:105106```ts107presetTagify({108excludedTags: [109'b',110/^h\d+$/,111'table',112'article', // Add custom exclusions113/^my-/, // Exclude tags starting with 'my-'114],115})116```117118## Use Cases119120- Quick prototyping121- Cleaner HTML for simple pages122- Icon embedding: `<i-carbon-sun />`123- Semantic-like styling: `<flex-center>`, `<text-red>`124125## Limitations126127- Custom element names must contain a hyphen (HTML spec)128- Some frameworks may not support all custom elements129- Utilities without hyphens need the prefix option130131<!--132Source references:133- https://unocss.dev/presets/tagify134-->135