The links of one item to others, for a side rail: blockers, related issues, docs that mention it. Rows show a status, a key and a title on a thin guide line, long groups fold behind Show N more, and your app brings the data and the add form.
On this page
- Issue sidebar
- Doc backlinks
- Blockers and dependencies
- Linked decisions
Examples
A doc's backlinks
Nothing linked yet
A long list
In a 240px rail
When a blocker is done
This is the default pattern: when a blocker is done, move it from Blocked by to Related and mark it done, so Blocked by only holds open work and hides once it is empty. The component never moves links by itself; moveResolved does it for you before you pass the groups. The first demo does this: API-77 is done, so it sits under Related. Turn off Blocker done to see it back under Blocked by.
Heading and group labels
Keep the heading apart from the group labels. The default heading is Links, so a group can be called Related. A heading of Related over a group called Related gives two names that read the same, and a screen reader hears the same name twice. In development the component warns in the console when a group label equals the heading.
Installation
npx knowns-ui@latest add related-linksPaste this into your coding agent (Claude Code, Cursor, Codex). It checks your project, sets up the registry, runs the install and verifies it.
Install Related Links from Knowns UI into this project. Work step by step, show me each change, and ask before you edit files outside this project.
Context: Knowns UI (https://ui.knowns.dev) is a shadcn registry. Items land in the project as source files. Docs: https://ui.knowns.dev/docs/related-links
1. Check the project first. Stop and tell me if any of these is missing:
- React 19 and Tailwind CSS v4.
- A components.json at the project root. If there is none, ask me before running `npx knowns-ui@latest init --no-key` (it runs shadcn init when needed, then adds the registries).
2. Run:
```bash
npx knowns-ui@latest add related-links
```
It writes these files:
- lib/knowns/run.ts
- lib/knowns/json.tsx
- lib/knowns/status.ts
- lib/knowns/tone.ts
- lib/knowns/types.ts
- lib/knowns/use-abortable.ts
- lib/knowns/utils.ts
- components/ui/knowns/spinner.tsx
- components/ui/knowns/button.tsx
- lib/knowns/motion.tsx
- lib/knowns/motion-utils.ts
- components/ui/knowns/related-links.tsx
- components/ui/knowns/related-links-utils.ts
and installs these npm packages: clsx@^2.1.1, tailwind-merge@^3.7.0, class-variance-authority@^0.7.1.
3. While it runs:
- It also adds a few @keyframes (all named kn-*) to the global CSS file (globals.css or the file components.json points at). Let it: they only add animations.
- If it asks to overwrite files under lib/knowns/: these are shared by every Knowns UI item. List them, say whether I changed them (check git), and ask me before you answer.
- If it asks to overwrite any other file, show me the diff and ask me.
4. Verify:
- Every file in the list above exists.
- The project type-checks (for example `npx tsc --noEmit`) and the dev build has no new errors.
5. Use it: follow the examples and props on https://ui.knowns.dev/docs/related-links, and ask me if anything about my data is unclear.
If the Knowns UI MCP server is connected (https://ui.knowns.dev/docs/ai-and-mcp), use get_component({ name: "related-links" }) or search_docs for details.
Finish with a short summary: the files you added or changed, the packages you installed, and anything I still need to do.Props
- groups
{ id, label, tone?, items, limit? }[]- The groups in order. A group with no items is hidden.
- groups[].tone
"default"|"attention"|"muted"- Default
"default" - Attention for blockers (amber label and guide line), muted for done links.
- items[]
{ id, title, href, key?, status?, statusLabel?, kind?, kindLabel?, done?, removeLabel?, removable? }- One row. status and kind are decorative slots; statusLabel and kindLabel are read out.
- heading
ReactNode- Default
"Links" - The heading over the groups.
- headingLevel
2|3|4- Default
3 - Its level in your page.
- action
ReactNode- End of the header, such as an Open in graph icon link.
- limit
number- Default
5 - Rows per group before Show N more. One extra row never hides behind a button.
- expanded / onExpandedChange
string[] / (ids) => void- Controlled ids of the groups that show every row.
- onOpen
(item, group, e) => void- A row was clicked. Call e.preventDefault() to route in your app.
- renderLink
(props) => ReactNode- Your router's link instead of an anchor; pass every prop through.
- onRemove
(item, group) => void- Shows a remove button per row. Remove the item from groups; focus moves to the next row.
- renderAdd
({ close }) => ReactNode- Your add form, opened by the Add link button. close() returns focus to the button.
- addLabel
string- Default
"Add link" - The add button's words.
- addOpen / onAddOpenChange
boolean / (open) => void- Controlled open state of the add form.
- items[].removable
boolean- Default
true - False hides the remove button on that row, for links the viewer cannot remove: inbound links, text mentions. Only matters with onRemove.
- footer
ReactNode- Under the groups: refs not found yet, a truncation note, a remove error. Shown even when every group is empty.
- readOnly
boolean- Default
false - No add button and no remove buttons. With nothing linked, nothing renders.
- moveResolved
(groups, { from, to, isResolved }) => groups- Helper for the resolved pattern: moves resolved items to the top of another group, marked done.
| Prop | Type | Default | Description |
|---|---|---|---|
| groups | { id, label, tone?, items, limit? }[] | - | The groups in order. A group with no items is hidden. |
| groups[].tone | "default" | "attention" | "muted" | "default" | Attention for blockers (amber label and guide line), muted for done links. |
| items[] | { id, title, href, key?, status?, statusLabel?, kind?, kindLabel?, done?, removeLabel?, removable? } | - | One row. status and kind are decorative slots; statusLabel and kindLabel are read out. |
| heading | ReactNode | "Links" | The heading over the groups. |
| headingLevel | 2 | 3 | 4 | 3 | Its level in your page. |
| action | ReactNode | - | End of the header, such as an Open in graph icon link. |
| limit | number | 5 | Rows per group before Show N more. One extra row never hides behind a button. |
| expanded / onExpandedChange | string[] / (ids) => void | - | Controlled ids of the groups that show every row. |
| onOpen | (item, group, e) => void | - | A row was clicked. Call e.preventDefault() to route in your app. |
| renderLink | (props) => ReactNode | - | Your router's link instead of an anchor; pass every prop through. |
| onRemove | (item, group) => void | - | Shows a remove button per row. Remove the item from groups; focus moves to the next row. |
| renderAdd | ({ close }) => ReactNode | - | Your add form, opened by the Add link button. close() returns focus to the button. |
| addLabel | string | "Add link" | The add button's words. |
| addOpen / onAddOpenChange | boolean / (open) => void | - | Controlled open state of the add form. |
| items[].removable | boolean | true | False hides the remove button on that row, for links the viewer cannot remove: inbound links, text mentions. Only matters with onRemove. |
| footer | ReactNode | - | Under the groups: refs not found yet, a truncation note, a remove error. Shown even when every group is empty. |
| readOnly | boolean | false | No add button and no remove buttons. With nothing linked, nothing renders. |
| moveResolved | (groups, { from, to, isResolved }) => groups | - | Helper for the resolved pattern: moves resolved items to the top of another group, marked done. |
Accessibility
- The whole thing is a section named by its heading. Each group is a group named by its label, with its rows in a list.
- Each row is one link, read as "key title, status, kind". The status glyph and kind icon are decorative, so the words come from statusLabel and kindLabel and nothing is read twice. Status is never told by colour alone.
- Rows with removable false have no remove button at all, so the tab order skips nothing that does not work. The remove button follows its row in the tab order with its own name ("Remove API-77 from Blocked by"). It shows on hover and focus, and always on touch screens. After a removal, focus goes to the row that took its place, then the next group, then the add button.
- Show N more and Add link are buttons with aria-expanded and aria-controls. Escape inside the add form closes it, and focus returns to Add link however the form closes.
- Keep group labels different from the heading (the default heading is Links); the component warns in development when one is the same. Pick group labels that differ in their first word ("Blocked by", "Related"), not two near-identical ones: people scan the first word.
What it handles
- 01Groups links by relation, each with a label and a tone: blockers stand out in amber, done links fade a step. A group with no links is not shown.
- 02Draws each row as one link: the app's status glyph, the key, the title cut to fit, and a kind icon, on a thin guide line under the group label.
- 03Shows the first five rows of a long group and a Show N more button for the rest.
- 04Gives each row a remove button with a name of its own, or none on rows the viewer cannot remove, and moves focus to the next row once the app has removed it.
- 05Shows a footer under the groups for notes such as refs not found yet or a remove error, even with nothing linked.
- 06Opens the app's own add form under a quiet Add link button, and puts focus back on the button when the form closes.
States
- First render
- Nothing moves
- none
- Hover on a row
- The row fills a step; the remove button fades in over the kind icon
- 120ms, ease out
- Show N more
- The rest of the rows fold open
- 180ms open, 120ms close, ease out
- Add form
- Appears under the button at once
- none
- Touch screen
- Rows are 36px high and the remove button always shows
- none
- Reduced motion
- Everything changes at once
- 0ms
| State | What moves | Timing |
|---|---|---|
| First render | Nothing moves | none |
| Hover on a row | The row fills a step; the remove button fades in over the kind icon | 120ms, ease out |
| Show N more | The rest of the rows fold open | 180ms open, 120ms close, ease out |
| Add form | Appears under the button at once | none |
| Touch screen | Rows are 36px high and the remove button always shows | none |
| Reduced motion | Everything changes at once | 0ms |
Works with
When to use
When to use
- The links of an issue, task or doc in its side rail: what blocks it, what it blocks, related items and backlinks.
- A short list of linked items with a status and a key, where people add and remove links.
When not to use
- One linked issue at the end of a row: use Issue Chip.
- A full list of tasks grouped by status: use Grouped List.
Using with AI
Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:
- Add the Knowns UI Related Links to my app and wire it to my own data.
- I need the links of an issue, task or doc in its side rail: what blocks it, what it blocks, related items and backlinks. Set that up with the Knowns UI Related Links.
- Which Related Links props do I need for a minimal setup? Show me a short example.
With the server connected, your assistant calls get_component({ name: "related-links" }) and search_docs({ query: "related links" }).