Icon
One SVG mark drawn from a path definition, decorative by default and named when it carries meaning.
Usage
An Icon has no catalog of names: assign an IconDefinition to its icon property. In an app you import one definition module, such as @tweakpad/ui/icons/plus, so only the artwork you use is bundled. The examples here inline their definitions.
The register/icon entry registers only tp-icon, while register opts into every component. The main entry exports the TpIcon class and IconDefinition type but does not re-export artwork.
Meaning
Without label an Icon is decorative and hidden from assistive technology, which is right when text beside it already says the same thing. A non-empty label gives it role="img" and an accessible name, for the case where the icon is the only signal.
Size and color
size takes any CSS length and sets a square extent; without it the Icon uses the theme’s medium icon size. The artwork strokes with currentColor, so it follows the surrounding text color.
The default theme uses the shared medium icon extent (1rem, normally 16 CSS pixels). Small icons use 0.875rem; large icons use 1.25rem. These extents derive from the rem-based --tp-spacing seed, so changing the theme’s root spacing seed keeps them proportional. Override the icon-size roles directly for a scoped icon scale. Explicit size still overrides the shared extent; hit targets are unchanged.
Custom artwork
A definition is a viewBox and a list of paths, never an HTML string, so your own marks render on the same path as the library’s. Paths default to a 2-unit currentColor stroke with no fill; set fill: 'currentColor' and stroke: 'none' for solid shapes.
Media icons
@tweakpad/ui/icons/media offers the media-control set as 24×24 outline artwork with the same 2-unit stroke as the single-icon modules. Each definition is a separate named export, so importing one keeps the others out of a bundled build:
The grouped mediaIcons object (keys below) is for layouts that use the whole set; importing it includes every media definition. MediaIconName is the union of its keys.
playplayIconpausepauseIconreplayreplayIconvolumeHighvolumeHighIconvolumeLowvolumeLowIconvolumeOffvolumeOffIconcaptionsOncaptionsOnIconcaptionsOffcaptionsOffIconfullscreenEnterfullscreenEnterIconfullscreenExitfullscreenExitIconpipEnterpipEnterIconpipExitpipExitIconseekForwardseekForwardIconseekBackwardseekBackwardIconspeedspeedIconqualityqualityIconaudioaudioIconsettingssettingsIconicons/settingscastcastIconairplayairplayIconliveliveIconcheckcheckIconicons/checksettingsIcon (@tweakpad/ui/icons/settings) is also the settings entry of navigationIcons.
File icons
@tweakpad/ui/icons/upload-cloud exports uploadCloudIcon, the upload mark of File upload and the cloud entry of @tweakpad/ui/icons/empty-state. @tweakpad/ui/icons/image exports imageIcon (an image file) beside imageOffIcon (an image that could not load); @tweakpad/ui/icons/file-text exports fileTextIcon for other files.
Text editing icons
Rich-text toolbars, menus and popovers can use these 24×24 outline definitions, drawn with the same 2-unit stroke as the single-icon modules. Each is a separate named export, so importing one keeps the others out of a bundled build:
@tweakpad/ui/icons/text-formattingboldIcon, italicIcon, underlineIcon, strikethroughIcon, codeIcon, superscriptIcon, subscriptIcon, highlighterIcon, baselineIcon, removeFormattingIcon@tweakpad/ui/icons/text-blocksheading1Icon, heading2Icon, heading3Icon, pilcrowIcon, bulletListIcon, orderedListIcon, taskListIcon, quoteIcon, codeBlockIcon, calloutIcon, embedIcon@tweakpad/ui/icons/text-aligntextAlignLeftIcon, textAlignCenterIcon, textAlignRightIcon, textAlignJustifyIcon@tweakpad/ui/icons/linklinkIcon, unlinkIcon, cornerDownLeftIcon@tweakpad/ui/icons/table-editingtableIcon, insertRowAboveIcon, insertRowBelowIcon, insertColumnLeftIcon, insertColumnRightIcon, mergeCellsIcon, splitCellIcon, headerRowIcon, headerColumnIcon, paintBucketIcon, clearCellsIcon@tweakpad/ui/icons/arrowsarrowUpIcon, arrowDownIcon, arrowLeftIcon, arrowRightIcon@tweakpad/ui/icons/ellipsisellipsisVerticalIcon@tweakpad/ui/icons/image-plusimagePlusIcon@tweakpad/ui/icons/at-signatSignIcon@tweakpad/ui/icons/banbanIconThe text-alignment and column icons are physical: in a right-to-left editor, start alignment shows textAlignRightIcon and a column inserted before the current one shows insertColumnRightIcon. The horizontal ellipsis is the more entry of navigationIcons (@tweakpad/ui/icons/navigation). @tweakpad/ui/icons/text-formatting also exports bookmarkIcon and filledBookmarkIcon. Editing surfaces reuse undoIcon, redoIcon, imageIcon, trashIcon, copyIcon, copyPlusIcon, minusIcon, plusIcon, gripVerticalIcon, chevronDownIcon, checkIcon and externalLinkIcon from their own modules, such as @tweakpad/ui/icons/undo.
API Reference
Every element also accepts motion-policy.
Attributes
labellabelstring''sizesizestring''Properties
iconIconDefinition | undefined@tweakpad/ui/icons/plus, or your own.partPresentationPartPresentation{}presentationControllerread-onlynew PresentationController(this)partPresentation to this Icon's parts.CSS parts
::part(icon-graphic)Related
Components, widgets and patterns that use this one.