Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

html2uuitk

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html2uuitk

Converts HTML + CSS layouts into Unity UI Toolkit USS and UXML.

latest
Source
npmnpm
Version
0.3.0
Version published
Maintainers
1
Created
Source

html2uuitk

Converts HTML + CSS layouts into Unity UI Toolkit USS and UXML.

Installation

npm install -g html2uuitk

Usage

# Basic usage
npx html2uuitk --input index.html --css styles.css --output ./output

# Multiple files
npx html2uuitk -i page1.html page2.html --css base.css theme.css -o ./output

# With reset CSS and config
npx html2uuitk -i index.html --css styles.css --reset reset.css --config config.json -o ./output

Arguments

ArgumentAliasTypeRequiredDescription
--input-iarrayYesInput HTML files
--cssarrayYesCSS files to convert
--resetstringNoReset CSS file
--output-ostringYesOutput folder
--config-cstringNoConfiguration file (JSON)
--helpShow help

Features

HTML to UXML Element Mapping

HTMLUXML
div, section, nav, header, footer, main, aside, article, ul, ol, li, imgui:VisualElement
p, span, a, h1h6, label, strong, em, small, code, b, i, mark, abbr, cite, q, timeui:Label
input[type="text"], textareaui:TextField
input[type="checkbox"]ui:Toggle
input[type="radio"]ui:RadioButton
input[type="range"]ui:Slider
input[type="number"]ui:IntegerField
buttonui:Button
selectui:DropdownField
progressui:ProgressBar

Elements like script, style, head, form, svg, canvas, audio, video, and iframe are skipped. Table elements (table, tr, td, etc.) and other HTML-only elements produce warnings.

CSS to USS Property Conversion

The tool supports 73+ USS properties and handles these transformations:

Property mappings:

  • font-family-unity-font
  • text-align-unity-text-align
  • font-style-unity-font-style
  • font-weight-unity-font-style

Value mappings:

CSSUSS
text-align: left-unity-text-align: middle-left
text-align: center-unity-text-align: middle-center
text-align: right-unity-text-align: middle-right
display: block/grid/inline-*display: flex
overflow: auto/scrolloverflow: hidden
position: fixedposition: absolute
font-weight: 600+-unity-font-style: bold

Unit conversions:

  • rem/empx (base 16px)
  • vw/vh%
  • letter-spacing values are doubled for Unity
  • Leading decimals fixed: .5px0.5px
  • Modern color syntax normalized: rgb(0 0 0 / 0.5)rgba(0, 0, 0, 0.5)

Shorthand Expansion

CSS shorthands are expanded into individual USS properties:

  • margin/padding — 1 to 4 value shorthand (e.g. margin: 10px 20px → individual sides)
  • border-radius — 1 to 4 value shorthand → individual corners
  • borderborder: 1px solid #000border-width + border-color
  • fontfont: italic bold 16px/1.5 Roboto → individual font properties
  • backgroundbackground: #fff url(bg.png) no-repeat → individual background properties

Box Shadow

box-shadow: 2px 4px 8px rgba(0,0,0,0.3);

Maps to USS custom shadow properties: --unity-shadow-offset-x, --unity-shadow-offset-y, --unity-shadow-blur-radius, --unity-shadow-color.

Pseudo-Classes

Supported: :hover, :active, :focus

Unsupported pseudo-classes and pseudo-elements (::before, ::after, :nth-child(), etc.) are discarded with warnings.

CSS Variables

CSS custom properties (var()) are supported with:

  • Variable extraction from :root and other rules
  • Chain resolution (var(--a)var(--b) → final value)
  • Fallback values: var(--missing, #ff0000)
  • Circular reference detection

By default, var() references are preserved in the USS output. Enable substituteVariables in config to inline the resolved values.

Rule Deduplication

When multiple selectors map to the same USS output (e.g. h1, h2, h3 all become Label), duplicate rules are automatically deduplicated.

Configuration

The config file is optional. All options have sensible defaults.

{
    "assets": {
        "Roboto": {
            "path": "Assets/Fonts/Roboto-Regular.asset"
        }
    },
    "options": {
        "uppercase": false,
        "substituteVariables": false,
        "focusable": false
    }
}
OptionTypeDefaultDescription
uppercasebooleanfalseConvert text content to uppercase in UXML
substituteVariablesbooleanfalseReplace var() references with resolved values
focusablebooleanSet focusable attribute on input elements
assetsobject{}Map font names to Unity asset paths

Asset Mapping

Map CSS font names to Unity asset paths:

{
    "assets": {
        "Roboto": { "path": "Assets/Fonts/Roboto-Regular.asset" }
    }
}

Before:

.text { font-family: 'Roboto'; }

After:

.text { -unity-font: url("Assets/Fonts/Roboto-Regular.asset"); }

To find Unity asset paths, select the font asset in Unity's Project window and use right-click → "Copy Path".

Unsupported Properties

Properties not supported by USS (e.g. cursor) are skipped with warnings during conversion.

FAQs

Package last updated on 20 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts