Nasimunreleased, after 0.12.0
ComponentsActions

LinkButton

A link that looks like a button and moves inside the app through NasimProvider's router.

Since 0.1.0Client componentstable
Open alone
link-button/in-app.tsx
import { LinkButton } from '@nyxon/nasim';

const copy = { plans: 'مشاهدهٔ پلن‌ها', invoices: 'فاکتورهای من' };

// A link styled as a button. With NasimProvider's `navigate`, `href` moves inside the app.
export default function InApp() {
  return (
    <div className="flex flex-wrap gap-2">
      <LinkButton href="#plans">{copy.plans}</LinkButton>
      <LinkButton href="#invoices" variant="secondary">
        {copy.invoices}
      </LinkButton>
    </div>
  );
}

Import

import { LinkButton } from '@nyxon/nasim';

Usage

LinkButton is React Aria's Link drawn with HeroUI's button styles: it takes variant, size, fullWidth and isIconOnly as Button does, and an href. With navigate on NasimProvider (Setup) an in-app href moves through the app's router without a page load; without it, it is a plain link. An address with a scheme or a //host is never handed to the router.

<LinkButton href="/services">{t.services.all}</LinkButton>

routerOptions carries { replace?, scroll? } to the router (NasimNavigateOptions).

Examples

Inside the app

Shown above: a main and a secondary link side by side.

In a new tab

target="_blank" adds rel="noopener noreferrer", so the new page never gets this window. Say in the label that it opens a new tab.

Open alone
link-button/new-tab.tsx
import { LinkButton } from '@nyxon/nasim';

const copy = { guide: 'راهنمای اتصال (در برگهٔ تازه)' };

// target="_blank" adds rel="noopener noreferrer": the new page never gets this window.
// The label says it opens a new tab, so nobody is surprised.
export default function NewTab() {
  return (
    <LinkButton href="https://nyxon.tech" target="_blank" variant="outline">
      {copy.guide}
    </LinkButton>
  );
}

Rules

  • A control that goes somewhere is a link, not a Button with a handler that navigates: the address shows on hover, it opens in a new tab, and a screen reader calls it a link.
  • Its words come from the screen's strings module, like every label.

Accessibility

It renders an <a> with href, so it is announced as a link and Enter follows it (Space does not, as for any link). Its focus ring is the button's.

API

PropTypeDefaultDescription
hrefstring—A URL to link to. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#href).
variant"danger" | "danger-soft" | "ghost" | "outline" | "primary" | "secondary" | "tertiary"—
size"lg" | "md" | "sm"—
fullWidthboolean—
isIconOnlyboolean—
targetReact.HTMLAttributeAnchorTarget—The target window for the link. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#target).
relstring—The relationship between the linked resource and the current page. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel).
routerOptionsNasimNavigateOptions—Options for the configured client side router.
classNamestring—

LinkButton takes the rest of React Aria's Link props too.

Button (an action on the page) and NasimProvider's navigate (in-app links).

On this page