NavigationPhoneLink
Searchastronomic.dev# PhoneLink
For a phone number people tap to call, such as in the header: the label over the number, or an icon on a phone.
Static: no JavaScript.
## Usage
```astro
import PhoneLink from "@astronomic-dev/ui/components/PhoneLink.astro";
```
## Examples
### Label and number
Your phone icon in the accent, then the label in small capitals over the number in even-width figures. A pill at least 44px tall that calls the number.
```astro
---
import PhoneLink from "@astronomic-dev/ui/components/PhoneLink.astro";
import Phone from "@lucide/astro/icons/phone";
import { plumbing } from "../_data/groundcrew.ts";
---
<!-- Brassfield Plumbing & Drain's main line: the label over the number. -->
<PhoneLink number={plumbing.phone} label="Call us" icon={Phone} />
```
### Urgent
urgent puts the icon in an accent mark, for an emergency line. With text, shorter words show in place of the number, and the number stays in the link's name.
```astro
---
import PhoneLink from "@astronomic-dev/ui/components/PhoneLink.astro";
import Siren from "@lucide/astro/icons/siren";
import { plumbing } from "../_data/groundcrew.ts";
const line = plumbing.emergency?.phone ?? plumbing.phone;
---
<!-- The after-hours line: the icon in an accent mark, and shorter words in place of the number. -->
<div class="flex flex-wrap items-center gap-4">
<PhoneLink number={line} label="24/7 emergency" icon={Siren} urgent />
<PhoneLink number={line} text="24/7 emergency" icon={Siren} urgent />
</div>
```
### Icon only on a phone
iconOnlyBelow="md": below the md fold point the words hide and the icon shows in a 44px round link, with the same name. In a frame, so the fold point is real.
```astro
---
import PhoneLink from "@astronomic-dev/ui/components/PhoneLink.astro";
import Phone from "@lucide/astro/icons/phone";
import { construction } from "../_data/groundcrew.ts";
---
<!-- Sixpenny Builders: below the md fold point only the icon shows, in a 44px round link with the same name. -->
<PhoneLink number={construction.phone} label="Call us" icon={Phone} iconOnlyBelow="md" />
```
## Props
### PhoneLink
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `number` | `string` | None | Required. The number as the page shows it, such as "(555) 010-0142". The link calls it (a tel: link). A value with fewer than 3 digits renders nothing. |
| `label` | `string` | None | Small words over the number, such as "Call us" or "24/7 emergency". Part of the accessible name. |
| `text` | `string` | None | Shorter visible words in place of the number, such as "24/7". The number stays in the accessible name. |
| `icon` | `IconComponent` | None | Required. Your phone icon, before the words. Below iconOnlyBelow it is all there is to see. Decoration. |
| `urgent` | `boolean` | `false` | Puts the icon in an accent mark, its corners nested in the link's, for an emergency line. |
| `iconOnlyBelow` | `"md" \| "lg" \| "nav-phone"` | None | Below this fold point only the icon shows, in a 44px round link: md or lg (Navbar's collapse), or nav-phone (theme.css --breakpoint-nav-phone, md by default). The Navbar passes its phone's iconOnlyBelow, else its own collapse. |
| `tone` | `"page" \| "band"` | `"page"` | page: on the page or a card, the icon in the accent. band: on the Navbar's bar or a band, in the band's colors; put focus-on-band on the wrapper for the band's focus ring (the Navbar does). |
| `class` | `string` | None | More classes, merged with cn(), so yours win on conflicts. |
Any other attribute goes on the <a>.
## Accessibility
- A tel: link with one accessible name at every width: the visible words in their order, then the number, such as "24/7 emergency: (614) 555-0119", or "Call (614) 555-0119" with no words. It does not change at the fold point, so a voice user can say what they see.
- The icon and the urgent mark are decoration, hidden from a screen reader.
- The link is at least 44px tall at every pointer, and 44px square when only the icon shows.
- The number is in tabular figures.
PhoneLink
FreeFor a phone number people tap to call, such as in the header: the label over the number, or an icon on a phone.
- File
- PhoneLink.astro
- Group
- Navigation
- Kind
- Static: no JavaScript
- Examples
- 3
Examples
Drag the orange handle to set the width. Frames get real breakpoints.
- Static
- Interactive
- Framed
Label and number
Your phone icon in the accent, then the label in small capitals over the number in even-width figures. A pill at least 44px tall that calls the number.
examples/phonelink/main.astro
---
import PhoneLink from "@astronomic-dev/ui/components/PhoneLink.astro";
import Phone from "@lucide/astro/icons/phone";
import { plumbing } from "../_data/groundcrew.ts";
---
<!-- Brassfield Plumbing & Drain's main line: the label over the number. -->
<PhoneLink number={plumbing.phone} label="Call us" icon={Phone} />Urgent
urgent puts the icon in an accent mark, for an emergency line. With text, shorter words show in place of the number, and the number stays in the link's name.
examples/phonelink/urgent.astro
---
import PhoneLink from "@astronomic-dev/ui/components/PhoneLink.astro";
import Siren from "@lucide/astro/icons/siren";
import { plumbing } from "../_data/groundcrew.ts";
const line = plumbing.emergency?.phone ?? plumbing.phone;
---
<!-- The after-hours line: the icon in an accent mark, and shorter words in place of the number. -->
<div class="flex flex-wrap items-center gap-4">
<PhoneLink number={line} label="24/7 emergency" icon={Siren} urgent />
<PhoneLink number={line} text="24/7 emergency" icon={Siren} urgent />
</div>Icon only on a phone
iconOnlyBelow="md": below the md fold point the words hide and the icon shows in a 44px round link, with the same name. In a frame, so the fold point is real.
This preview did not load.
examples/phonelink/icon-only.astro
---
import PhoneLink from "@astronomic-dev/ui/components/PhoneLink.astro";
import Phone from "@lucide/astro/icons/phone";
import { construction } from "../_data/groundcrew.ts";
---
<!-- Sixpenny Builders: below the md fold point only the icon shows, in a 44px round link with the same name. -->
<PhoneLink number={construction.phone} label="Call us" icon={Phone} iconOnlyBelow="md" />