Skip to content
Cynosurev0.5.0
SearchStorybookGitHubnpmColour mode: System. Switch to Light

Components / Foundations

LinkBase

The native <a> for Cynosure, and the only module allowed to render one. It is a foundation: it adds safe link behaviour and no styling.

Who uses itLink to "Who uses it"

Link and Card (when it navigates), and any composite that navigates.

When to use it directlyLink to "When to use it directly"

Only when building a new composite that navigates and needs a native anchor.

Use a component instead when you want a link in content: Link. For an action that does not navigate, use Button.

Opens external links safely

UsageLink to "Usage"

tsx
Copy
import { LinkBase } from "@arshad-shah/cynosure";

<LinkBase className="my-link" href="/docs">Docs</LinkBase>
<LinkBase href="https://example.com" target="_blank">Example</LinkBase>

<LinkBase href="javascript:alert(1)">Dropped</LinkBase> // renders <a> with no href

PropsLink to "Props"

It accepts every native anchor attribute.

GuaranteesLink to "Guarantees"

  • New tabs: with target="_blank", rel gets noopener noreferrer added after any rel you pass.
  • Safe schemes only: href is checked by safeHref (internal to LinkBase). Relative, hash and query URLs, and http, https, mailto and tel are linked. Anything else, including javascript:, is dropped and the anchor gets no href.
  • Parsed like a browser: safeHref strips tab and newline characters anywhere and leading control characters before checking, so obfuscated javascript: URLs cannot slip through. An unparseable absolute URL is dropped.
  • The ref reaches the native <a>.

Link · Button

These examples run Cynosure 0.5.0 (commit 50ce30b), the version on npm.

Getting started
Theming
Icons
Accessibility
Code editors and highlighters
Using Cynosure without React
Build-tool adapters
Components
Accordion
AppShell
AspectRatio
Breadcrumbs
Calendar
Card
Container
Disclosure
Divider
DocumentViewport
Grid
Inline
PageHeader
PanZoomCanvas
ScrollArea
SideNav
SortableList
SplitPane
Stack
StatusBar
Tabs
TitleBar
Toolbar
Tree
VirtualList
ZoomControls
Announcer
Avatar
Badge
CodeBlock
DescriptionList
EmptyState
ErrorBoundary
Field
Heading
IconTile
Image
Kbd
List
LoadingDots
Notice
ProgressBar
Prose
Skeleton
Stat
Steps
Table
Text
Button
Checkbox
Checklist
ColorField
ColorSwatches
Combobox
CompareSlider
CopyButton
DateField
FileDrop
IconButton
KeyValueEditor
Link
NumberField
Pagination
PathField
RadioGroup
SearchField
SegmentedControl
Select
SelectionFrame
SignaturePad
Slider
Switch
TagInput
TextArea
TextField
ThemeToggle
TimeField
ButtonBase
ChoiceBase
DialogBase
FileInputBase
HiddenValue
Icon
InputBase
LinkBase
LiveRegion
TextAreaBase
ChatMessage
Choice
DataGrid
DeviceFrame
HighlightedText
HotkeyField
ListRow
OptionList
OverlayFrame
QRCode
RowActions
Section
SiteFooter
SiteHeader
SkipLink
SortButton
VisuallyHidden
CommandPalette
ContextMenu
Dialog
FloatingToolbar
HoverCard
Menu
Menubar
Popover
ProgressOverlay
Sheet
Toast
Tooltip
Changelog