This page is part of a static HTML representation of the TiddlyWiki at https://tiddlywiki.com/

LinkWidget

7th September 2017 at 3:19pm
Widgets

The link widget generates links to tiddlers. (Use the HTML <a> element to generate external links).

Content and Attributes

AttributeDescription
toThe title of the target tiddler for the link (defaults to the current tiddler)
aria-labelOptional Accessibility label
tooltipOptional tooltip WikiText
tabindexOptional numeric tabindex
draggable"yes" to enable the link to be draggable (defaults to "yes")
tagOptional tag to override the default "a" element

The content of the link widget is rendered within the <a> tag. The draggable functionality is equivalent to using the DraggableWidget with the tiddler attribute set to the link target.

The default value of the tooltip attribute is supplied by the tv-wikilink-tooltip variable.

This means that you can control the text of a link tooltip in several ways:

<$link to="HelloThere" tooltip="Custom tooltip">Link 1</$link>

<$set name="tv-wikilink-tooltip" value="I'm a link to {{!!title}}">
<$link to="HelloThere">Link 2</$link>
</$set>

Renders as:

Link 1

Link 2

Note that the tooltip is rendered with the current tiddler set to the target of the link.

A useful convention is to set the tooltip like this:

\define tv-wikilink-tooltip()
<$transclude field="tooltip"><$transclude field="title"/></$transclude>
\end

This causes the tooltip to be the tooltip field of the target tiddler. If the field isn't present, then the title is used instead.

CSS Classes

  • tc-tiddlylink - applied to all links
  • tc-tiddlylink-external - applied to external, non-tiddler links
  • tc-tiddlylink-internal - applied to tiddler links
  • tc-tiddlylink-missing - applied to tiddler links where the target tiddler doesn't exist
  • tc-tiddlylink-resolves - applied to tiddler links when the target tiddler does exist

href generation

The following process is used to generate the href attribute of the generated HTML <a> element:

  1. If tv-get-export-link is defined it is invoked to convert the target tiddler title to the href value
  2. New in 5.1.15 If tv-filter-export-link is defined it is interpreted as a filter that converts the target tiddler title to the href value
  3. If tv-wikilink-template is defined it is treated as a specialised macro body that can perform limited conversion of the target tiddler title to the href value
  4. Otherwise, the target tiddler title is URI encoded to create the href

Configuration variables