Skip to content
Ginga UI
Ginga UI
日本語

Getting started

  • Overview
  • Quick start
  • Theme generation
  • Custom rendering
  • All components

Forms

  • Button
  • Checkbox
  • Input
  • Radio
  • Questionnaire
  • SegmentedControl
  • Select
  • ComboBox
  • NumberField
  • SearchField
  • Slider
  • Switch
  • FormControl

Display

  • Accordion
  • Alert
  • AlertDialog
  • Badge
  • CodeBlock
  • Card
  • Dialog
  • Drawer
  • Image
  • List
  • Popover
  • Menu
  • Tooltip
  • Table
  • Tab
  • Toast
  • Trace

Typography

  • Heading
  • Paragraph

Navigation

  • Anchor

Layout

  • Box

Resources

  • Changelog
  • GitHub (opens in a new tab)

Logo: Twemoji (opens in a new tab) (CC-BY 4.0)

Anchor

An anchor component for creating links.

View in Storybook (opens in a new tab)

Installation

import { Anchor } from "@ginga-ui/core";

Basic usage

A simple link example.

Click the link
anchor.tsx
import { Anchor } from "@ginga-ui/core";

export function BasicExample() {
  return <Anchor href="https://example.com">Click the link</Anchor>;
}

External link

Opens a link to an external site in a new tab.

Open on GitHub (new tab)
anchor.tsx
import { Anchor } from "@ginga-ui/core";

export function ExternalExample() {
  return (
    <Anchor href="https://github.com/newt239/ginga-ui" target="_blank">
      Open on GitHub (new tab)
    </Anchor>
  );
}

Disabled

Use the disabled prop to disable the link.

Regular linkDisabled link
anchor.tsx
anchor.module.css
import { Anchor } from "@ginga-ui/core";
import styles from "./anchor.module.css";

export function DisabledExample() {
  return (
    <div className={styles.linkStack}>
      <Anchor href="https://example.com">Regular link</Anchor>
      <Anchor href="https://example.com" disabled>
        Disabled link
      </Anchor>
    </div>
  );
}

Button style

Use variant="button" to make the link look like a button. buttonVariant and size accept the same variants and sizes as Button.

FilledLightOutlineGhost
anchor.tsx
anchor.module.css
import { Anchor } from "@ginga-ui/core";
import styles from "./anchor.module.css";

export function ButtonVariantExample() {
  return (
    <div className={styles.buttonRow}>
      <Anchor href="https://example.com" variant="button">
        Filled
      </Anchor>
      <Anchor href="https://example.com" variant="button" buttonVariant="light">
        Light
      </Anchor>
      <Anchor
        href="https://example.com"
        variant="button"
        buttonVariant="outline"
      >
        Outline
      </Anchor>
      <Anchor href="https://example.com" variant="button" buttonVariant="ghost">
        Ghost
      </Anchor>
    </div>
  );
}

Router link

Pass a function to render to draw the link with another component such as next/link. Pass the received props, including ref, to an a element.

Go to components
anchor.tsx
import { Anchor } from "@ginga-ui/core";
import NextLink from "next/link";

export function RouterLinkExample() {
  return (
    <Anchor href="/components" render={(props) => <NextLink {...props} />}>
      Go to components
    </Anchor>
  );
}

Props

Anchor

NameTypeDefaultDescription
variant"default" | "button""default"Appearance of the link. "button" makes it look like a Button.
buttonVariant"filled" | "light" | "outline" | "ghost" | "reverse""filled"Button variant used when variant is "button".
size"sm" | "md" | "lg""md"Button size used when variant is "button".
disabledbooleanfalseDisables the link.
startIconReactNode-Icon shown before the label when variant is "button".
endIconReactNode-Icon shown after the label when variant is "button".
render(props, renderProps) => ReactElement-Replaces the root element, such as with next/link. It is used only when href is set.

Also accepts the props of React Aria's Link (opens in a new tab).