CellLink
A link for table cells that renders a real href but never navigates on its own — the host decides how to open it.
CellLink
Basic Usage
CellLink
Two underline strategies
Clicking navigates nothing; it hands the host an open event.
Loading demo...
Why It Does Not Navigate
The component renders a genuine <a href> — copy-link, hover preview, and the context menu all work — but calls preventDefault() on click and emits open instead.
This is not fastidiousness. tuffex ships into both the browser and the Electron renderer, and inside the renderer a self-navigating link walks the application window away from itself, which is a real security and usability problem. Handing the decision to the host is what lets one component behave correctly in both. TxSources established this convention already, and this component follows it.
API
Props
| Prop | Type | Default | Description |
|---|---|---|---|
href | string | - | Target URL, written into the real href attribute |
label | string | href | Visible text; falls back to the href |
external | boolean | false | Appends the outbound arrow glyph |
muted | boolean | false | Uses the secondary ink instead of the link accent, for record-name columns |
underline | 'always' | 'hover' | 'hover' | Underline strategy |
ariaLabel | string | - | Accessible name for when the visible text does not describe the destination |
Events
| Event | Payload | Description |
|---|---|---|
open | ({ href, event }) | Fires on click; the component has already called preventDefault(), so navigation is the host's call |
Slots
| Name | Description |
|---|---|
default | Replaces the link text |
Interaction Contract
- It renders a native
<a>, so pressing Enter firesopentoo — no extra handling required. underline="hover"shows the rule only on hover and:focus-visible, which suits columns whose text is the primary content anyway.underline="always"keeps a permanent rule tinted to 35%, going solid on hover — right for a dedicated link column, where a full column of solid underlines turns into a block of rules.- The outbound arrow is
aria-hiddenand never announced; put the destination information inariaLabel. - Long text truncates with an ellipsis, so a link cannot blow out its cell.
Best Practices
- When the text is a bare domain, add an
ariaLabelsuch as "Open the Aurora Scoops website" — otherwise a screen reader just spells out a hostname. - Use
mutedwithunderline="hover"for record-name columns, and the default colour withunderline="always"for dedicated link columns. - In the Electron renderer, route the
openevent through the host's external-browser channel rather than opening a window in the renderer. - For a cell with no link, render a placeholder such as
—rather than aTxCellLinkwith an emptyhref.
Source
- Component source:
packages/tuffex/packages/components/src/cell-link/src/TxCellLink.vue. - Types:
packages/tuffex/packages/components/src/cell-link/src/types.tsexportsCellLinkProps,CellLinkEmits, andCellLinkUnderline. - Test coverage:
packages/tuffex/packages/components/src/cell-link/__tests__/cell-link.test.tshas 6 cases covering the native anchor and itshref, the label fallback,openemission afterpreventDefault()(assertingdefaultPrevented), conditional rendering andaria-hiddenon the arrow, the underline and muted state classes, and the accessible-name override.
查看源码
packages/tuffex/packages/components/src/cell-link/index.ts