Navigation
Anchor
Display links with Hope UI styling features.
Import
tsximport { Anchor } from "@hope-ui/core";
tsximport { Anchor } from "@hope-ui/core";
Usage
tsx<Anchor href="/">Hope UI</Anchor>
tsx<Anchor href="/">Hope UI</Anchor>
External link
Use the isExternal prop to open the link in a new tab.
tsx<Anchor href="https://hope-ui.com" isExternal>Hope UI <ExternalLinkIcon /></Anchor>
tsx<Anchor href="https://hope-ui.com" isExternal>Hope UI <ExternalLinkIcon /></Anchor>
Usage with routing library
Pass the as prop to Anchor to replace the rendered a tag with the router's link component.
tsximport { Link } from "@solidjs/router";<Anchor as={Link} href="/">Home</Anchor>;
tsximport { Link } from "@solidjs/router";<Anchor as={Link} href="/">Home</Anchor>;
Theming
Use the AnchorTheme type to override Anchor styles and default props when extending Hope UI theme.
tsximport { extendTheme, AnchorTheme } from "@hope-ui/core";const theme = extendTheme({components: {Anchor: {// ...overrides} as AnchorTheme,},});
tsximport { extendTheme, AnchorTheme } from "@hope-ui/core";const theme = extendTheme({components: {Anchor: {// ...overrides} as AnchorTheme,},});
Component parts
| Name | Static selector | Description |
|---|---|---|
| root | hope-Anchor-root | Root element |
Props
| Name | Type | Description |
|---|---|---|
| isExternal | boolean | Whether the link should be opened in a new tab. |